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

build: refactor and new optional dependencies #1108

Merged
merged 7 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ And with ``conda`` from the `conda-forge channel <https://anaconda.org/conda-for

conda install -c conda-forge eodag

Please note that EODAG comes with a minimal set of dependencies. If you want more features, please install using one of
the `available extras <https://eodag.readthedocs.io/en/latest/getting_started_guide/install.html#optional-dependencies>`_.

Usage
=====

Expand Down
16 changes: 15 additions & 1 deletion docs/getting_started_guide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ Or with ``conda`` from the *conda-forge* channel:

conda install -c conda-forge eodag

Optional dependencies
^^^^^^^^^^^^^^^^^^^^^

Since ``v3.0``, EODAG comes with a minimal set of dependencies. If you want more features, please install using one of
the following extras:

* ``eodag[all]``, includes everything that would be needed to run EODAG and associated tutorials with all features
* ``eodag[all-providers]``, includes dependencies required to have all providers available
* ``eodag[aws]``, includes dependencies for plugins using Amazon S3
* ``eodag[csw]``, includes dependencies for plugins using CSW
* ``eodag[ecmwf]``, includes dependencies for :class:`~eodag.plugins.apis.ecmwf.EcmwfApi` (`ecmwf` provider)
* ``eodag[usgs]``, includes dependencies for :class:`~eodag.plugins.apis.usgs.UsgsApi` (`usgs` provider)
* ``eodag[server]``, includes dependencies for server-mode

.. _install_notebooks:

Run the notebooks locally
Expand All @@ -30,7 +44,7 @@ that can be run locally:

1. Install the extras dependencies it requires by executing this command (preferably in a virtual environment)::

python -m pip install eodag[tutorials]
python -m pip install "eodag[tutorials]"

2. Clone ``eodag`` 's repository with git::

Expand Down
1 change: 1 addition & 0 deletions docs/plugins_reference/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ This table lists all the authentication plugins currently available:
eodag.plugins.authentication.openid_connect.OIDCAuthorizationCodeFlowAuth
eodag.plugins.authentication.keycloak.KeycloakOIDCPasswordAuth
eodag.plugins.authentication.qsauth.HttpQueryStringAuth
eodag.plugins.authentication.sas_auth.SASAuth
1 change: 1 addition & 0 deletions docs/plugins_reference/download.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This table lists all the download plugins currently available:
eodag.plugins.download.http.HTTPDownload
eodag.plugins.download.aws.AwsDownload
eodag.plugins.download.s3rest.S3RestDownload
eodag.plugins.download.creodias_s3.CreodiasS3Download

---------------------------
Download methods call graph
Expand Down
3 changes: 2 additions & 1 deletion docs/plugins_reference/search.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ This table lists all the search plugins currently available:
:toctree: generated/

eodag.plugins.search.qssearch.QueryStringSearch
eodag.plugins.search.qssearch.AwsSearch
eodag.plugins.search.qssearch.ODataV4Search
eodag.plugins.search.qssearch.PostJsonSearch
eodag.plugins.search.qssearch.StacSearch
eodag.plugins.search.static_stac_search.StaticStacSearch
eodag.plugins.search.creodias_s3.CreodiasS3Search
eodag.plugins.search.build_search_result.BuildSearchResult
eodag.plugins.search.build_search_result.BuildPostSearchResult
eodag.plugins.search.data_request_search.DataRequestSearch
eodag.plugins.search.csw.CSWSearch
15 changes: 15 additions & 0 deletions eodag/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from eodag.api.product.metadata_mapping import mtd_cfg_as_conversion_and_querypath
from eodag.api.search_result import SearchResult
from eodag.config import (
PluginConfig,
SimpleYamlProxyConfig,
get_ext_product_types_conf,
load_default_config,
Expand Down Expand Up @@ -403,6 +404,20 @@ def _prune_providers_list(self) -> None:
for provider in list(self.providers_config.keys()):
conf = self.providers_config[provider]

# remove providers using skipped plugins
if [
v
for v in conf.__dict__.values()
if isinstance(v, PluginConfig)
and getattr(v, "type", None) in self._plugins_manager.skipped_plugins
]:
self.providers_config.pop(provider)
logger.debug(
f"{provider}: provider needing unavailable plugin has been removed"
)
continue

# check authentication
if hasattr(conf, "api") and getattr(conf.api, "need_auth", False):
credentials_exist = any(
[
Expand Down
10 changes: 10 additions & 0 deletions eodag/plugins/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class PluginManager:

product_type_to_provider_config_map: Dict[str, List[ProviderConfig]]

skipped_plugins: List[str]

def __init__(self, providers_config: Dict[str, ProviderConfig]) -> None:
self.skipped_plugins = []
self.providers_config = providers_config
# Load all the plugins. This will make all plugin classes of a particular
# type to be available in the base plugin class's 'plugins' attribute.
Expand All @@ -92,6 +95,13 @@ def __init__(self, providers_config: Dict[str, ProviderConfig]) -> None:
):
try:
entry_point.load()
except pkg_resources.DistributionNotFound:
logger.debug(
"%s plugin skipped, eodag[%s] or eodag[all] needed",
entry_point.name,
",".join(entry_point.extras),
)
self.skipped_plugins.append(entry_point.name)
except ImportError:
import traceback as tb

Expand Down
28 changes: 0 additions & 28 deletions eodag/plugins/search/qssearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,34 +1002,6 @@ def _request(
return response


class AwsSearch(QueryStringSearch):
"""A specialisation of RestoSearch that modifies the way the EOProducts are built
from the search results"""

def normalize_results(
self, results: List[Dict[str, Any]], **kwargs: Any
) -> List[EOProduct]:
"""Transform metadata from provider representation to eodag representation"""
normalized: List[EOProduct] = []
logger.debug("Adapting plugin results to eodag product representation")
for result in results:
ref = result["properties"]["title"].split("_")[5]
year = result["properties"]["completionDate"][0:4]
month = str(int(result["properties"]["completionDate"][5:7]))
day = str(int(result["properties"]["completionDate"][8:10]))

properties = QueryStringSearch.extract_properties[self.config.result_type](
result, self.get_metadata_mapping(kwargs.get("productType"))
)

properties["downloadLink"] = (
"s3://tiles/{ref[1]}{ref[2]}/{ref[3]}/{ref[4]}{ref[5]}/{year}/"
"{month}/{day}/0/"
).format(**locals())
normalized.append(EOProduct(self.provider, properties, **kwargs))
return normalized


class ODataV4Search(QueryStringSearch):
"""A specialisation of a QueryStringSearch that does a two step search to retrieve
all products metadata"""
Expand Down
6 changes: 6 additions & 0 deletions eodag/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""EODAG REST API"""
try:
from fastapi import __version__ # noqa: F401
except ImportError:
raise ImportError(
f"{__name__} not available, please install eodag[server] or eodag[all]"
)
96 changes: 54 additions & 42 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,64 @@ packages = find:
include_package_data = True
python_requires = >=3.6
install_requires =
annotated-types
click
requests
urllib3
python-dateutil
PyYAML
tqdm
shapely
pyshp
OWSLib >=0.27.1
geojson
jsonpath-ng < 1.6.0
lxml
orjson < 3.10.0;python_version>='3.12' and platform_system=='Windows'
orjson;python_version<'3.12' and platform_system!='Windows'
geojson
pydantic >= 2.1.0
pydantic_core
pyproj >= 2.1.0
usgs >= 0.3.1
pyshp
pystac >= 1.0.0b1
python-dateutil
PyYAML
requests
setuptools
shapely
stream-zip
tqdm
typing_extensions
urllib3
Whoosh

[options.extras_require]
all =
eodag[all-providers,csw,server,tutorials]
all-providers =
eodag[aws,ecmwf,usgs]
aws =
boto3
botocore
csw =
OWSLib >=0.27.1
ecmwf =
ecmwf-api-client
usgs =
usgs >= 0.3.1
server =
fastapi >= 0.93.0
pygeofilter
starlette
uvicorn
jsonpath-ng < 1.6.0
lxml
Whoosh
pystac >= 1.0.0b1
ecmwf-api-client
stream-zip
pydantic >= 2.1.0
pydantic_core
typing_extensions
annotated-types
setuptools
pygeofilter

[options.extras_require]
notebook = tqdm[notebook]
tutorials =
eodag[notebook]
eodag-cube >= 0.2.0
jupyter
ipyleaflet >= 0.10.0
ipywidgets
matplotlib
folium
imageio
rasterio
netcdf4

dev =
eodag[all-providers,csw,server]
pytest
pytest-cov
# pytest-html max version set and py requirement added
Expand All @@ -92,19 +116,8 @@ dev =
stdlib-list
boto3-stubs[essential]
types-lxml

notebook = tqdm[notebook]
tutorials =
eodag-cube >= 0.2.0
jupyter
ipyleaflet >= 0.10.0
ipywidgets
matplotlib
folium
imageio
rasterio
netcdf4
docs =
eodag[all]
sphinx
sphinx-book-theme
sphinx-copybutton
Expand All @@ -127,8 +140,8 @@ exclude =
console_scripts =
eodag = eodag.cli:eodag
eodag.plugins.api =
UsgsApi = eodag.plugins.apis.usgs:UsgsApi
EcmwfApi = eodag.plugins.apis.ecmwf:EcmwfApi
UsgsApi = eodag.plugins.apis.usgs:UsgsApi [usgs]
EcmwfApi = eodag.plugins.apis.ecmwf:EcmwfApi [ecmwf]
eodag.plugins.auth =
GenericAuth = eodag.plugins.authentication.generic:GenericAuth
HTTPHeaderAuth = eodag.plugins.authentication.header:HTTPHeaderAuth
Expand All @@ -146,22 +159,21 @@ eodag.plugins.crunch =
FilterProperty = eodag.plugins.crunch.filter_property:FilterProperty
FilterDate = eodag.plugins.crunch.filter_date:FilterDate
eodag.plugins.download =
AwsDownload = eodag.plugins.download.aws:AwsDownload
AwsDownload = eodag.plugins.download.aws:AwsDownload [aws]
HTTPDownload = eodag.plugins.download.http:HTTPDownload
S3RestDownload = eodag.plugins.download.s3rest:S3RestDownload
CreodiasS3Download = eodag.plugins.download.creodias_s3:CreodiasS3Download
CreodiasS3Download = eodag.plugins.download.creodias_s3:CreodiasS3Download [aws]
eodag.plugins.search =
CSWSearch = eodag.plugins.search.csw:CSWSearch
CSWSearch = eodag.plugins.search.csw:CSWSearch [csw]
QueryStringSearch = eodag.plugins.search.qssearch:QueryStringSearch
AwsSearch = eodag.plugins.search.qssearch:AwsSearch
ODataV4Search = eodag.plugins.search.qssearch:ODataV4Search
PostJsonSearch = eodag.plugins.search.qssearch:PostJsonSearch
StacSearch = eodag.plugins.search.qssearch:StacSearch
StaticStacSearch = eodag.plugins.search.static_stac_search:StaticStacSearch
BuildSearchResult = eodag.plugins.search.build_search_result:BuildSearchResult
BuildPostSearchResult = eodag.plugins.search.build_search_result:BuildPostSearchResult
DataRequestSearch = eodag.plugins.search.data_request_search:DataRequestSearch
CreodiasS3Search = eodag.plugins.search.creodias_s3:CreodiasS3Search
CreodiasS3Search = eodag.plugins.search.creodias_s3:CreodiasS3Search [aws]

[flake8]
ignore = E203, W503
Expand Down
Loading
Loading