-
Notifications
You must be signed in to change notification settings - Fork 28
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 RemoteDandiset.has_data_standard() convenience function #958
base: master
Are you sure you want to change the base?
Changes from 5 commits
9cd1ea1
27b0ce5
21261b1
74b3749
5bc0f54
2b008ef
fce70eb
285a2b9
b1aabee
203d4ad
12bd523
6eea7c4
d2073c2
fd5cdd5
4908500
a994e54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,8 @@ | |
|
||
T = TypeVar("T") | ||
|
||
DATA_STANDARD_MAP = dict(NWB="RRID:SCR_015242") | ||
|
||
|
||
class AssetType(Enum): | ||
""" | ||
|
@@ -1071,6 +1073,25 @@ def iter_upload_raw_asset( | |
self, metadata=asset_metadata, jobs=jobs, replacing=replace_asset | ||
) | ||
|
||
def has_data_standard(self, data_standard: str) -> bool: | ||
""" | ||
Returns True if the Dandiset contains one or more files of the indicated | ||
standard. Otherwise, returns False. | ||
""" | ||
if data_standard in DATA_STANDARD_MAP: | ||
rrid = DATA_STANDARD_MAP[data_standard] | ||
elif data_standard.startswith("RRID:"): | ||
rrid = data_standard | ||
else: | ||
raise ValueError( | ||
f"'data_standard' must be an RRID (of form 'RRID:XXX_NNNNNNN`) or one " | ||
bendichter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
f"of the following values: {DATA_STANDARD_MAP.keys()}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
bendichter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
assets_summary = self.get_raw_metadata()["assetsSummary"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jwodder and @bendichter WDYT - better be strict or robust? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be fine with changing this to throw a warning if assetsSummary is missing
bendichter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if "dataStandard" not in assets_summary: | ||
return False | ||
return any(x["identifier"] == rrid for x in assets_summary["dataStandard"]) | ||
|
||
|
||
class BaseRemoteAsset(ABC, APIBase): | ||
""" | ||
|
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.
The docstring should document the accepted data standards (or, at the very least, the RRID input format).