-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validation of filepaths for non-BIDS NWB assets #1173
Conversation
Codecov ReportBase: 88.92% // Head: 89.16% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1173 +/- ##
==========================================
+ Coverage 88.92% 89.16% +0.23%
==========================================
Files 76 76
Lines 9393 9506 +113
==========================================
+ Hits 8353 8476 +123
+ Misses 1040 1030 -10
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -29,6 +29,7 @@ | |||
from dandi.dandiapi import RemoteAsset, RemoteDandiset, RESTFullAPIClient | |||
from dandi.metadata import get_default_metadata, nwb2asset | |||
from dandi.misctypes import DUMMY_DIGEST, Digest, P | |||
from dandi.organize import validate_organized_path |
Check notice
Code scanning / CodeQL
Cyclic import
@@ -537,6 +541,29 @@ | |||
raise | |||
# TODO: might reraise instead of making it into an error | |||
return _pydantic_errors_to_validation_results([e], str(self.filepath)) | |||
|
|||
from .bids import NWBBIDSAsset |
Check notice
Code scanning / CodeQL
Cyclic import
dandi/organize.py
Outdated
|
||
LABELREGEX = r"[^_*\\/<>:|\"'?%@;.]+" | ||
ORGANIZED_FILENAME_REGEX = ( | ||
rf"sub-{LABELREGEX}(_(ses|tis|slice|cell)-{LABELREGEX})*(_[a-z]+(\+[a-z]+)*)?\.nwb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- let's make at least
_ses
strictly followingsub-
if present - according to https://github.com/dandi/dandi-cli/blob/HEAD/dandi/organize.py#L45 is still missing
probe
andobj
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally there should be a single data structure describing entities etc we should have in the filename. In principle that potential_fields
is the one but I guess can't be used here "as is", unless you enrich that structure with regexes for the values, in particular for extensions etc. Then this regex can be constructed programmatically and we would avoid duplication of this knowledge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yarikoptic Can tis/slice/cell/probe/obj occur without a preceding ses, or is ses a prerequisite for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to potential_fields
, ses
is not mandatory, so other entities could occur without a preceding ses
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 55df999.
ok, I dislike that we have duplication of specification ATM between organize and validate but ok -- let's RF it after. Meanwhlie filed #1174 which found while test driving, and seems to work:
although messages are a bit cryptic I guess. |
Closes #1163.