Skip to content

Missing assets are deserialized as None #77

Closed
@gadomski

Description

@gadomski

If many items are converted to a table, and then converted back to dictionaries, any missing assets are converted to None (which is invalid STAC):

import pystac
import stac_geoparquet
from pystac import Item

item: Item = pystac.read_file(
    "https://raw.githubusercontent.com/radiantearth/stac-spec/v1.0.0/examples/simple-item.json"
)
reduced_item = item.full_copy()
del reduced_item.assets["thumbnail"]

table = stac_geoparquet.arrow.parse_stac_items_to_arrow([item, reduced_item])
items = list(stac_geoparquet.arrow.stac_table_to_items(table))
assert items[1]["assets"][
    "thumbnail"
], f"the thumbnail asset is {items[1]['assets']['thumbnail']}"

Output:

Traceback (most recent call last):
  File "check.py", line 13, in <module>
    assert items[1]["assets"][
           ^^^^^^^^^^^^^^^^^^^
AssertionError: the thumbnail asset is None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions