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

Allow root to be set during to_dict #549

Merged
merged 3 commits into from
Jul 12, 2021

Conversation

lossyrob
Copy link
Member

@lossyrob lossyrob commented Jul 9, 2021

Related Issue(s): #546

Description:
There was existing unused arguments for setting the root on from_dict for Catalogs, Collections and Items. This commit implements and tests that the root is set to the parameter if present, and adds the parameter to ItemCollection, which itself does not have a root but instead passes the root onto each of the Items parsed during the from_dict call.

This will allow pystac_client to pass in the client Catalog as the root of the Items returned during a search. This will drastically speed up the item.to_dict() calls as the logic in to_dict checks the root to see if the HREFs should be absolute or relative, which ends up reading the root object for each Item in the search results; instead if the root is set at the time of item.from_dict, the reading of the root link of the item can be skipped.

PR Checklist:

  • Code is formatted (run pre-commit run --all-files)
  • 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.

lossyrob added 3 commits July 9, 2021 17:52
There was existing unused arguments for seting the root on
to_dict. This commit implements and tests that the root is set to the
parameter if present, and adds the parameter to ItemCollection, which
itself does not have a root but instead passes the root onto each of
the Items parsed during the to_dict call.

Related to #546
@codecov-commenter
Copy link

Codecov Report

Merging #549 (e892910) into main (12eff70) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #549      +/-   ##
==========================================
+ Coverage   94.25%   94.26%   +0.01%     
==========================================
  Files          71       71              
  Lines       10263    10294      +31     
  Branches     1072     1076       +4     
==========================================
+ Hits         9673     9704      +31     
  Misses        422      422              
  Partials      168      168              
Impacted Files Coverage Δ
pystac/item_collection.py 93.75% <ø> (ø)
pystac/stac_object.py 90.86% <ø> (ø)
pystac/catalog.py 91.64% <100.00%> (+0.04%) ⬆️
pystac/collection.py 93.48% <100.00%> (+0.05%) ⬆️
pystac/item.py 93.22% <100.00%> (+0.03%) ⬆️
tests/test_catalog.py 99.15% <100.00%> (+<0.01%) ⬆️
tests/test_collection.py 100.00% <100.00%> (ø)
tests/test_item.py 100.00% <100.00%> (ø)
tests/test_item_collection.py 100.00% <100.00%> (ø)

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 12eff70...e892910. Read the comment docs.

Copy link
Contributor

@duckontheweb duckontheweb left a comment

Choose a reason for hiding this comment

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

Looks great. I had always kind of wondered why that root parameter was hanging around...

@duckontheweb duckontheweb merged commit b17aeb5 into main Jul 12, 2021
@duckontheweb duckontheweb deleted the feature/rde/itemcollect-todict branch July 16, 2021 00:50
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.

3 participants