Allow root to be set during to_dict #549
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofitem.from_dict
, the reading of the root link of the item can be skipped.PR Checklist:
pre-commit run --all-files
)scripts/test
)