Skip to content

Support recursive with get_itemsΒ #485

@jsignell

Description

@jsignell

I was running tests locally with dev install of pystac and pystac-client and I got a test failure on TestCollectionClient.test_get_item_with_item_search:

self = <tests.test_collection_client.TestCollectionClient object at 0x7f6accfde190>

    @pytest.mark.vcr
    def test_get_item_with_item_search(self) -> None:
        client = Client.open(STAC_URLS["PLANETARY-COMPUTER"])
        collection = client.get_collection("aster-l1t")
        assert collection is not None
        assert client._stac_io
        client._stac_io.set_conformance(
            [
                "https://api.stacspec.org/v1.0.0-rc.2/core",
                "https://api.stacspec.org/v1.0.0-rc.2/item-search",
            ]
        )
        item = collection.get_item("AST_L1T_00312272006020322_20150518201805")
        assert item
        assert item.id == "AST_L1T_00312272006020322_20150518201805"
    
        item = collection.get_item("for-sure-not-a-real-id")
        assert item is None
    
>       item = collection.get_item(
            "AST_L1T_00312272006020322_20150518201805", recursive=True
        )

tests/test_collection_client.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pystac_client/collection_client.py:171: in get_item
    item = super().get_item(id, recursive=True)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <CollectionClient id=aster-l1t>, id = 'AST_L1T_00312272006020322_20150518201805'
recursive = True

    def get_item(self, id: str, recursive: bool = False) -> Optional[Item]:
        """Returns an item with a given ID.
    
        Args:
            id : The ID of the item to find.
            recursive : If True, search this collection and all children for the
                item; otherwise, only search the items of this collection. Defaults
                to False.
    
        Return:
            Item or None: The item with the given ID, or None if not found.
        """
>       return next(self.get_items(id, recursive=recursive), None)
E       TypeError: CollectionClient.get_items() got an unexpected keyword argument 'recursive'

This is the result of an internal change in pystac: stac-utils/pystac#1075

Questions:

  1. Should we deprecate get_all_items and get_item like we did in pystac?
  2. Do we need to support old versions of pystac in new versions of pystac-client?
  3. Are there any upstream tests that install pystac off main? And if not would it be helpful to set some up?
  4. Should we revert the change in pystac and save it for 2.0?

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions