Skip to content

Commit

Permalink
rename example yaml files; fix yaml file names in pytest;
Browse files Browse the repository at this point in the history
  • Loading branch information
Chenying Zhao committed May 25, 2023
1 parent 25f7ed5 commit 0553121
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 4 deletions.
8 changes: 8 additions & 0 deletions notebooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Notebooks folder

## Example container configuration YAML files
* Naming convension: `eg_<bidsapp-0-0-0>_<task>_<system>_<cluster_name>.yaml`
* `<bidsapp-0-0-0>`: BIDS App name and version
* `<task>`: For what application of BIDS App? Full run? Sloppy mode?
* `<system>`: `sge` or `slurm`
* `<cluster_name>`: name of example cluster where the YAML file was tested
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions tests/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,59 @@ def container_ds_path(where_now, tmp_path_factory):

return origin_container_ds

def get_container_config_yaml_filename(which_bidsapp,
which_input, if_two_input,
type_system):
"""
This is to get the container's config YAML file name,
depending on the BIDS App and if there are two inputs (for fMRIPrep)
Parameters:
-------------
which_bidsapp: str
name of the bidsapp
which_input: str
"BIDS" for raw BIDS
"fmriprep" for zipped BIDS derivates
if_two_input: bool
whether there are two input BIDS datasets
type_system: str
"sge" or "slurm"
Returns:
-----------
container_config_yaml_filename: str
the filename, without the path.
"""
dict_cluster_name = {'sge': 'cubic',
'slurm': 'msi'}
dict_bidsapp_version = {"qsiprep": "0-16-0RC3",
"fmriprep": "20-2-3",
"toybidsapp": "0-0-7"}
dict_task_name = {"qsiprep": 'sloppy',
"fmriprep": "full",
"toybidsapp": "rawBIDS"}

# bidsapp and its version:
container_config_yaml_filename = "eg_" + which_bidsapp + "-" \
+ dict_bidsapp_version[which_bidsapp]

# task:
container_config_yaml_filename += "_"
if (which_bidsapp == "fmriprep") & if_two_input:
container_config_yaml_filename += "ingressed-fs"
elif (which_bidsapp == "toybidsapp") & (which_input == "fmriprep"):
# the input is zipped BIDS derivatives:
container_config_yaml_filename += "zipped"
else:
container_config_yaml_filename += dict_task_name[which_bidsapp]

# cluster system type and example name:
container_config_yaml_filename += "_" + type_system + "_" \
+ dict_cluster_name[type_system] + ".yaml"

return container_config_yaml_filename


def if_command_installed(cmd):
"""
Expand Down
5 changes: 5 additions & 0 deletions tests/test_babs_check_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
container_ds_path,
where_now,
if_circleci,
get_container_config_yaml_filename,
__location__,
INFO_2ND_INPUT_DATA,
LIST_WHICH_BIDSAPP,
Expand Down Expand Up @@ -80,8 +81,12 @@ def test_babs_check_setup(
project_root = op.join(where_project, project_name)
container_name = which_bidsapp + "-" + TOYBIDSAPP_VERSION_DASH
container_config_yaml_filename = "example_container_" + which_bidsapp + ".yaml"
container_config_yaml_filename = \
get_container_config_yaml_filename(which_bidsapp, which_input, if_two_input=False,
type_system="sge") # TODO: also test slurm!
container_config_yaml_file = op.join(op.dirname(__location__), "notebooks",
container_config_yaml_filename)
assert op.exists(container_config_yaml_file)

# below are all correct options:
babs_init_opts = argparse.Namespace(
Expand Down
11 changes: 7 additions & 4 deletions tests/test_babs_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
container_ds_path,
where_now,
if_circleci,
get_container_config_yaml_filename,
__location__,
INFO_2ND_INPUT_DATA,
LIST_WHICH_BIDSAPP,
Expand Down Expand Up @@ -71,6 +72,8 @@ def test_babs_init(which_bidsapp, which_input, type_session, if_input_local, if_
Path to the container datalad dataset
if_circleci: fixture; bool
Whether currently in CircleCI
TODO: add `type_system` and to test out Slurm version!
"""
# Sanity checks:
assert which_bidsapp in LIST_WHICH_BIDSAPP
Expand All @@ -94,12 +97,12 @@ def test_babs_init(which_bidsapp, which_input, type_session, if_input_local, if_

# Preparation of freesurfer: for fmriprep and qsiprep:
# check if `--fs-license-file` is included in YAML file:
container_config_yaml_filename = "example_container_" + which_bidsapp + ".yaml"
if (which_bidsapp == "fmriprep") & if_two_input:
container_config_yaml_filename = \
"example_container_" + which_bidsapp + "_ingressed_fs.yaml"
container_config_yaml_filename = \
get_container_config_yaml_filename(which_bidsapp, which_input, if_two_input,
type_system="sge") # TODO: also test slurm!
container_config_yaml_file = op.join(op.dirname(__location__), "notebooks",
container_config_yaml_filename)
assert op.exists(container_config_yaml_file)
container_config_yaml = read_yaml(container_config_yaml_file)

if "--fs-license-file" in container_config_yaml["singularity_run"]:
Expand Down

0 comments on commit 0553121

Please sign in to comment.