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

Make table extension columns serializable #992

Merged
merged 2 commits into from
Feb 15, 2023

Conversation

jsignell
Copy link
Member

@jsignell jsignell commented Feb 15, 2023

Related Issue(s): #872

Description:
The table extension was not serializable because the list of columns was not getting serialized properly. This PR takes inspiration from the original recommendation (thanks @martinfleis!) but pushes the change further back into the mixin class.

Note:
The _set_property functionality seems pretty useful overall and I was wondering if it should be use more thoroughly or if there is a reason not to use it.

PR Checklist:

  • Code is formatted (run pre-commit run --all-files)
  • Tests pass (run scripts/test)
  • Documentation has been updated to reflect changes, if applicable
  • This PR maintains or improves overall codebase code coverage.
  • Changes are added to the CHANGELOG. See the docs for information about adding to the changelog.

@gadomski gadomski self-assigned this Feb 15, 2023
@gadomski gadomski added this to the 1.7 milestone Feb 15, 2023
@gadomski gadomski self-requested a review February 15, 2023 20:36
@gadomski gadomski removed their assignment Feb 15, 2023
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that the new functionality in the base class is useful; previous fixes (e.g.

@bands.setter
def bands(self, v: Optional[List[RasterBand]]) -> None:
self._set_property(
BANDS_PROP, map_opt(lambda bands: [b.to_dict() for b in bands], v)
)
) do the same thing, but at the extension level. IMO it'd be worth opening a new issue after this PR lands to convert any other extension-specific _set_property magic to use this new base-class functionality.

tests/extensions/test_table.py Outdated Show resolved Hide resolved
@gadomski gadomski linked an issue Feb 15, 2023 that may be closed by this pull request
@jsignell jsignell requested a review from gadomski February 15, 2023 21:19
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2023

Codecov Report

Base: 90.06% // Head: 90.13% // Increases project coverage by +0.06% 🎉

Coverage data is based on head (e306f1c) compared to base (7819728).
Patch coverage: 75.00% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #992      +/-   ##
==========================================
+ Coverage   90.06%   90.13%   +0.06%     
==========================================
  Files          47       47              
  Lines        6161     6164       +3     
  Branches      917      920       +3     
==========================================
+ Hits         5549     5556       +7     
+ Misses        431      426       -5     
- Partials      181      182       +1     
Impacted Files Coverage Δ
pystac/extensions/table.py 72.90% <66.66%> (+2.77%) ⬆️
pystac/extensions/base.py 93.65% <100.00%> (+0.20%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gadomski gadomski force-pushed the serialize-table-column branch from c7dde3c to e306f1c Compare February 15, 2023 22:07
@gadomski gadomski enabled auto-merge February 15, 2023 22:07
@gadomski gadomski added this pull request to the merge queue Feb 15, 2023
Merged via the queue into stac-utils:main with commit d6d82ee Feb 15, 2023
@jsignell jsignell deleted the serialize-table-column branch February 16, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

table extension Column is not JSON serializable
3 participants