Skip to content

Commit

Permalink
[FIX] Package pipeline-catalog as data files in CLI installation (#379
Browse files Browse the repository at this point in the history
)

* move pipeline-catalog submodule into bagel package

* update path to processing pipeline index

* add pipeline-catalog to package installation

* move tests out of bagel module and update paths

* move submodules for test data into tests module

* update dockerignore

* update test data paths

* do not install CLI in editable mode in CI tests

* install minimal dependencies in Docker image
  • Loading branch information
alyssadai authored Nov 7, 2024
1 parent e4897ba commit edf59d7
Show file tree
Hide file tree
Showing 72 changed files with 24 additions and 20 deletions.
5 changes: 2 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ CITATION.cff
LICENSE
README.md

# submodules used for testing
bids-examples
neurobagel_examples
# testing
tests
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
3 changes: 2 additions & 1 deletion bagel/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)


Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ zip_safe = False
packages = find:
include_package_data = True

[options.package_data]
bagel =
pipeline-catalog/**/*

[options.extras_require]
dev =
flake8
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions bagel/tests/conftest.py → tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion bagel/tests/test_cli_bids.py → tests/test_cli_bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand All @@ -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,
],
Expand Down
File renamed without changes.
File renamed without changes.
13 changes: 7 additions & 6 deletions bagel/tests/test_utility.py → tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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,
Expand Down

0 comments on commit edf59d7

Please sign in to comment.