-
Notifications
You must be signed in to change notification settings - Fork 53
Fix recursive search in Client.get_items #799
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few suggestions, but thank you so much for opening this PR! I think it'll be a real improvement.
|
||
Return: | ||
Iterator[Item]: Iterator of items whose parent is this | ||
catalog. | ||
""" | ||
if self.conforms_to(ConformanceClasses.ITEM_SEARCH): | ||
search = self.search(ids=ids) | ||
if recursive: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is maybe overly cautious but I would prefer this to be:
if recursive: | |
if recursive is not False: |
Just to ensure that in the (unlikely) case where someone is passing recursive=None
they get recursion to match the behavior before this PR.
except APIError: | ||
child_catalogs = [catalog for catalog, _, _ in self.walk()] | ||
search = self.search(ids=ids, collections=[self, *child_catalogs]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it would be pretty easy to do accidentally. I think I'd prefer to just let the error raise and make it a little harder to get every single item in planetary computer for instance.
for item in super().get_items( | ||
*ids, recursive=recursive is None or recursive | ||
): | ||
for item in super().get_items(*ids, recursive=recursive): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still want to account for the possibility of recursive being None here.
for item in super().get_items(*ids, recursive=recursive): | |
for item in super().get_items( | |
*ids, recursive=recursive is None or recursive | |
): |
Related Issue(s):
Client.get_items
has surprising recursive behaviour when using the/search
endpoint #798Description:
False
PR Checklist: