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

table extension Column is not JSON serializable #872

Closed
martinfleis opened this issue Aug 10, 2022 · 1 comment · Fixed by #992
Closed

table extension Column is not JSON serializable #872

martinfleis opened this issue Aug 10, 2022 · 1 comment · Fixed by #992
Assignees
Labels
bug Things which are broken
Milestone

Comments

@martinfleis
Copy link
Contributor

When trying to use the table extension, I think I hit a bug (or I don't know how to use it). See the example:

from datetime import datetime

import pystac
from pystac.extensions.table import TableExtension, Column

catalog = pystac.Catalog(
    id="test_catalog",
    description="Test catalog",
    )

# create Item
item = pystac.Item(id='countries',
                 geometry=None,
                 bbox=[0, 1, 1, 2],
                 datetime=datetime.utcnow(),
                 href="./data.json",
                 properties={},
                 )

# add column metadata
tab_ext = TableExtension.ext(item, add_if_missing=True)
tab_ext.columns = [
    Column({"name": 'col_1', "type": 'str'}),
    Column({"name": 'col_2', "type": 'byte_array'}),
]

# add asset
item.add_asset(
    key='data',
    asset=pystac.Asset(
        title="Dataset root",
        href="./data.parquet",
        media_type="application/x-parquet"
    )
)

# add to collection
catalog.add_item(item)

catalog.normalize_hrefs("stac/")
catalog.save(catalog_type=pystac.CatalogType.SELF_CONTAINED)

The last line raises

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Untitled-1.ipynb Cell 4 in <cell line: 1>()
----> 1 catalog.save(catalog_type=pystac.CatalogType.SELF_CONTAINED)

...

TypeError: Object of type Column is not JSON serializable

I believe that this mirrors the issue #605 and change I made on this branch (main...martinfleis:pystac:table_serialize) fixes it. Happy to turn it into a PR if that is an actual bug and not my misunderstanding of the API.

@m-mohr
Copy link
Contributor

m-mohr commented Oct 17, 2022

I'm running into the same issue... I just don't use the TableExtension for now.

@gadomski gadomski added the bug Things which are broken label Jan 31, 2023
@gadomski gadomski added this to the 1.7 milestone Jan 31, 2023
@gadomski gadomski linked a pull request Feb 15, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things which are broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants