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

Default layout strategy for catalogs #1295

Merged
merged 8 commits into from
Jan 10, 2024

Conversation

thomas-maschler
Copy link
Contributor

@thomas-maschler thomas-maschler commented Dec 23, 2023

Related Issue(s):

Description:

This PR enables setting a default layout strategy for a catalog. Users can either set the default layout strategy
when instantiating the catalog or defining a fall back strategy when subclassing Catalog.

Together with #1294, this PR is part of setting the foundation for enabling API transactions using pystac-client.

PR Checklist:

  • pre-commit hooks pass locally
  • 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.

@thomas-maschler thomas-maschler mentioned this pull request Dec 23, 2023
5 tasks
Copy link

codecov bot commented Dec 27, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (0407be2) 91.12% compared to head (c1facca) 91.15%.

Files Patch % Lines
pystac/catalog.py 88.23% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1295      +/-   ##
==========================================
+ Coverage   91.12%   91.15%   +0.03%     
==========================================
  Files          51       51              
  Lines        6994     7002       +8     
  Branches     1001     1002       +1     
==========================================
+ Hits         6373     6383      +10     
  Misses        444      444              
+ Partials      177      175       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jsignell jsignell left a comment

Choose a reason for hiding this comment

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

This looks really good too! The only issue is consolidating on an argument name.


catalog = Catalog(...,
href="/some/location/catalog.json",
layout_strategy=custom_strategy)
Copy link
Member

Choose a reason for hiding this comment

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

In other places we just call this kwarg strategy - did that feel too opaque?

@@ -167,6 +171,9 @@ class Catalog(STACObject):
a canonical format.
"""

_layout_strategy: HrefLayoutStrategy = BestPracticesLayoutStrategy()
Copy link
Member

Choose a reason for hiding this comment

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

So the idea is that pystac will be able to override this in the Client class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, correct. For example, the pystac_client.Client could set the fallback strategy to APILayoutStrategy

@thomas-maschler
Copy link
Contributor Author

Thanks for the review, I updated the argument name.

if root.strategy is not None:
return root.strategy
else:
return root._fallback_strategy
Copy link
Member

Choose a reason for hiding this comment

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

I think this rename is a lot clearer too 👍

@jsignell jsignell added this pull request to the merge queue Jan 10, 2024
Merged via the queue into stac-utils:main with commit 8dc1c65 Jan 10, 2024
@thomas-maschler thomas-maschler deleted the layout_strategy branch January 10, 2024 17:37
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.

2 participants