Hint

You can run this notebook in a live session with Binder.

Configuration#

[1]:
from eodag import EODataAccessGateway

Add or update a provider#

An EODataAccessGateway object has a method update_providers_config() that allows to either add a new provider or to update an existing one. The example below shows how to add a STAC provider.

[2]:
dag = EODataAccessGateway()
dag.available_providers()
[2]:
['astraea_eod',
 'cop_ads',
 'cop_cds',
 'cop_dataspace',
 'creodias',
 'earth_search',
 'earth_search_cog',
 'earth_search_gcs',
 'ecmwf',
 'onda',
 'peps',
 'planetary_computer',
 'sara',
 'theia',
 'usgs_satapi_aws']
[3]:
dag.update_providers_config("""
    tamn:
        search:
            type: StacSearch
            api_endpoint: https://tamn.snapplanet.io/search
        products:
            S2_MSI_L1C:
                productType: S2
            GENERIC_PRODUCT_TYPE:
                productType: '{productType}'
        download:
            type: AwsDownload
            base_uri: https://tamn.snapplanet.io
            flatten_top_dirs: True
        auth:
            type: AwsAuth
            credentials:
                aws_access_key_id: PLEASE_CHANGE_ME
                aws_secret_access_key: PLEASE_CHANGE_ME
""")
[4]:
"tamn" in dag.available_providers()
[4]:
True

Set a provider’s priority#

The method set_preferred_provider() can be used to dynamically set the preferred provider/prioritary and the method get_preferred_provider() to return the current preferred/prioritary provider.

[5]:
dag.set_preferred_provider("tamn")
dag.get_preferred_provider()
[5]:
('tamn', 2)

Logging#

Logging is activated with the setup_logging() method. It’s a useful way to see what eodag does under the hood (e.g. requesting the provider, adapting the response, etc.). It’s also useful to detect when things go wrong and create an issue on GitHub if relevant.

The method accepts the following values for its verbose parameter:

  • 0: no logging and no progress bar

  • 1: no logging but progress bars displayed

  • 2: log at the INFO level

  • 3: log at the DEBUG level (even more information)

[6]:
from eodag import setup_logging
setup_logging(verbose=3)
[7]:
EODataAccessGateway()
2024-03-28 09:13:10,078 eodag.config                     [DEBUG   ] (tid=140326064008256) Loading configuration from /home/docs/checkouts/readthedocs.org/user_builds/eodag/checkouts/latest/eodag/resources/providers.yml
2024-03-28 09:13:10,258 eodag.config                     [INFO    ] (tid=140326064008256) Loading user configuration from: /home/docs/.config/eodag/eodag.yml
2024-03-28 09:13:10,283 eodag.core                       [INFO    ] (tid=140326064008256) usgs: provider needing auth for search has been pruned because no crendentials could be found
2024-03-28 09:13:10,283 eodag.core                       [INFO    ] (tid=140326064008256) aws_eos: provider needing auth for search has been pruned because no crendentials could be found
2024-03-28 09:13:10,285 eodag.core                       [INFO    ] (tid=140326064008256) meteoblue: provider needing auth for search has been pruned because no crendentials could be found
2024-03-28 09:13:10,286 eodag.core                       [INFO    ] (tid=140326064008256) hydroweb_next: provider needing auth for search has been pruned because no crendentials could be found
2024-03-28 09:13:10,287 eodag.core                       [INFO    ] (tid=140326064008256) wekeo: provider needing auth for search has been pruned because no crendentials could be found
2024-03-28 09:13:10,288 eodag.core                       [INFO    ] (tid=140326064008256) wekeo_cmems: provider needing auth for search has been pruned because no crendentials could be found
2024-03-28 09:13:10,289 eodag.core                       [INFO    ] (tid=140326064008256) creodias_s3: provider needing auth for search has been pruned because no crendentials could be found
2024-03-28 09:13:10,291 eodag.core                       [DEBUG   ] (tid=140326064008256) Opening product types index in /home/docs/.config/eodag/.index
2024-03-28 09:13:10,297 eodag.core                       [INFO    ] (tid=140326064008256) Locations configuration loaded from /home/docs/.config/eodag/locations.yml
[7]:
<eodag.api.core.EODataAccessGateway at 0x7f9ffd870040>
[ ]: