Skip to content

Commit

Permalink
Use /home/aljen.uitbeijerse in parameter xmls, and have a replace fun…
Browse files Browse the repository at this point in the history
…ction for it in trigger_install

To prepare for adding windows test jobs that can use the same parameter xml
  • Loading branch information
AljenU committed Nov 25, 2021
1 parent 663fa96 commit 6369673
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 21 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/aap_parameters_defaults_GitHub.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<aap xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="/home/runner/work/automaticanalysis/automaticanalysis/aa_parametersets/aap_parameters_defaults.xml" parse="xml"/>
<xi:include href="$HOME/work/automaticanalysis/automaticanalysis/aa_parametersets/aap_parameters_defaults.xml" parse="xml"/>
<local>
<directory_conventions>
<rawdatadir desc='Directories to find raw MRI data' ui='dir_list'>/home/runner/data/aa_demo</rawdatadir>
<rawmeegdatadir desc='Directory to find raw MEEG data' ui='dir'>/home/runner/data/aa_demo</rawmeegdatadir>
<rawdatadir desc='Directories to find raw MRI data' ui='dir_list'>$HOME/data/aa_demo</rawdatadir>
<rawmeegdatadir desc='Directory to find raw MEEG data' ui='dir'>$HOME/data/aa_demo</rawmeegdatadir>
<rawdataafterconversionprefix desc='Prefix of raw data after conversion from DICOM to NIFTI' ui='text'>fMR</rawdataafterconversionprefix>
<subject_directory_format desc='Format of subject directory' ui='optionlist' options='from subject_directory_names|from data|S#|manual'>3</subject_directory_format>
<rawseries_usefileorder desc='In raw data, use number in file listing not filtering by series number' ui='yesno'>0</rawseries_usefileorder>
Expand All @@ -20,33 +20,33 @@
<dicomfilter ui='text'>*.IMA</dicomfilter>
<toolbox desc='Toolbox with implemented interface in extrafunctions/toolboxes' ui='custom'>
<name desc='Name corresponding to the name of the interface without the "Class" suffix' ui='text'>spm</name>
<dir ui='dir'>/home/runner/tools/spm12</dir>
</toolbox>
<dir ui='dir'>$HOME/tools/spm12</dir>
</toolbox>
<toolbox desc='Toolbox with implemented interface in extrafunctions/toolboxes' ui='custom'>
<name desc='Name corresponding to the name of the interface without the "Class" suffix' ui='text'>wls</name>
<dir ui='dir'>/home/runner/tools/rwls</dir>
<dir ui='dir'>$HOME/tools/rwls</dir>
</toolbox>
<toolbox desc='Toolbox with implemented interface in extrafunctions/toolboxes' ui='custom'>
<name desc='Name corresponding to the name of the interface without the "Class" suffix' ui='text'>aroma</name>
<dir ui='dir'>/home/runner/tools/ICA-AROMA</dir>
<dir ui='dir'>$HOME/tools/ICA-AROMA</dir>
</toolbox>
<linuxshell desc='Linux shell used to run linux commands' ui='text'>bash</linuxshell>
<fsldir desc='Path to fsl' ui='dir'>/home/runner/tools/fsl</fsldir>
<fslsetup desc='Path to fsl setup script, executing before any fsl command' ui='text'>/home/runner/tools/config/fsl_bash.sh</fslsetup>
<fsldir desc='Path to fsl' ui='dir'>$HOME/tools/fsl</fsldir>
<fslsetup desc='Path to fsl setup script, executing before any fsl command' ui='text'>$HOME/tools/config/fsl_bash.sh</fslsetup>
<fslshell desc='Shell used to run FSL' ui='text'>bash</fslshell>
<fsloutputtype desc='Output type used by FSL' ui='text'>NIFTI</fsloutputtype>
<freesurferdir desc='Path to freesurfer' ui='dir'>/home/runner/tools/freesurfer</freesurferdir>
<freesurferdir desc='Path to freesurfer' ui='dir'>$HOME/tools/freesurfer</freesurferdir>
<freesurfershell desc='Shell used to run FreeSurfer' ui='text'>bash</freesurfershell>
<freesurfersetup desc='Path to FreeSurfer setup script, executing before any FreeSurfer command' ui='text'></freesurfersetup>
<freesurferenvironment desc='Path to FreeSurfer environmental setup script, executing before any FreeSurfer command' ui='text'>/home/runner/tools/freesurfer/FreeSurferEnv.sh;</freesurferenvironment>
<templatedir desc='Path to folder with various templates (e.g. for aamod_freesurfer_deface)' ui='dir'>/home/runner/tools/templates</templatedir>
<FaceMaskingdir desc='Path to FaceMasking (WUSTL NRG)' ui='dir'>/home/runner/tools/mask_face/nrg-improc</FaceMaskingdir>
<freesurferenvironment desc='Path to FreeSurfer environmental setup script, executing before any FreeSurfer command' ui='text'>$HOME/tools/freesurfer/FreeSurferEnv.sh;</freesurferenvironment>
<templatedir desc='Path to folder with various templates (e.g. for aamod_freesurfer_deface)' ui='dir'>$HOME/tools/templates</templatedir>
<FaceMaskingdir desc='Path to FaceMasking (WUSTL NRG)' ui='dir'>$HOME/tools/mask_face/nrg-improc</FaceMaskingdir>
<allowremotecache desc='Allow local caching of files from remote server' ui='optionlist'>1</allowremotecache>
<poolprofile desc='Cluster Profile and (optional) initial submit argument (e.g. asking for specific queue or resource) separated with colon' ui='text'>local</poolprofile>
</directory_conventions>
<options>
<maximumretry desc='Maximum number of (re)tries to retrieve file' ui='double'>5</maximumretry>
<NIFTI4D desc="Use NIFTI-4D instead of NIFTI-3D" ui="yesno">1</NIFTI4D>
<maximumretry desc='Maximum number of (re)tries to retrieve file' ui='double'>5</maximumretry>
<NIFTI4D desc="Use NIFTI-4D instead of NIFTI-3D" ui="yesno">1</NIFTI4D>
<hardlinks desc='Allow hardlinks during retrieving inputs' ui='yesno'>0</hardlinks>
<wheretoprocess desc='where to do processing' options='localsingle|localparallel|aws|qsub' ui='optionlist'>localsingle</wheretoprocess>
<garbagecollection desc='Perform garbage collection after the analysis' ui='yesno'>1</garbagecollection>
Expand All @@ -55,11 +55,11 @@
<restorepath desc='Restore linux and MATLAB path upon closing' ui='yesno'>1</restorepath>
<diagnostic_videos desc='Enable diagnostic videos (matlab not stable on some platforms)' ui='yesno'>0</diagnostic_videos>
<autoidentifyfieldmaps desc='Automatically identify field maps?' ui='yesno'>0</autoidentifyfieldmaps>
<autoidentifyt2 desc='Automatically identify T2?' ui='yesno'>0</autoidentifyt2>
<autoidentifyt2 desc='Automatically identify T2?' ui='yesno'>0</autoidentifyt2>
<autoidentifytmaps desc='Automatically identify t maps?' ui='yesno'>0</autoidentifytmaps>
</options>
<acq_details>
<root desc='Root on local machine for processed data' ui='dir'>/home/runner/projects</root>
<root desc='Root on local machine for processed data' ui='dir'>$HOME/projects</root>
</acq_details>
</local>
</aap>
8 changes: 4 additions & 4 deletions .github/workflows/aap_parameters_defaults_GitHub_minimal.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<aap xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="/home/runner/work/automaticanalysis/automaticanalysis/aa_parametersets/aap_parameters_defaults.xml" parse="xml"/>
<xi:include href="$HOME/work/automaticanalysis/automaticanalysis/aa_parametersets/aap_parameters_defaults.xml" parse="xml"/>
<local>
<directory_conventions>
<rawdatadir desc='Directories to find raw MRI data' ui='dir_list'>/home/runner/data/aa_demo</rawdatadir>
<rawdatadir desc='Directories to find raw MRI data' ui='dir_list'>$HOME/data/aa_demo</rawdatadir>
<toolbox desc='Toolbox with implemented interface in extrafunctions/toolboxes' ui='custom'>
<name desc='Name corresponding to the name of the interface without the "Class" suffix' ui='text'>spm</name>
<dir ui='dir'>/home/runner/tools/spm12</dir>
<dir ui='dir'>$HOME/tools/spm12</dir>
</toolbox>
</directory_conventions>
<acq_details>
<root desc='Root on local machine for processed data' ui='dir'>/home/runner/projects</root>
<root desc='Root on local machine for processed data' ui='dir'>$HOME/projects</root>
</acq_details>
</local>
</aap>
33 changes: 33 additions & 0 deletions .github/workflows/trigger_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,47 @@
# Using python (instead of matlab) because using system() in matlab gives enormous amount of
# command window output, and there is some problem with the status code from system()

import os
import sys
import subprocess
import platform

def main():
# Replace before any install, because various install steps use the parameter xml
parameter_xml_env_var_replace()
do_install()


def parameter_xml_env_var_replace():
"""Platform-indepent replacement of environment variables in the source parameter xml
Path specifications in the parameter xml use environment variable references because
paths are different on the different runner platforms. However, environment variable
references themselves are also platform-dependent.
Replace specific unix-style environment variable references in the parameter xml file
with the value of the environment variable on the current runner platform, to produce
a parameter xml file without env var references."""

var_workspace = os.environ['GITHUB_WORKSPACE']
var_par_xml = os.environ['PARAMETER_XML']
# TODO: check that home is also ok on windows.
var_home = os.environ['HOME']

# Read in the file
fname = os.path.join(var_workspace, '.github', 'workflows', var_par_xml)
with open(fname, 'r') as file :
filedata = file.read()

# Replace $HOME with its value
filedata = filedata.replace('$HOME', var_home)

# Write the file out again
with open(fname, 'w') as file:
file.write(filedata)

def do_install():
"""Install tools and parameter xml """
plt = platform.system()
if plt == "Windows":
print("Your system is Windows")
Expand Down

0 comments on commit 6369673

Please sign in to comment.