Skip to content

Return a Results class from search and query methods - #1298

Draft
mfisher87 wants to merge 41 commits into
mainfrom
results-object
Draft

Return a Results class from search and query methods#1298
mfisher87 wants to merge 41 commits into
mainfrom
results-object

Conversation

@mfisher87

@mfisher87 mfisher87 commented Apr 14, 2026

Copy link
Copy Markdown
Member

Description

Left to do:

  • Make the Results class iterable
  • Remove demo notebooks
  • Convert TODO comments to issues, clean up those comments
  • Add a unit test (no actual query) for to_gdf

"Ready for review" checklist

  • Place this Pull Request (PR) in draft until it is ready for review (see below)
  • Please review our Pull Request Guide
  • Mark "ready for review" after following instructions in the guide

Merge checklist

  • PR title is descriptive
  • PR body contains links to related and resolved issues (e.g. closes #1)
  • If needed, CHANGELOG.md updated
  • If needed, docs and/or README.md updated
  • If needed, unit tests added (unsure how? see below!)
  • All checks passing (tip: comment pre-commit.ci autofix if pre-commit is failing)
  • At least one approval

Need help? We welcome contributions at every experience level. You don't have to
write tests alone — open your PR and ask for help. It's also fine to let GitHub run tests
for you, via Continuous Integration (CI),
instead of running them locally. If anything fails and you're not sure why, just
mention @earthaccess-dev/maintainers in a comment and we'll work with you!


📚 Documentation preview 📚: https://earthaccess--1298.org.readthedocs.build/en/1298/

@github-actions

github-actions Bot commented Apr 14, 2026

Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on this branch for commit 75fadd9

I will automatically update this comment whenever this PR is modified

Binder 👈 Launch a binder notebook on this branch for commit eb932d5

Binder 👈 Launch a binder notebook on this branch for commit 78dcc49

Binder 👈 Launch a binder notebook on this branch for commit 6b3f8cc

Binder 👈 Launch a binder notebook on this branch for commit b4a7089

Binder 👈 Launch a binder notebook on this branch for commit 9c4e96c

Binder 👈 Launch a binder notebook on this branch for commit f3d3c2d

Binder 👈 Launch a binder notebook on this branch for commit 5e8e7ed

Binder 👈 Launch a binder notebook on this branch for commit b7b231f

Binder 👈 Launch a binder notebook on this branch for commit dff6214

Binder 👈 Launch a binder notebook on this branch for commit 2cde854

Binder 👈 Launch a binder notebook on this branch for commit 4f26870

Binder 👈 Launch a binder notebook on this branch for commit 34e3ca2

Binder 👈 Launch a binder notebook on this branch for commit 06b3544

Binder 👈 Launch a binder notebook on this branch for commit 52a142d

@mfisher87 mfisher87 changed the title Set mypy to lowest supported Python version Return a Results class from search and query methods Apr 15, 2026
mfisher87 and others added 7 commits April 15, 2026 11:02
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
mfisher87 and others added 7 commits April 15, 2026 12:16
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
mfisher87 and others added 11 commits April 21, 2026 13:42
I don't think this is an API we should commit to, we want to move
towards exposing a query object. The _query attribute is also private
right now because we want to think through what the query object itself
should look like before exposing as a public API.
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Trey Stafford <19692879+trey-stafford@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
trey-stafford and others added 3 commits April 28, 2026 11:21
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
Co-authored-by: Matt Fisher <3608264+mfisher87@users.noreply.github.com>
Co-authored-by: Jessica Scheick <11756442+JessicaS11@users.noreply.github.com>
Co-authored-by: Joseph H Kennedy <7882693+jhkennedy@users.noreply.github.com>
Co-authored-by: Julia Lober <72712672+julober@users.noreply.github.com>
I don't think this is an API we should commit to, we want to move
towards exposing a query object. The _query attribute is also private
right now because we want to think through what the query object itself
should look like before exposing as a public API.
@trey-stafford

Copy link
Copy Markdown
Contributor

Discussed during earthaccess community call today:

  • Subclassing list isn't a great idea. It provides opportunities for mutating the granule/collections in the list without updates to the corresponding query class.
  • We agreed that we should create a base Results class that GranuleResults and CollectionResults can subclass. Making two separate containers for the different results types allows for e.g., isinstance checks against specific collection types.
  • The results should be immutable
  • We would like to support lazy loading of results, but this is also in conflict with our desire to provide e.g., to_gdf, which would require materializing the results. Materializing the results on one iteration can "wipe out" the results, preventing subsequent iterations. How do we present results to users in a way that they can easily iterate over multiple times lazily? Should we support methods that force materialization?
  • We discussed how to_gdf should work. Ideally we don't have column names that are the full CMR representation, but instead show readable column names.

chuckwondo and others added 8 commits April 28, 2026 18:08
Co-authored-by: Matt Fisher <mfisher87@users.noreply.github.com>
Co-authored-by: Trey Stafford <trey-stafford@users.noreply.github.com>
Co-authored-by: Andy Barrett <andypbarrett@users.noreply.github.com>
Co-authored-by: Jessica Scheick <JessicaS11@users.noreply.github.com>
* Add init method for base class
* Replace `len` calls with `query.hits` in anticipation of generator approach
* Update preview/repr methods also in an anticipation of generator approach
@jhkennedy

jhkennedy commented May 12, 2026

Copy link
Copy Markdown
Contributor

Sorry I couldn't make it to this breakout discussion today -- got totally engrossed in the plugin discussion.

We would like to support lazy loading of results, but this is also in conflict with our desire to provide e.g., to_gdf, which would require materializing the results. Materializing the results on one iteration can "wipe out" the results, preventing subsequent iterations. How do we present results to users in a way that they can easily iterate over multiple times lazily? Should we support methods that force materialization?

We started this with the intention of moving towards a more object-oriented API (#1250 and described in the "what's next" section of demo_new.ipynb). So, I don't think the results class should be "lazy" or directly invoke any searches -- that should be the responsibility of the search client. The client can yield results lazily or return the full set of results, but each materialization should be different results objects. That does imply some additional methods (e.g., equality, combining, etc.) that come with the list class.

Note: we included the query parameters and options for provenance, but the expectation is that they'd be used by the client when doing searches. That part, I think, is a bit clunky still; we kicked around a full provenance type object but didn't settle on anything.

Subclassing list isn't a great idea. It provides opportunities for mutating the granule/collections in the list without updates to the corresponding query class.

This is addressed by my comments above. The benefit of sub-classing list is that it's the least breaking change for eathaccess (it already just returns a list).

The results should be immutable

I could be convinced of this, but I'm not sure it's necessary. Generally, I want user's to be able to use the results -- inculding combining multiple searches into one, etc. That all can be done with an imutable object, so I don't think they are contradictory, but I'd need to think more about the tradeoffs between the two.

We agreed that we should create a base Results class that GranuleResults and CollectionResults can subclass

makes sense to me.

We discussed how to_gdf should work. Ideally we don't have column names that are the full CMR representation, but instead show readable column names.

Yes, human-readable column names would be ideal, but maybe not necessary for a MVP.


@mfisher87 what do you think?

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.

4 participants