Skip to content
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

fix key error #477

Merged
merged 3 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cubedash/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,10 @@ def undo_eo3_compatibility(doc):
In-place removal and undo-ing of the EO-compatibility fields added by ODC to EO3
documents on index.
"""
del doc["grid_spatial"]
del doc["extent"]
if "grid_spatial" in doc:
del doc["grid_spatial"]
if "extent" in doc:
del doc["extent"]

lineage = doc.get("lineage")
# If old EO1-style lineage was built (as it is on dataset.get(include_sources=True),
Expand Down
5 changes: 5 additions & 0 deletions integration_tests/test_eo3_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ def test_undo_eo3_doc_compatibility(eo3_index: Index):
), "Document does not match original after undoing compatibility fields."


def test_undo_eo3_compatibility_del_handling():
doc = {"extent": "a", "lineage": {}}
assert _utils.undo_eo3_compatibility(doc) is None


def with_parsed_datetimes(v: Dict, name=""):
"""
All date fields in eo3 metadata have names ending in 'datetime'. Return a doc
Expand Down