Skip to content
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

Search function will not return a SearchResult #503

Closed
iliion opened this issue Sep 12, 2022 · 6 comments
Closed

Search function will not return a SearchResult #503

iliion opened this issue Sep 12, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@iliion
Copy link

iliion commented Sep 12, 2022

I have configured an eodag instance having as a provider ONDA DIAS and also the respective username and password.
The objective is to search and download a product by its ID (The ID is S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916)
I have written the following simple code in order to achieve the above.

Code

...
    try:
        product: SearchResult= dag.search(id=product_id)
    except Exception as err:
        print(f"Failed to collect '{product_id}' product.", err)
...

The search function finds 1 result(s) on provider 'onda' but it doesnt return an SearchResult successfully.

Output

python core/core.py --provider onda  --product_id S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916
2022-09-12 19:13:05,923-15s eodag.config                     [INFO    ] (config           ) Loading user configuration from: /home/vagrant/Desktop/JRC_Repos/data-downloaders/eodag_download/eodag/core/config/eodag.yml
2022-09-12 19:13:06,356-15s eodag.core                       [DEBUG   ] (core             ) Opening product types index in /home/vagrant/.config/eodag/.index
2022-09-12 19:13:06,383-15s eodag.core                       [INFO    ] (core             ) Locations configuration loaded from /home/vagrant/Desktop/JRC_Repos/data-downloaders/eodag_download/eodag/core/config/locations.yml
2022-09-12 19:13:08,108-15s eodag.core                       [INFO    ] (core             ) Searching product with id 'S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916' on provider: onda
2022-09-12 19:13:08,108-15s eodag.core                       [DEBUG   ] (core             ) Using plugin class for search: ODataV4Search
2022-09-12 19:13:08,109-15s eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Getting genric provider product type definition parameters for None
2022-09-12 19:13:08,109-15s eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Getting genric provider product type definition parameters for None
2022-09-12 19:13:08,110-15s eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Building the query string that will be used for search
2022-09-12 19:13:08,110-15s eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Retrieving queryable metadata from metadata_mapping
2022-09-12 19:13:08,111-15s eodag.plugins.search.qssearch    [INFO    ] (qssearch         ) Sending search request: https://catalogue.onda-dias.eu/dias-catalogue/Products?$format=json&$search=%22S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916%22
2022-09-12 19:13:08,819-15s eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Sending metadata request: https://catalogue.onda-dias.eu/dias-catalogue/Products(de250e38-6e13-44cc-ba07-fc5411658ab7)/Metadata
2022-09-12 19:13:09,169-15s eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Adapting 1 plugin results to eodag product representation
2022-09-12 19:13:09,251-15s eodag.core                       [INFO    ] (core             ) Found 1 result(s) on provider 'onda'
Failed to collect 'S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916' product. 

Environment:

  • Python version: 3.6.9
  • EODAG version: 2.5.2

Additional context

The metadata request is successfull (in the browser)
https://catalogue.onda-dias.eu/dias-catalogue/Products(de250e38-6e13-44cc-ba07-fc5411658ab7)/Metadata

As well as the request for the product:
https://catalogue.onda-dias.eu/dias-catalogue/Products?$format=json&$search=%22S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916%22

@iliion iliion added the bug Something isn't working label Sep 12, 2022
@sbrunato
Copy link
Collaborator

sbrunato commented Sep 14, 2022

Hello @iliion ,

in your example, the error is not displayed, so I do not know what can raise the error....

However, I can suggest you to:

  • check that SearchResult is imported (from eodag import SearchResult), as it used in type annotation
  • even if your example won't fail, it stores a tuple (search_result, total_count) in the variable product. You'd better unpack search_result and total_count in two variables (search() method returns 2 variables, unlike search_all():
product_id = "S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916"
try:
    search_result, total_count = dag.search(id=product_id)
except Exception as err:
    print(f"Failed to collect '{product_id}' product.", err)
print(search_result)

2022-09-14 17:38:24,996 eodag.core                       [INFO    ] (core             ) Searching product with id 'S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916' on provider: onda
2022-09-14 17:38:25,005 eodag.plugins.search.qssearch    [INFO    ] (qssearch         ) Sending search request: https://catalogue.onda-dias.eu/dias-catalogue/Products?$format=json&$search=%22S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916%22
2022-09-14 17:38:26,002 eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Sending metadata request: https://catalogue.onda-dias.eu/dias-catalogue/Products(de250e38-6e13-44cc-ba07-fc5411658ab7)/Metadata
2022-09-14 17:38:26,476 eodag.plugins.search.qssearch    [DEBUG   ] (qssearch         ) Adapting 1 plugin results to eodag product representation
2022-09-14 17:38:26,587 eodag.core                       [INFO    ] (core             ) Found 1 result(s) on provider 'onda'
[EOProduct(id=S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916, provider=onda)]

I also removed type annotation as it is not supported for tuple unpacking

@iliion
Copy link
Author

iliion commented Sep 21, 2022

Hello @sbrunato
SearchResult was already imported correctly. --> from eodag import SearchResult

I copied your code and I get the same result as before. (It is also true that no error is raised. It just fails to collect the Product.)
Im quite puzzled.

For the record I already have another function implemented like this:
products: SearchResult = dag.search_all(**search_criteria, items_per_page=100)

The latter is successfull

@sbrunato
Copy link
Collaborator

can you try this please ?

import traceback

product_id = "S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916"
try:
    search_result, total_count = dag.search(id=product_id)
    print(search_result)
except Exception:
    print(traceback.format_exc())

Then post the output. Thanks

@iliion
Copy link
Author

iliion commented Sep 21, 2022

I get this error

2022-09-20 08:27:35,380-15s eodag.config                     [INFO    ] Loading user configuration from: /home/vagrant/Desktop/JRC_Repos/data-downloaders/eodag_download/eodag/core/config/eodag.yml
2022-09-20 08:27:35,890-15s eodag.core                       [INFO    ] Locations configuration loaded from /home/vagrant/Desktop/JRC_Repos/data-downloaders/eodag_download/eodag/core/config/locations.yml
2022-09-20 08:27:37,761-15s eodag.core                       [INFO    ] Searching product with id 'S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916' on provider: onda
2022-09-20 08:27:37,764-15s eodag.plugins.search.qssearch    [INFO    ] Sending search request: https://catalogue.onda-dias.eu/dias-catalogue/Products?$format=json&$search=%22S2B_MSIL1C_20170717T153909_N0205_R011_T19TCJ_20170717T154916%22
2022-09-20 08:27:45,543-15s eodag.core                       [INFO    ] Found 1 result(s) on provider 'onda'
Traceback (most recent call last):
  File "core/core.py", line 49, in search_by_id
    product, total_count = dag.search(id=product_id)
  File "/home/vagrant/.local/lib/python3.6/site-packages/eodag/api/core.py", line 591, in search
    return self._search_by_id(search_kwargs.pop("id"), **search_kwargs)
  File "/home/vagrant/.local/lib/python3.6/site-packages/eodag/api/core.py", line 853, in _search_by_id
    guesses = self.guess_product_type(**results[0].properties)
  File "/home/vagrant/.local/lib/python3.6/site-packages/eodag/api/core.py", line 467, in guess_product_type
    raise NoMatchingProductType()
eodag.utils.exceptions.NoMatchingProductType
  • Thanks for the traceback. Very useful

@sbrunato
Copy link
Collaborator

You're welcome.
Also, you should update eodag, as this issue has bee fixed in #380 (v2.4.0 release).
Or if you cannot update, specify the product type while searching: dag.search(id=product_id, productType="S2_MSI_L1C")

@iliion
Copy link
Author

iliion commented Sep 21, 2022

Ok that solved it. Thaks for your support.
Cheers! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants