Skip to content

deprecate get_all_items_as_dict and get_all_items, add get_items_as_dicts #206

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 6 commits into from
Jun 1, 2022

Conversation

philvarner
Copy link
Collaborator

Related Issue(s): #187

Description:

  • deprecate get_all_items_as_dict and get_all_items, as these can retrieve the entire catalog without the user really knowing
  • add get_items_as_dicts to allow for retrieval of unmarshalled items

PR Checklist:

  • Code is formatted
  • Tests pass
  • Changes are added to the CHANGELOG

@philvarner philvarner marked this pull request as ready for review June 1, 2022 14:23
@codecov-commenter
Copy link

codecov-commenter commented Jun 1, 2022

Codecov Report

Merging #206 (0abeac6) into main (d2bce11) will decrease coverage by 0.21%.
The diff coverage is 77.27%.

@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
- Coverage   83.93%   83.72%   -0.22%     
==========================================
  Files           9        9              
  Lines         660      676      +16     
==========================================
+ Hits          554      566      +12     
- Misses        106      110       +4     
Impacted Files Coverage Δ
pystac_client/client.py 80.00% <0.00%> (ø)
pystac_client/item_search.py 91.93% <80.00%> (-0.93%) ⬇️
pystac_client/collection_client.py 76.74% <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 d2bce11...0abeac6. Read the comment docs.

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.

One top-level thought -- in Rust, the convention is to use iter_* for methods that return iterators. Here, this would mean that get_itemcollections would be renamed to iter_itemcollections (same with iter_items). Does that scan any better to you @philvarner? Just a thought as I was musing about our discussion on whether to include all in the method name.

Phil Varner and others added 2 commits June 1, 2022 10:55
Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
@philvarner philvarner requested a review from gadomski June 1, 2022 15:00
@philvarner
Copy link
Collaborator Author

One top-level thought -- in Rust, the convention is to use iter_* for methods that return iterators. Here, this would mean that get_itemcollections would be renamed to iter_itemcollections (same with iter_items). Does that scan any better to you @philvarner? Just a thought as I was musing about our discussion on whether to include all in the method name.

Few thoughts. I like that convention, but it's not one used in Python, so I'd avoid it. Though, I also hate methods prefixed with "get" since that's the old (entirely unncecessary) OO convention for accessor methods. I also don't like using get when the underlying method has side-effects and isn't just returning a value. I usually prefer just to name it like itemcollections() or items() or items_as_dicts(). Since they are causing network requests, I might prefix them with retrieve to indicate that there's a lot going on under the hood.

Co-authored-by: Pete Gadomski <pete.gadomski@gmail.com>
@gadomski
Copy link
Member

gadomski commented Jun 1, 2022

it's not one used in Python, so I'd avoid it

Yup fair.

Though, I also hate methods prefixed with "get" since that's the old (entirely unncecessary) OO convention for accessor methods. I also don't like using get when the underlying method has side-effects and isn't just returning a value.

Agreed.

Since they are causing network requests, I might prefix them with retrieve to indicate that there's a lot going on under the hood.

Agreed, though since they can be GET requests I guess get_ isn't a terrible prefix either :-). Full circle.

I don't think I feel strongly enough to think a change is necessary now, but happy to support a change too with others' input.

@philvarner
Copy link
Collaborator Author

philvarner commented Jun 1, 2022

Since they are causing network requests, I might prefix them with retrieve to indicate that there's a lot going on under the hood.

Agreed, though since they can be GET requests I guess get_ isn't a terrible prefix either :-). Full circle.

Well, we default to POST, so... 🤣

I don't think I feel strongly enough to think a change is necessary now, but happy to support a change too with others' input.

oh, so apparently the get prefix was added by in v0.2.0, from the changelog:

- `Search.item_collections()` renamed to `Search.get_item_collections()`
- `Search.item_collections()` renamed to `Search.get_items()`

(though i think the second msg should say Search.items() renamed

@matthewhanson any thoughts on this?

@philvarner philvarner requested a review from gadomski June 1, 2022 18:01
@philvarner philvarner merged commit 1c545d0 into main Jun 1, 2022
@philvarner philvarner deleted the pv/items-api branch June 1, 2022 19:57
weiji14 added a commit to weiji14/zen3geo that referenced this pull request Jun 20, 2023
weiji14 added a commit to weiji14/zen3geo that referenced this pull request Jun 20, 2023
* ✨ PySTACAPIItemLister to list STAC Items matching STAC API search

An iterable-style DataPipe to list STAC Items matching a STAC API search query! Calls pystac_client.ItemSearch.items() to yield pystac.Item instances. Included a doctest and a unit test that produces a list of STAC Items from a STAC API search that can be iterated over. Added a new section in the API docs too.

* 🚑 Fix typo on docs/api.md

Should be referencing `zen3geo.datapipes.pystac_client.PySTACAPIItemListerIterDataPipe`

* 📝 Use non-deprecated .items() in object-detection-boxes tutorial

PySTAC Client has renamed `ItemSearch.get_items()` to `ItemSearch.items()` in stac-utils/pystac-client#206, see also https://github.com/stac-utils/pystac-client/blob/v0.7.1/CHANGELOG.md#deprecated-1.

* 📝 Intersphinx link to pystac.STACObject in PySTACItemReader docs

Properly linking to https://pystac.readthedocs.io/en/1.0/api/pystac.html#pystac.STACObject in the docstring of PySTACItemReaderIterDataPipe.
Kirill888 pushed a commit to opendatacube/odc-stac that referenced this pull request Oct 7, 2024
The `.get_items()` method has been deprecated since stac-utils/pystac-client#206, use `.items()` instead.
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