Allow user to specify mandatory (if not empty) fields in organize#1171
Allow user to specify mandatory (if not empty) fields in organize#1171yarikoptic merged 6 commits intomasterfrom
Conversation
Codecov ReportBase: 89.15% // Head: 89.16% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1171 +/- ##
=======================================
Coverage 89.15% 89.16%
=======================================
Files 76 76
Lines 9510 9525 +15
=======================================
+ Hits 8479 8493 +14
- Misses 1031 1032 +1
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. |
|
@yarikoptic To be clear, by "mandatory" you mean "must be included in organized filenames (rather than only being included if necessary for disambiguation)", correct? There's probably a better way to word that. EDIT: Would |
correct
it seems we never exposed in API/CLI the "mandatory"❯ git grep mandatory
dandi/organize.py: "subject_id": {"format": "sub-{}", "type": "mandatory"},
dandi/organize.py: "modalities": {"format": "_{}", "type": "mandatory_if_not_empty"},
dandi/organize.py: "extension": {"format": "{}", "type": "mandatory"},
dandi/organize.py: "mandatory",
dandi/organize.py: "mandatory_if_not_empty",
dandi/organize.py: # we will add _mandatory_if_not_empty to those files records, which will
dandi/organize.py: r["_mandatory_if_not_empty"] = r.get(
dandi/organize.py: "_mandatory_if_not_empty", []
dandi/organize.py: # unless it is mandatory, we would not include the fields with more than
dandi/organize.py: (field_type == "mandatory")
dandi/organize.py: field_type == "mandatory_if_not_empty"
dandi/organize.py: or (field in r.get("_mandatory_if_not_empty", []))
dandi/validate.py: if pattern.get("mandatory") or pattern.get("required"):
versioneer.py: VCS = parser.get("versioneer", "VCS") # mandatoryand I agree that |
481b00f to
0a5f20c
Compare
|
@yarikoptic How exactly should I test this? Are any of the |
if currently you |
|
@yarikoptic Done? |
dandi/organize.py
Outdated
|
|
||
| def get_obj_id(object_id): | ||
| """Given full object_id, get its shortened version""" | ||
| import numpy as np |
There was a problem hiding this comment.
why was it moved? because otherwise not used anywhere?
There was a problem hiding this comment.
potential_fields now needs to be imported from organize.py in order to be used in the --required-field definition, but that leads to a bunch of unconditional "heavy" imports unless this line (and others) is moved from the module-level to function-level.
There was a problem hiding this comment.
Commit just says Fix heavy imports but what is "fixed" since it was there before -- is there a test fail or what?
Indeed for dandi * --help we might want to avoid heavy imports (but then should be done at the imports of cmd_ files) -- I would not bother trying to delay such a generic import as numpy. Not yet sure about other imports
There was a problem hiding this comment.
I see - thanks! So let's move potential_fields into consts.py as dandi_layout_fields variable, import from there where needed. .consts is a lightweight import. And revert this imports fixing commit.
|
Let's release whenever this one is done. |
476f5af to
be00d45
Compare
|
Great! Thank you @jwodder ! |
Closes: #69
potential_fields