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

Update docs to reflect that collection rel type can be for anything #1393

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

gadomski
Copy link
Member

@gadomski gadomski commented Aug 21, 2024

Related Issue(s):

Description:

We already have a collection rel type, so this PR is just a small docs tweak to reflect that collection links don't have to be only for items.

It's not required, but it would be nice to move {get|set}_collection to STACObject from Item:

pystac/pystac/item.py

Lines 260 to 295 in 28352e7

def set_collection(self, collection: Collection | None) -> Item:
"""Set the collection of this item.
This method will replace any existing Collection link and attribute for
this item.
Args:
collection : The collection to set as this
item's collection. If None, will clear the collection.
Returns:
Item: self
"""
self.remove_links(pystac.RelType.COLLECTION)
self.collection_id = None
if collection is not None:
self.add_link(Link.collection(collection))
self.collection_id = collection.id
return self
def get_collection(self) -> Collection | None:
"""Gets the collection of this item, if one exists.
Returns:
Collection or None: If this item belongs to a collection, returns
a reference to the collection. Otherwise returns None.
"""
collection_link = self.get_single_link(pystac.RelType.COLLECTION)
if collection_link is None:
return None
else:
return cast(
Collection, collection_link.resolve_stac_object(self.get_root()).target
)

However, as documented in #1392, set_collection returns self, which makes it a bit more awkward to return from the STACObject base class. My instinct is to hold off for moving {get|set}_collection, and just create a tracking issue in the v2.0 milestone so that we can solve #1392 and the method move at the same time.

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.
  • Create tracking issue for moving {get|set}_collection to STACObject: Move {set|get}_collection to STACObject #1399

@gadomski gadomski requested a review from jsignell August 21, 2024 19:29
@gadomski gadomski self-assigned this Aug 21, 2024
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.19%. Comparing base (e326b41) to head (6541a83).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1393   +/-   ##
=======================================
  Coverage   91.19%   91.19%           
=======================================
  Files          52       52           
  Lines        7238     7238           
  Branches     1019     1019           
=======================================
  Hits         6601     6601           
  Misses        457      457           
  Partials      180      180           

☔ 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.

lgtm

@gadomski gadomski added this pull request to the merge queue Sep 10, 2024
Merged via the queue into main with commit d4bed27 Sep 10, 2024
20 checks passed
@gadomski gadomski deleted the issues/1379-add-collection-as-rel-type branch September 10, 2024 20:36
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.

Add collection as a relation type
2 participants