Handling FileNotFoundError in BIDSLayout Initialization when is_derivative=True and validate=False, also resolves #1050 #1049
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.
This pull request addresses an issue encountered when initializing a
BIDSLayout
with a derivatives directory that does not contain adataset_description.json
file. Previously, aFileNotFoundError
would be raised in such cases, even whenvalidate=False
was set.The proposed change allows for a
FileNotFoundError
to be caught and handled gracefully during the initialization of aBIDSLayout
. This allows for the indexing of derivatives without adataset_description.json
file, aligning with the description ofis_derivative
parameter that states this parameter "can be enabled along with validate=False to index derivatives without dataset_description.json."The specific change involves modifying the exception handling at line 142 in
layout.py
to catch bothBIDSValidationError
andFileNotFoundError
. This ensures that the initialization process can continue even if thedataset_description.json
file is missing.