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
Change product finding to handle lists of products #1201
Conversation
8beba73
to
e5dc75c
Compare
Codecov Report
@@ Coverage Diff @@
## develop #1201 +/- ##
========================================
Coverage 93.79% 93.79%
========================================
Files 102 102
Lines 10403 10406 +3
========================================
+ Hits 9757 9760 +3
Misses 646 646
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests added / passed. NOT A GOOD TEST. ANY IDEAS ON A BETTER ONE?
Yeah, I'm wary of Mock tests. It's too easy for them to miss the actual useful parts to test (and be tied to internals, so break easily).
The integration_tests
folder contains fixtures that create real indexes to test/query against.
For example, something like this should reproduce it, using the fixtures inside (integration_tests/index/test_search.py
):
def test_query_dataset_multi_product(index: Index, ls5_dataset_w_children: Dataset):
# We have one ls5 level1 and its child nbar
dc = Datacube(index)
# Can we query a single product name?
datasets = dc.find_datasets(product='ls5_nbar_scene')
assert len(datasets) == 1
# Can we query multiple products?
datasets = dc.find_datasets(product=['ls5_nbar_scene', 'ls5_level1_scene'])
assert len(datasets) == 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Oh, and does this need an entry in whats_new? |
Wait, I meant to push another commit. Hold on. |
e5dc75c
to
d5a7417
Compare
I don't think it needs to go in what's new, @SpacemanPaul as it doesn't actually change anything... and it's an internal API fix. |
I think this is good enough fix for right now, but a "proper" fix might require handling the case where |
d5a7417
to
385656e
Compare
385656e
to
ab80f02
Compare
Can we also handle the case when multiple products are supplied as a tuple? datacube-core/datacube/index/_products.py Lines 333 to 334 in d268f49
will require fixing code above def _listify(v):
return [v] if isinstance(v, str) else [*v] |
I handled it differently. Thoughts @Kirill888 ? |
@alexgleith I don't see it being handled? I'm talking about supplying |
Ok, tests passing and added the tuple handling @Kirill888. Bump @SpacemanPaul for a re-review please? |
Reason for this pull request
Searching for datasets by including a list of products is possible, this makes it accessible using the normal query method.
Proposed changes
Use
index.products.search(product=product)
to find products. Tested with a string or a list of strings locally.Closes TypeError: unhashable type: 'list' when making fused wofs and fc cache odc-tools#366
Tests added / passed. NOT A GOOD TEST. ANY IDEAS ON A BETTER ONE?
Fully documented, including
docs/about/whats_new.rst
for all changes