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
fetch_all argument for dataset search methods #1553
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-1.9 #1553 +/- ##
===============================================
- Coverage 85.65% 85.62% -0.04%
===============================================
Files 140 140
Lines 15175 15279 +104
===============================================
+ Hits 12998 13082 +84
- Misses 2177 2197 +20 ☔ View full report in Codecov by Sentry. |
It would be really neat if this behaviour could be implemented via a decorator rather than multiple wrapper functions that are all but identical |
Yeah, I thought about that but I couldn't see how to do it without significantly complicating the contract between the abstract base class and the implementations. Definitely something that could be revisited though. |
I think we're better off without this. The added complexity both internally and in the API isn't worth it. The extra argument requires more explanation and make it less clear what the functions do. Python is full of iterator functions (especially We could include examples in the documentation of using |
|
Yeah, I can see that. The main use case as far as I can see is internal - for tests. It's much easier to check test results if they are instantiated into a list. The main justification is the deprecation/removal of Having said that, I don't mind dropping it - except that I built the other more useful PR on top of this one, so dropping this one would cause me some short term pain. |
I completely support removing If it's mostly for in tests, I even more think that we should be calling
Sorry! I do think short term pain over long term pain and support though. It's hopefully not too hard to remove from the next PR. |
Reason for this pull request
Add
fetch_all: bool = False
argument to all (non-deprecated) dataset search methods, as per EP-13.Proposed changes
fetch_all: bool
argument (defaulting toFalse
) added to all non-deprecated dataset search methods. When true, all search results are gathered and returned in a fully instantiated list. When false (the default), the method acts as a generator and yields a result at a time.Notes:
yield
statement in a method/function makes it act as a generator - you can't decide dynamically whether to yield or return from a function. Basic form looks like:search_by_products()
method has two layers of lazy evaluation (in generator mode, yields tuples containing a product and a nested generator that yields datasets. Thefetch_all=True
version fully instantiates both layers.docs/about/whats_new.rst
for all changes