{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Configuration" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from eodag import EODataAccessGateway" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Add or update a provider" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "An [EODataAccessGateway](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway) object has a method [update_providers_config()](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway.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." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['astraea_eod',\n", " 'aws_eos',\n", " 'cop_ads',\n", " 'cop_cds',\n", " 'cop_dataspace',\n", " 'creodias',\n", " 'earth_search',\n", " 'earth_search_cog',\n", " 'earth_search_gcs',\n", " 'ecmwf',\n", " 'hydroweb_next',\n", " 'meteoblue',\n", " 'onda',\n", " 'peps',\n", " 'planetary_computer',\n", " 'sara',\n", " 'theia',\n", " 'usgs',\n", " 'usgs_satapi_aws',\n", " 'wekeo']" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dag = EODataAccessGateway()\n", "dag.available_providers()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "dag.update_providers_config(\"\"\"\n", " tamn:\n", " search:\n", " type: StacSearch\n", " api_endpoint: https://tamn.snapplanet.io/search\n", " products:\n", " S2_MSI_L1C:\n", " productType: S2\n", " GENERIC_PRODUCT_TYPE:\n", " productType: '{productType}'\n", " download:\n", " type: AwsDownload\n", " base_uri: https://tamn.snapplanet.io\n", " flatten_top_dirs: True\n", " auth:\n", " type: AwsAuth\n", " credentials:\n", " aws_access_key_id: PLEASE_CHANGE_ME\n", " aws_secret_access_key: PLEASE_CHANGE_ME\n", "\"\"\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"tamn\" in dag.available_providers()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Set a provider's priority" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The method [set_preferred_provider()](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway.set_preferred_provider) can be used to dynamically set the preferred provider/prioritary and the method [get_preferred_provider()](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway.get_preferred_provider) to return the current preferred/prioritary provider." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "('tamn', 2)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dag.set_preferred_provider(\"tamn\")\n", "dag.get_preferred_provider()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Logging" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Logging is activated with the [setup_logging()](../../api_reference/utils.rst#eodag.utils.logging.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](https://github.com/CS-SI/eodag/issues) if relevant." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The method accepts the following values for its `verbose` parameter:\n", "\n", "* `0`: no logging and no progress bar\n", "* `1`: no logging but progress bars displayed\n", "* `2`: log at the *INFO* level\n", "* `3`: log at the *DEBUG* level (even more information)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "from eodag import setup_logging\n", "setup_logging(verbose=3)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2023-10-17 15:35:20,898 eodag.config [DEBUG ] (tid=140145864171520) Loading configuration from /home/sylvain/workspace/eodag/eodag/resources/providers.yml\n", "2023-10-17 15:35:21,004 eodag.config [INFO ] (tid=140145864171520) Loading user configuration from: /home/sylvain/.config/eodag/eodag.yml\n", "2023-10-17 15:35:21,120 eodag.core [DEBUG ] (tid=140145864171520) Opening product types index in /home/sylvain/.config/eodag/.index\n", "2023-10-17 15:35:21,124 eodag.core [INFO ] (tid=140145864171520) Locations configuration loaded from /home/sylvain/.config/eodag/locations.yml\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "EODataAccessGateway()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" }, "nbsphinx": { "execute": "always" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }