Skip to content

Commit

Permalink
Merge pull request #9 from DCAN-Labs/test
Browse files Browse the repository at this point in the history
Implementing pytest
  • Loading branch information
rosemccollum authored Dec 8, 2023
2 parents e060d06 + 7fc605b commit f8c73a4
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/temp/
/src/__pycache__/
/test-param-jsons/
/__pycache__
/__pycache__/
/.pytest_cache/
137 changes: 137 additions & 0 deletions invalid-example.json
Original file line number Diff line number Diff line change
@@ -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\""
]
}
}
}
22 changes: 22 additions & 0 deletions lolcow_test.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
19 changes: 19 additions & 0 deletions lolcow_test.py
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 10 additions & 0 deletions param_test.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit f8c73a4

Please sign in to comment.