diff --git a/.gitignore b/.gitignore index 41f5d7c..51933a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /temp/ /src/__pycache__/ /test-param-jsons/ -/__pycache__ \ No newline at end of file +/__pycache__/ +/.pytest_cache/ \ No newline at end of file diff --git a/invalid-example.json b/invalid-example.json new file mode 100644 index 0000000..901f53c --- /dev/null +++ b/invalid-example.json @@ -0,0 +1,137 @@ +{ + "cabinet": { + "container_type": "singularity", + "stages": ["bibsnet", "solve_world_hunger", "nibabies"], + "verbose": true, + "handle_missing_host_paths": "make_directories" + }, + + "stages": { + "bibsnet": { + "container_filepath": "/home/faird/shared/code/internal/pipelines/cabinet_container/cabinet_v2.4.3.sif", + "container_args": { + "--cleanenv": true, + "--nv": true + }, + "binds": [ + { + "host_path":"/home/faird/shared/data/BCP-MVP_BIBSNet/input/", + "container_path":"/input" + }, + { + "host_path":"/home/feczk001/shared/projects/segpipeline_testing/Barry_test/cbaw-test/derivatives/" + }, + { + "host_path":"/home/feczk001/shared/projects/segpipeline_testing/Barry_test/cbaw-test/work/", + "container_path":"/work" + } + ], + "positional_args": [ + "/input", "/output", "participant" + ], + "flags": { + "--parameter-json":"/home/cabinet/parameter-file-container.json", + "-start":"prebibsnet", + "-end":"postbibsnet", + "-v": true, + "--participant-label":"470437", + "-w":"/work" + } + }, + "nibabies": { + "container_filepath": "/home/faird/shared/code/external/pipelines/nibabies/nibabies_t1-t2-derivatives_08102023.sif", + "container_args": { + "--cleanenv": true + }, + "binds": [ + { + "host_path":"/home/faird/shared/data/BCP-MVP_BIBSNet/input/", + "container_path":"/bids_dir" + }, + { + "host_path":"/home/feczk001/shared/projects/segpipeline_testing/Barry_test/cbaw-test/derivatives/nibabies/", + "container_path":"/output_dir" + }, + { + "host_path":"/home/feczk001/shared/projects/segpipeline_testing/Barry_test/cbaw-test/work/", + "container_path":"/work" + }, + { + "host_path":"/home/faird/shared/code/external/utilities/freesurfer_license/license.txt", + "container_path":"/opt/freesurfer/license.txt" + }, + { + "host_path":"/home/feczk001/shared/projects/segpipeline_testing/Barry_test/cbaw-test/derivatives/bibsnet/", + "container_path":"/derivatives" + }, + { + "host_path":"/home/faird/tikal004/fake/file/path/", + "container_path":"/fake_path" + } + ], + "positional_args": [ + "/bids_dir", "/output_dir", "participant" + ], + "flags": { + "--project-goodvoxels": true, + "--surface-recon-method": "mcribs", + "--omp-nthreads": 3, + "--resource-monitor": true, + "--cifti-output": "91k", + "-vv": true, + "-w": "/work", + "--fd-radius": 35, + "--derivatives": "/derivatives", + "--age-months": 1, + "--participant-label":"470437" + } + }, + "xcpd": { + "container_args": { + "--cleanenv": true + }, + "binds": [ + { + "host_path":"/home/feczk001/shared/projects/segpipeline_testing/Barry_test/cbaw-test/work/", + "container_path":"/work" + }, + { + "host_path":"/home/faird/shared/code/external/utilities/freesurfer_license/license.txt", + "container_path":"/opt/freesurfer/license.txt" + }, + { + "host_path":"/home/feczk001/shared/projects/segpipeline_testing/Barry_test/cbaw-test/derivatives/", + "container_path":"/output_dir" + }, + { + "host_path":"/home/faird/shared/code/external/pipelines/xcp_d_test_binds/20230712_fix-collection/xcp_d/xcp_d", + "container_path":"/usr/local/miniconda/lib/python3.8/site-packages/xcp_d" + } + ], + "positional_args": [ + "/output_dir/nibabies", "/output_dir/", "participant" + ], + "flags": { + "--input-type": "nibabies", + "--cifti": true, + "--despike":true, + "--resource-monitor": true, + "--dcan-qc": true, + "-w": "/work", + "--omp-nthreads": 3, + "--warp-surfaces-native2std": true, + "-f": 0.3, + "-m": true, + "-vv": true, + "--participant-label": "470437" + } + }, + "lolcow": { + "container_filepath": "/home/faird/tikal004/lolcow.sif", + "action": "exe", + "positional_args": [ + "cowsay", "\"Thank you for testing CABINET\"" + ] + } + } +} diff --git a/lolcow_test.json b/lolcow_test.json new file mode 100644 index 0000000..bab8361 --- /dev/null +++ b/lolcow_test.json @@ -0,0 +1,22 @@ +{ + "cabinet": { + "container_type": "singularity", + "stages": ["lolcow", "dockerfail", "lolcow", "lolcow-exec"] + }, + + "stages": { + "lolcow": { + "container_filepath": "/home/faird/shared/code/internal/utilities/test_containers/lolcow.sif" + }, + "dockerfail": { + "container_filepath": "/home/faird/shared/code/internal/utilities/test_containers/dockerfail.sif" + }, + "lolcow-exec": { + "action": "exec", + "container_filepath": "/home/faird/shared/code/internal/utilities/test_containers/lolcow.sif", + "positional_args": [ + "cowsay", "Thank you for testing CABINET" + ] + } + } +} diff --git a/lolcow_test.py b/lolcow_test.py new file mode 100755 index 0000000..b942e92 --- /dev/null +++ b/lolcow_test.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# coding: utf-8 + +from src.valid_jargs_class import ValidJargs +from src.wrapper_class import Wrapper + +param_json = "lolcow_test.json" + +Jargs = ValidJargs(param_json) + +Test = Wrapper(Jargs) + +def test_run_stage_pass(): + + assert Test.run_stage("lolcow") + +def test_run_stage_fail(): + + assert not Test.run_stage("dockerfail") diff --git a/param_test.py b/param_test.py new file mode 100644 index 0000000..4c1220c --- /dev/null +++ b/param_test.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# coding: utf-8 + +from src.valid_jargs_class import ValidJargs + +param_json = "invalid-example.json" + +Jargs = ValidJargs(param_json) + +assert not Jargs.validate_cabinet_options() \ No newline at end of file