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

Method remove_child returns a ValueError with client property object #50

Open
SethDocherty opened this issue Dec 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@SethDocherty
Copy link
Member

When using the pystac_client.Client object that's assigned to the client property in the Web3 class, I'm unable to use the remove_child() method inherited via the pystac.Catalog object.

The following method filters out collections from a STACObject

def filter_catalog(stac_object, collections_to_keep: List[str]) -> None:
    child_ids = [child.id for child in stac_object.get_children()]
    if not collections_to_keep:
        for col in child_ids:
            stac_object.remove_child(col)
    else:
        # Remove any collections that are not in the keep_collections list
        for col in child_ids:
            if col not in collections_to_keep:
                stac_object.remove_child(col)

Using the client property form the Web3 class:

test_client = client.Web3(stac_endpoint=<STAC URL>)
filter_catalog(test_client.client, [<COLLECTION ID>])

returns the following error:

  File "./.../.venv/lib/python/site-packages/pystac_client/collection_client.py", line 102, in set_root
    raise ValueError(
ValueError("`CollectionClient.root` must be set")

If I instead create a new STACObject instead of using the existing one, I do not get an error:

stac_obj = pystac.Catalog.from_file(tmp_client.stac_endpoint)
filter_catalog(test_client.client, [<COLLECTION ID>])

References:

stac-utils/pystac-client#706

@SethDocherty SethDocherty added the bug Something isn't working label Dec 2, 2024
@SethDocherty SethDocherty changed the title Method remove_child returns a ValueError when client property object Method remove_child returns a ValueError with client property object Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant