Skip to content

Refactor caching to utilize HREFs and parent IDs #214

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

Merged
merged 2 commits into from
Oct 27, 2020

Conversation

lossyrob
Copy link
Member

This PR refactors the caching strategy used by the resolved object cache to be based on an object's self HREF if available, and if not, to use a combination of the object's and its parents' IDs.

Before this change PySTAC required IDs to be unique within a catalog. This proved to be too restrictive and produced unexpected results in several situations.

Fixes #160
Fixes #92

@lossyrob lossyrob force-pushed the feature/rde/href-caching branch from 635df33 to 3ce9d5c Compare October 27, 2020 04:06
This commit modifies the caching strategy of PySTAC away from being
based simply on the ID of the STACObject. This can cause issues as
STAC objects do not necessarily have unique IDs, though best practices
say unique IDs are prefered.

This change modifies the cache to be based off of the self HREF first,
and if none is present, based off of not just the object's ID but the
ID of all of it's parents.

The caching is updated any time set_self_href is called on a STAC
object so the cache is kept up-to-date when new HREFs are set on
objects.

Fixes #92
@lossyrob lossyrob force-pushed the feature/rde/href-caching branch from 3ce9d5c to 7bbe8f7 Compare October 27, 2020 15:12
@codecov-io
Copy link

codecov-io commented Oct 27, 2020

Codecov Report

Merging #214 into develop will increase coverage by 0.23%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #214      +/-   ##
===========================================
+ Coverage    92.36%   92.59%   +0.23%     
===========================================
  Files           28       28              
  Lines         3351     3375      +24     
===========================================
+ Hits          3095     3125      +30     
+ Misses         256      250       -6     
Impacted Files Coverage Δ
pystac/cache.py 100.00% <100.00%> (+6.00%) ⬆️
pystac/link.py 97.36% <100.00%> (+0.09%) ⬆️
pystac/stac_object.py 95.04% <100.00%> (+0.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8219ee...7bbe8f7. Read the comment docs.

@lossyrob lossyrob merged commit 3b6d63e into develop Oct 27, 2020
@lossyrob lossyrob deleted the feature/rde/href-caching branch October 27, 2020 15:21
lossyrob added a commit that referenced this pull request Oct 28, 2020
This change was missed in #214. In that PR, the set_self_href logic
that existed on Collection was promoted to be the logic of all
set_self_hrefs on STACObjects. This makes this method unnecessary, and
causes duplicate calls to cache logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants