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. |
| 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
| # 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.
- let's make at least
_sesstrictly followingsub-if present - according to https://github.com/dandi/dandi-cli/blob/HEAD/dandi/organize.py#L45 is still missing
probeandobj.
There was a problem hiding this comment.
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.
@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.
according to potential_fields, ses is not mandatory, so other entities could occur without a preceding ses.
|
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.