diff --git a/.dockerignore b/.dockerignore index 3863da4f..8b74e807 100644 --- a/.dockerignore +++ b/.dockerignore @@ -38,6 +38,5 @@ CITATION.cff LICENSE README.md -# submodules used for testing -bids-examples -neurobagel_examples +# testing +tests diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 023377ab..c6b162bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r dev_requirements.txt - pip install --no-deps -e . + pip install --no-deps . - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.gitmodules b/.gitmodules index cd2afe22..97b7e96b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ [submodule "bids-examples"] - path = bids-examples + path = tests/bids-examples url = https://github.com/bids-standard/bids-examples.git [submodule "neurobagel_examples"] - path = neurobagel_examples + path = tests/neurobagel_examples url = https://github.com/neurobagel/neurobagel_examples.git [submodule "pipeline-catalog"] - path = pipeline-catalog + path = bagel/pipeline-catalog url = https://github.com/nipoppy/pipeline-catalog.git diff --git a/Dockerfile b/Dockerfile index 444647a9..32ead537 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ COPY . /app/src # 1. install the environment from our lockfile RUN pip install -r /app/src/requirements.txt # 2. install the CLI script without touching the dependencies again -RUN pip install --no-cache-dir --no-deps /app/src[all] +RUN pip install --no-cache-dir --no-deps /app/src ENTRYPOINT [ "bagel" ] CMD ["--help"] \ No newline at end of file diff --git a/bagel/mappings.py b/bagel/mappings.py index b99e6249..0acb5b5c 100644 --- a/bagel/mappings.py +++ b/bagel/mappings.py @@ -38,8 +38,9 @@ "assessment_tool": NB.pf + ":Assessment", } +# TODO: Use importlib.resources.files(bagel) to get the path to the pipeline-catalog instead? PROCESSING_PIPELINE_PATH = ( - Path(__file__).parents[1] / "pipeline-catalog" / "processing" + Path(__file__).parent / "pipeline-catalog" / "processing" ) diff --git a/pipeline-catalog b/bagel/pipeline-catalog similarity index 100% rename from pipeline-catalog rename to bagel/pipeline-catalog diff --git a/setup.cfg b/setup.cfg index 5436837e..00c575a6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,6 +29,10 @@ zip_safe = False packages = find: include_package_data = True +[options.package_data] +bagel = + pipeline-catalog/**/* + [options.extras_require] dev = flake8 diff --git a/bagel/tests/__init__.py b/tests/__init__.py similarity index 100% rename from bagel/tests/__init__.py rename to tests/__init__.py diff --git a/bids-examples b/tests/bids-examples similarity index 100% rename from bids-examples rename to tests/bids-examples diff --git a/bagel/tests/conftest.py b/tests/conftest.py similarity index 87% rename from bagel/tests/conftest.py rename to tests/conftest.py index e19bfab0..96b4efe9 100644 --- a/bagel/tests/conftest.py +++ b/tests/conftest.py @@ -13,7 +13,7 @@ def runner(): @pytest.fixture(scope="session") def bids_path(tmp_path_factory): - return Path(__file__).absolute().parent.parent.parent / "bids-examples" + return Path(__file__).absolute().parent / "bids-examples" @pytest.fixture(scope="session") @@ -28,9 +28,7 @@ def test_data(): @pytest.fixture(scope="session") def neurobagel_examples_path(tmp_path_factory): - return ( - Path(__file__).absolute().parent.parent.parent / "neurobagel_examples" - ) + return Path(__file__).absolute().parent / "neurobagel_examples" @pytest.fixture(scope="session") diff --git a/bagel/tests/data/README.md b/tests/data/README.md similarity index 100% rename from bagel/tests/data/README.md rename to tests/data/README.md diff --git a/bagel/tests/data/example1.json b/tests/data/example1.json similarity index 100% rename from bagel/tests/data/example1.json rename to tests/data/example1.json diff --git a/bagel/tests/data/example1.tsv b/tests/data/example1.tsv similarity index 100% rename from bagel/tests/data/example1.tsv rename to tests/data/example1.tsv diff --git a/bagel/tests/data/example10.json b/tests/data/example10.json similarity index 100% rename from bagel/tests/data/example10.json rename to tests/data/example10.json diff --git a/bagel/tests/data/example10.tsv b/tests/data/example10.tsv similarity index 100% rename from bagel/tests/data/example10.tsv rename to tests/data/example10.tsv diff --git a/bagel/tests/data/example11.json b/tests/data/example11.json similarity index 100% rename from bagel/tests/data/example11.json rename to tests/data/example11.json diff --git a/bagel/tests/data/example11.tsv b/tests/data/example11.tsv similarity index 100% rename from bagel/tests/data/example11.tsv rename to tests/data/example11.tsv diff --git a/bagel/tests/data/example12.json b/tests/data/example12.json similarity index 100% rename from bagel/tests/data/example12.json rename to tests/data/example12.json diff --git a/bagel/tests/data/example12.tsv b/tests/data/example12.tsv similarity index 100% rename from bagel/tests/data/example12.tsv rename to tests/data/example12.tsv diff --git a/bagel/tests/data/example13.json b/tests/data/example13.json similarity index 100% rename from bagel/tests/data/example13.json rename to tests/data/example13.json diff --git a/bagel/tests/data/example13.tsv b/tests/data/example13.tsv similarity index 100% rename from bagel/tests/data/example13.tsv rename to tests/data/example13.tsv diff --git a/bagel/tests/data/example14.json b/tests/data/example14.json similarity index 100% rename from bagel/tests/data/example14.json rename to tests/data/example14.json diff --git a/bagel/tests/data/example14.tsv b/tests/data/example14.tsv similarity index 100% rename from bagel/tests/data/example14.tsv rename to tests/data/example14.tsv diff --git a/bagel/tests/data/example15.json b/tests/data/example15.json similarity index 100% rename from bagel/tests/data/example15.json rename to tests/data/example15.json diff --git a/bagel/tests/data/example15.tsv b/tests/data/example15.tsv similarity index 100% rename from bagel/tests/data/example15.tsv rename to tests/data/example15.tsv diff --git a/bagel/tests/data/example16.json b/tests/data/example16.json similarity index 100% rename from bagel/tests/data/example16.json rename to tests/data/example16.json diff --git a/bagel/tests/data/example16.tsv b/tests/data/example16.tsv similarity index 100% rename from bagel/tests/data/example16.tsv rename to tests/data/example16.tsv diff --git a/bagel/tests/data/example17.json b/tests/data/example17.json similarity index 100% rename from bagel/tests/data/example17.json rename to tests/data/example17.json diff --git a/bagel/tests/data/example17.tsv b/tests/data/example17.tsv similarity index 100% rename from bagel/tests/data/example17.tsv rename to tests/data/example17.tsv diff --git a/bagel/tests/data/example18.json b/tests/data/example18.json similarity index 100% rename from bagel/tests/data/example18.json rename to tests/data/example18.json diff --git a/bagel/tests/data/example18.tsv b/tests/data/example18.tsv similarity index 100% rename from bagel/tests/data/example18.tsv rename to tests/data/example18.tsv diff --git a/bagel/tests/data/example19.json b/tests/data/example19.json similarity index 100% rename from bagel/tests/data/example19.json rename to tests/data/example19.json diff --git a/bagel/tests/data/example19.tsv b/tests/data/example19.tsv similarity index 100% rename from bagel/tests/data/example19.tsv rename to tests/data/example19.tsv diff --git a/bagel/tests/data/example2.csv b/tests/data/example2.csv similarity index 100% rename from bagel/tests/data/example2.csv rename to tests/data/example2.csv diff --git a/bagel/tests/data/example2.json b/tests/data/example2.json similarity index 100% rename from bagel/tests/data/example2.json rename to tests/data/example2.json diff --git a/bagel/tests/data/example2.tsv b/tests/data/example2.tsv similarity index 100% rename from bagel/tests/data/example2.tsv rename to tests/data/example2.tsv diff --git a/bagel/tests/data/example2.txt b/tests/data/example2.txt similarity index 100% rename from bagel/tests/data/example2.txt rename to tests/data/example2.txt diff --git a/bagel/tests/data/example20.json b/tests/data/example20.json similarity index 100% rename from bagel/tests/data/example20.json rename to tests/data/example20.json diff --git a/bagel/tests/data/example20.tsv b/tests/data/example20.tsv similarity index 100% rename from bagel/tests/data/example20.tsv rename to tests/data/example20.tsv diff --git a/bagel/tests/data/example21.json b/tests/data/example21.json similarity index 100% rename from bagel/tests/data/example21.json rename to tests/data/example21.json diff --git a/bagel/tests/data/example21.tsv b/tests/data/example21.tsv similarity index 100% rename from bagel/tests/data/example21.tsv rename to tests/data/example21.tsv diff --git a/bagel/tests/data/example3.json b/tests/data/example3.json similarity index 100% rename from bagel/tests/data/example3.json rename to tests/data/example3.json diff --git a/bagel/tests/data/example3.tsv b/tests/data/example3.tsv similarity index 100% rename from bagel/tests/data/example3.tsv rename to tests/data/example3.tsv diff --git a/bagel/tests/data/example4.json b/tests/data/example4.json similarity index 100% rename from bagel/tests/data/example4.json rename to tests/data/example4.json diff --git a/bagel/tests/data/example4.tsv b/tests/data/example4.tsv similarity index 100% rename from bagel/tests/data/example4.tsv rename to tests/data/example4.tsv diff --git a/bagel/tests/data/example5.json b/tests/data/example5.json similarity index 100% rename from bagel/tests/data/example5.json rename to tests/data/example5.json diff --git a/bagel/tests/data/example5.tsv b/tests/data/example5.tsv similarity index 100% rename from bagel/tests/data/example5.tsv rename to tests/data/example5.tsv diff --git a/bagel/tests/data/example6.json b/tests/data/example6.json similarity index 100% rename from bagel/tests/data/example6.json rename to tests/data/example6.json diff --git a/bagel/tests/data/example6.tsv b/tests/data/example6.tsv similarity index 100% rename from bagel/tests/data/example6.tsv rename to tests/data/example6.tsv diff --git a/bagel/tests/data/example7.json b/tests/data/example7.json similarity index 100% rename from bagel/tests/data/example7.json rename to tests/data/example7.json diff --git a/bagel/tests/data/example7.tsv b/tests/data/example7.tsv similarity index 100% rename from bagel/tests/data/example7.tsv rename to tests/data/example7.tsv diff --git a/bagel/tests/data/example8.json b/tests/data/example8.json similarity index 100% rename from bagel/tests/data/example8.json rename to tests/data/example8.json diff --git a/bagel/tests/data/example8.tsv b/tests/data/example8.tsv similarity index 100% rename from bagel/tests/data/example8.tsv rename to tests/data/example8.tsv diff --git a/bagel/tests/data/example9.json b/tests/data/example9.json similarity index 100% rename from bagel/tests/data/example9.json rename to tests/data/example9.json diff --git a/bagel/tests/data/example9.tsv b/tests/data/example9.tsv similarity index 100% rename from bagel/tests/data/example9.tsv rename to tests/data/example9.tsv diff --git a/bagel/tests/data/example_invalid.json b/tests/data/example_invalid.json similarity index 100% rename from bagel/tests/data/example_invalid.json rename to tests/data/example_invalid.json diff --git a/bagel/tests/data/example_invalid.tsv b/tests/data/example_invalid.tsv similarity index 100% rename from bagel/tests/data/example_invalid.tsv rename to tests/data/example_invalid.tsv diff --git a/bagel/tests/data/example_invalid_json.json b/tests/data/example_invalid_json.json similarity index 100% rename from bagel/tests/data/example_invalid_json.json rename to tests/data/example_invalid_json.json diff --git a/bagel/tests/data/example_iso88591.json b/tests/data/example_iso88591.json similarity index 100% rename from bagel/tests/data/example_iso88591.json rename to tests/data/example_iso88591.json diff --git a/bagel/tests/data/example_iso88591.tsv b/tests/data/example_iso88591.tsv similarity index 100% rename from bagel/tests/data/example_iso88591.tsv rename to tests/data/example_iso88591.tsv diff --git a/bagel/tests/data/proc_status_missing_sessions.tsv b/tests/data/proc_status_missing_sessions.tsv similarity index 100% rename from bagel/tests/data/proc_status_missing_sessions.tsv rename to tests/data/proc_status_missing_sessions.tsv diff --git a/bagel/tests/data/proc_status_no_bids_sessions.tsv b/tests/data/proc_status_no_bids_sessions.tsv similarity index 100% rename from bagel/tests/data/proc_status_no_bids_sessions.tsv rename to tests/data/proc_status_no_bids_sessions.tsv diff --git a/bagel/tests/data/proc_status_synthetic.csv b/tests/data/proc_status_synthetic.csv similarity index 100% rename from bagel/tests/data/proc_status_synthetic.csv rename to tests/data/proc_status_synthetic.csv diff --git a/bagel/tests/data/proc_status_synthetic.tsv b/tests/data/proc_status_synthetic.tsv similarity index 100% rename from bagel/tests/data/proc_status_synthetic.tsv rename to tests/data/proc_status_synthetic.tsv diff --git a/bagel/tests/data/proc_status_synthetic_incomplete.tsv b/tests/data/proc_status_synthetic_incomplete.tsv similarity index 100% rename from bagel/tests/data/proc_status_synthetic_incomplete.tsv rename to tests/data/proc_status_synthetic_incomplete.tsv diff --git a/bagel/tests/data/proc_status_unique_sessions.tsv b/tests/data/proc_status_unique_sessions.tsv similarity index 100% rename from bagel/tests/data/proc_status_unique_sessions.tsv rename to tests/data/proc_status_unique_sessions.tsv diff --git a/bagel/tests/data/proc_status_unique_subs.tsv b/tests/data/proc_status_unique_subs.tsv similarity index 100% rename from bagel/tests/data/proc_status_unique_subs.tsv rename to tests/data/proc_status_unique_subs.tsv diff --git a/neurobagel_examples b/tests/neurobagel_examples similarity index 100% rename from neurobagel_examples rename to tests/neurobagel_examples diff --git a/bagel/tests/test_cli_bids.py b/tests/test_cli_bids.py similarity index 98% rename from bagel/tests/test_cli_bids.py rename to tests/test_cli_bids.py index 71388ab5..55e051b7 100644 --- a/bagel/tests/test_cli_bids.py +++ b/tests/test_cli_bids.py @@ -133,6 +133,7 @@ def test_imaging_sessions_have_expected_metadata( def test_bids_data_with_sessions_have_correct_paths( runner, test_data_upload_path, + bids_synthetic, default_pheno_bids_output_path, load_test_json, ): @@ -147,7 +148,7 @@ def test_bids_data_with_sessions_have_correct_paths( "--jsonld-path", test_data_upload_path / "example_synthetic.jsonld", "--bids-dir", - Path(__file__).parent / "../../bids-examples/synthetic", + bids_synthetic, "--output", default_pheno_bids_output_path, ], diff --git a/bagel/tests/test_cli_derivatives.py b/tests/test_cli_derivatives.py similarity index 100% rename from bagel/tests/test_cli_derivatives.py rename to tests/test_cli_derivatives.py diff --git a/bagel/tests/test_cli_pheno.py b/tests/test_cli_pheno.py similarity index 100% rename from bagel/tests/test_cli_pheno.py rename to tests/test_cli_pheno.py diff --git a/bagel/tests/test_utility.py b/tests/test_utility.py similarity index 98% rename from bagel/tests/test_utility.py rename to tests/test_utility.py index d3ca92ff..907a576e 100644 --- a/bagel/tests/test_utility.py +++ b/tests/test_utility.py @@ -514,15 +514,16 @@ def test_create_acquisitions(bids_path, bids_dir, acquisitions, bids_session): "bids_sub_id, session", [("01", "01"), ("02", "02"), ("03", "01")], ) -def test_get_session_path_when_session_exists(bids_sub_id, session): +def test_get_session_path_when_session_exists( + bids_sub_id, session, bids_synthetic +): """ Test that given a subject and session ID (i.e. when BIDS session layer exists for dataset), get_session_path() returns a path to the subject's session directory. """ - bids_dir = Path(__file__).parent / "../../bids-examples/synthetic" session_path = butil.get_session_path( - layout=BIDSLayout(bids_dir, validate=True), - bids_dir=bids_dir, + layout=BIDSLayout(bids_synthetic, validate=True), + bids_dir=bids_synthetic, bids_sub_id=bids_sub_id, session=session, ) @@ -534,12 +535,12 @@ def test_get_session_path_when_session_exists(bids_sub_id, session): @pytest.mark.parametrize("bids_sub_id", ["01", "03", "05"]) -def test_get_session_path_when_session_missing(bids_sub_id): +def test_get_session_path_when_session_missing(bids_sub_id, bids_path): """ Test that given only a subject ID (i.e., when BIDS session layer is missing for dataset), get_session_path() returns the path to the subject directory. """ - bids_dir = Path(__file__).parent / "../../bids-examples/ds001" + bids_dir = bids_path / "ds001" session_path = butil.get_session_path( layout=BIDSLayout(bids_dir, validate=True), bids_dir=bids_dir,