Skip to content

Missing link from Asset to owner Item after signing STAC Item #25

Closed

Description

Signed STAC Item returned from pc.sign is missing links from Assets back to Item.

assert signed_item.assets[name].owner is item

In the example below second assert fails.

from pystac import Item
import planetary_computer as pc

item = Item.from_file("S2B_MSIL2A_20190629T212529_R043_T06VVN_20201006T080531.json")
assert item.assets["B01"].owner is item
signed_item = pc.sign(item)
assert signed_item.assets["B01"].owner is signed_item

Activity

  1. Kirill888 commented on Sep 2, 2021

    @Kirill888
    ContributorAuthor

    When making a clone of an Asset object .owner property is reset to None. Since Item is fully cloned when signing there is no need to then also clone all the assets. I would suggest adding in place signing option to pc.sign(asset) that skips cloning of an asset and just modifies passed in object in place, then use that option from pc.sign(item) overload.

    def sign_asset(asset: Asset) -> Asset:
    """Sign a PySTAC asset
    Args:
    asset (Asset): The Asset to sign
    Returns:
    Asset: A new copy of the Asset where the HREF is replaced with a
    signed version.
    """
    signed_asset = asset.clone()

  2. TomAugspurger commented on Sep 2, 2021

    @TomAugspurger

    Adding an option to skip cloning / operate in place makes sense to me. API-wise, I think we call it either copy=True/False or clone=True/False (the default being to clone). I guess pystac uses preserve_dict=True, but that's in the context of dict -> pystac object.

  3. TomAugspurger commented on Sep 7, 2021

    @TomAugspurger

    Kirill Kouzoubov (@Kirill888) do you need a release with #25 in it, or do you have any additional testing / changes before you'd want a release?

  4. Kirill888 commented on Sep 7, 2021

    @Kirill888
    ContributorAuthor

    Thanks Tom Augspurger (@TomAugspurger), I'm not in a hurry for these fixes to be released as I ended up signing at url level as that fits for my use case better anyway, but then I'm also not planning any more additions to this, so if you want this fix released sooner that would be great too.

  5. TomAugspurger commented on Sep 9, 2021

    @TomAugspurger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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