check-setup: validate input datasets at their configured path_in_babs - #407
Open
yibeichan wants to merge 1 commit into
Open
check-setup: validate input datasets at their configured path_in_babs#407yibeichan wants to merge 1 commit into
yibeichan wants to merge 1 commit into
Conversation
Closes PennLINC#325. `babs_check_setup` probed a hardcoded `<analysis>/inputs/data` before validating each input dataset. `babs init` clones each input to its configured `path_in_babs`, so any project not using the default layout fails here with a raw FileNotFoundError from os.listdir: FileNotFoundError: [Errno 2] No such file or directory: '.../analysis/inputs/data' Since PennLINC#369 this also affects a layout BABS itself generates: the BIDS-study layout puts inputs under `sourcedata/<name>`, so `babs check-setup` cannot run on those projects at all. The pre-check was already redundant. The per-dataset loop immediately below resolves `in_ds.babs_project_analysis_path` and raises for a missing directory or a non-DataLad dataset, using the configured path. The only condition the pre-check uniquely covered is "no input datasets configured", which is a property of the config rather than of the filesystem -- so check that directly. `get_immediate_subdirectories` was imported here only for this call and is now unused in babs/ (its definition in utils.py is left in place). Verified against a real BIDS-study-layout project (path_in_babs: sourcedata/BIDS, sourcedata/NIDM): the old pre-check raises FileNotFoundError, the new one passes and both input datasets then validate at their configured paths.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #407 +/- ##
==========================================
- Coverage 79.39% 79.38% -0.01%
==========================================
Files 17 17
Lines 2169 2168 -1
Branches 384 384
==========================================
- Hits 1722 1721 -1
Misses 302 302
Partials 145 145 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #325.
The bug
babs_check_setupprobes a hardcoded<analysis>/inputs/databefore validatingthe input datasets:
babs initclones each input dataset to its configuredpath_in_babs, so on anyproject not using the default layout this raises a raw
FileNotFoundErrorout ofos.listdir— not even the friendlyValueErroron the line below, which onlyfires for a directory that exists but is empty.
Since #369 this affects a layout BABS itself generates. The BIDS-study layout
puts inputs under
sourcedata/<name>, sobabs initwrites:and the resulting analysis directory has
sourcedata/{BIDS,NIDM}and noinputs/at all.
babs check-setupcannot run on such a project, which means losing thetest-job and environment checks that do work — we currently skip check-setup
entirely on every run.
The fix
The pre-check was already redundant. The per-dataset loop immediately below
resolves
in_ds.babs_project_analysis_pathand raises for a missing directoryor a non-DataLad dataset, using the configured path — so it covers everything
the hardcoded probe did, correctly.
The one condition the probe uniquely covered is "no input datasets configured",
which is a property of the config rather than of the filesystem. This PR checks
that directly and drops the path probe, so there is no second path-resolution
to keep in sync with
path_in_babs.get_immediate_subdirectorieswas imported here only for that call. It is nowunused within
babs/, but its definition inutils.pyis left in place — it ispublic API and
tests/test_utils.py::test_get_immediate_subdirectoriescovers it.Verification
Against a real BIDS-study-layout project (
path_in_babs: sourcedata/BIDSandsourcedata/NIDM), onea5d6f0:ruff checkandruff format --checkare clean on the changed file.On tests: I did not add one. The existing
tests/test_check_setup.pycases areintegration tests built on the
babs_project_*fixtures and the simbids apptainerimage, which I can't run in my environment, and there is no study-layout fixture to
extend. Happy to add a regression test if you can point me at the fixture you'd want
it built on — a
path_in_babs-varying project fixture would cover this directly.