From 4369f1b5b16fbf4e80c4e9be6d1e928c1d400432 Mon Sep 17 00:00:00 2001 From: Barry Tikalsky Date: Fri, 10 Nov 2023 14:25:23 -0600 Subject: [PATCH 1/5] changed default to empty list --- src/valid_jargs_class.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/valid_jargs_class.py b/src/valid_jargs_class.py index 9021bc7..672cab2 100644 --- a/src/valid_jargs_class.py +++ b/src/valid_jargs_class.py @@ -181,7 +181,7 @@ def validate_stage(self, stage): options["binds"] = { "required": False, "type": list, - "default": {} + "default": [] } elif container_type == "docker": @@ -192,7 +192,7 @@ def validate_stage(self, stage): options["mounts"] = { "required": False, "type": list, - "default": {} + "default": [] } for option, requirements in options.items(): From 7381cdddba080b4281c89826b07d2ed7b950f98c Mon Sep 17 00:00:00 2001 From: Barry Tikalsky Date: Fri, 10 Nov 2023 14:25:47 -0600 Subject: [PATCH 2/5] adding basic tests --- .gitignore | 4 +++- lolcow_test.json | 22 ++++++++++++++++++++++ lolcow_test.py | 19 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 lolcow_test.json create mode 100755 lolcow_test.py diff --git a/.gitignore b/.gitignore index 11ed1fb..51933a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /temp/ /src/__pycache__/ -/test-param-jsons/ \ No newline at end of file +/test-param-jsons/ +/__pycache__/ +/.pytest_cache/ \ No newline at end of file diff --git a/lolcow_test.json b/lolcow_test.json new file mode 100644 index 0000000..0d9f318 --- /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/tikal004/sif-files/lolcow.sif" + }, + "dockerfail": { + "container_filepath": "/home/faird/tikal004/sif-files/dockerfail.sif" + }, + "lolcow-exec": { + "action": "exec", + "container_filepath": "/home/faird/tikal004/sif-files/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..939814f --- /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") == True + +def test_run_stage_fail(): + + assert Test.run_stage("dockerfail") == False From 67b3fa24d1163fba50dfa21d29b3fb5f31673a5c Mon Sep 17 00:00:00 2001 From: Barry Tikalsky Date: Fri, 10 Nov 2023 14:29:55 -0600 Subject: [PATCH 3/5] moved sif files to shared dir --- lolcow_test.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lolcow_test.json b/lolcow_test.json index 0d9f318..bab8361 100644 --- a/lolcow_test.json +++ b/lolcow_test.json @@ -6,14 +6,14 @@ "stages": { "lolcow": { - "container_filepath": "/home/faird/tikal004/sif-files/lolcow.sif" + "container_filepath": "/home/faird/shared/code/internal/utilities/test_containers/lolcow.sif" }, "dockerfail": { - "container_filepath": "/home/faird/tikal004/sif-files/dockerfail.sif" + "container_filepath": "/home/faird/shared/code/internal/utilities/test_containers/dockerfail.sif" }, "lolcow-exec": { "action": "exec", - "container_filepath": "/home/faird/tikal004/sif-files/lolcow.sif", + "container_filepath": "/home/faird/shared/code/internal/utilities/test_containers/lolcow.sif", "positional_args": [ "cowsay", "Thank you for testing CABINET" ] From b88a02d7a878bd617724535827e22b674e323eff Mon Sep 17 00:00:00 2001 From: Barry Tikalsky Date: Fri, 8 Dec 2023 13:46:36 -0600 Subject: [PATCH 4/5] testing parameter ingestion --- invalid-example.json | 137 +++++++++++++++++++++++++++++++++++++++++++ param_test.py | 10 ++++ 2 files changed, 147 insertions(+) create mode 100644 invalid-example.json create mode 100644 param_test.py 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/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 From 7fc605b86a61341fd268c0629097616e3a672b0b Mon Sep 17 00:00:00 2001 From: Barry Tikalsky Date: Fri, 8 Dec 2023 14:15:23 -0600 Subject: [PATCH 5/5] updated tests --- lolcow_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lolcow_test.py b/lolcow_test.py index 939814f..b942e92 100755 --- a/lolcow_test.py +++ b/lolcow_test.py @@ -12,8 +12,8 @@ def test_run_stage_pass(): - assert Test.run_stage("lolcow") == True + assert Test.run_stage("lolcow") def test_run_stage_fail(): - assert Test.run_stage("dockerfail") == False + assert not Test.run_stage("dockerfail")