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

Speed up get_child by first checking links that have id in them #1064

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

jsignell
Copy link
Member

@jsignell jsignell commented Mar 27, 2023

Related Issue(s):

Description:

This PR passes id along to the underlying method so the links can be sorted to prefer the ones that contain the id and reduce the number of calls.

I am not sure how to test this. I was originally thinking that I could check the number of calls on one of the methods on Link that happen withing get_stac_objects but this felt rather convoluted and I am going to have to put this down for a few days, so I figured I should just go ahead and open the PR with what I've got.

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.

@codecov-commenter
Copy link

codecov-commenter commented Mar 27, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 🎉

Comparison is base (3f6588d) 90.24% compared to head (8b831c0) 90.25%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1064      +/-   ##
==========================================
+ Coverage   90.24%   90.25%   +0.01%     
==========================================
  Files          47       47              
  Lines        6220     6228       +8     
  Branches      931      935       +4     
==========================================
+ Hits         5613     5621       +8     
  Misses        427      427              
  Partials      180      180              
Impacted Files Coverage Δ
pystac/catalog.py 92.87% <100.00%> (+0.09%) ⬆️
pystac/stac_object.py 92.61% <100.00%> (+0.07%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gadomski gadomski linked an issue Mar 30, 2023 that may be closed by this pull request
@gadomski gadomski added this to the 1.8 milestone Mar 30, 2023
@gadomski gadomski self-requested a review March 30, 2023 13:14
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how to test this.

We could assert that non-preferred links are unresolved? E.g.

_ = catalog.get_child(id="foo")
for link in catalog.links:
    if "foo" not in link.href:
        assert not foo.is_resolved()

pystac/stac_object.py Outdated Show resolved Hide resolved
pystac/stac_object.py Outdated Show resolved Hide resolved
tests/test_collection.py Outdated Show resolved Hide resolved
pystac/catalog.py Outdated Show resolved Hide resolved
pystac/catalog.py Outdated Show resolved Hide resolved
pystac/catalog.py Outdated Show resolved Hide resolved
pystac/catalog.py Outdated Show resolved Hide resolved
pystac/stac_object.py Outdated Show resolved Hide resolved
@jsignell jsignell marked this pull request as ready for review March 30, 2023 21:03
@jsignell jsignell requested a review from gadomski March 30, 2023 21:06
Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a CHANGELOG entry.

@jsignell jsignell requested a review from gadomski March 31, 2023 12:41
@gadomski gadomski enabled auto-merge March 31, 2023 12:49
@gadomski gadomski added this pull request to the merge queue Mar 31, 2023
Merged via the queue into stac-utils:main with commit bfd4351 Mar 31, 2023
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.

Efficiently fetching a specific child object
3 participants