Skip to content

Commit

Permalink
Merge pull request dandi#21 from candleindark/remove-context
Browse files Browse the repository at this point in the history
fix: remove `"@context"` key from dandiset metadata
  • Loading branch information
candleindark authored Oct 30, 2024
2 parents a3845f9 + 8b35a5f commit 20bb892
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/dandisets_linkml_status_tools/cli/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def compile_dandiset_validation_report(
is published
:return: The compiled validation report
:raises KeyError: If the metadata of the given dandiset does not contain
a `"@context"` field
Note: This function should only be called in the context of a `DandiAPIClient`
context manager associated with the given dandiset.
"""
Expand All @@ -145,6 +148,20 @@ def compile_dandiset_validation_report(

raw_metadata = dandiset.get_raw_metadata()

if "@context" not in raw_metadata:
msg = (
f"There is no '@context' key in the metadata of "
f"dandiset {dandiset_id} @ version {dandiset_version}"
)
logger.critical(msg)
raise KeyError(msg)

# Remove the "@context" key from the metadata.
# This key is not part of the `Dandiset`
# or `PublishedDandiset` metadata model, so it shouldn't
# be validated as part of the model.
del raw_metadata["@context"]

# === Fetch dandiset version info ===
dandiset_version_info = dandiset.get_version(dandiset_version)
# Get dandiset version status
Expand Down

0 comments on commit 20bb892

Please sign in to comment.