eodag 3.0.0b3__py3-none-any.whl → 3.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. eodag/api/core.py +347 -247
  2. eodag/api/product/_assets.py +44 -15
  3. eodag/api/product/_product.py +58 -47
  4. eodag/api/product/drivers/__init__.py +81 -4
  5. eodag/api/product/drivers/base.py +65 -4
  6. eodag/api/product/drivers/generic.py +65 -0
  7. eodag/api/product/drivers/sentinel1.py +97 -0
  8. eodag/api/product/drivers/sentinel2.py +95 -0
  9. eodag/api/product/metadata_mapping.py +129 -93
  10. eodag/api/search_result.py +28 -12
  11. eodag/cli.py +61 -24
  12. eodag/config.py +457 -167
  13. eodag/plugins/apis/base.py +10 -4
  14. eodag/plugins/apis/ecmwf.py +53 -23
  15. eodag/plugins/apis/usgs.py +41 -17
  16. eodag/plugins/authentication/aws_auth.py +30 -18
  17. eodag/plugins/authentication/base.py +14 -3
  18. eodag/plugins/authentication/generic.py +14 -3
  19. eodag/plugins/authentication/header.py +14 -6
  20. eodag/plugins/authentication/keycloak.py +44 -25
  21. eodag/plugins/authentication/oauth.py +18 -4
  22. eodag/plugins/authentication/openid_connect.py +192 -171
  23. eodag/plugins/authentication/qsauth.py +12 -4
  24. eodag/plugins/authentication/sas_auth.py +22 -5
  25. eodag/plugins/authentication/token.py +95 -17
  26. eodag/plugins/authentication/token_exchange.py +19 -19
  27. eodag/plugins/base.py +4 -4
  28. eodag/plugins/crunch/base.py +8 -5
  29. eodag/plugins/crunch/filter_date.py +9 -6
  30. eodag/plugins/crunch/filter_latest_intersect.py +9 -8
  31. eodag/plugins/crunch/filter_latest_tpl_name.py +8 -8
  32. eodag/plugins/crunch/filter_overlap.py +9 -11
  33. eodag/plugins/crunch/filter_property.py +10 -10
  34. eodag/plugins/download/aws.py +181 -105
  35. eodag/plugins/download/base.py +49 -67
  36. eodag/plugins/download/creodias_s3.py +40 -2
  37. eodag/plugins/download/http.py +247 -223
  38. eodag/plugins/download/s3rest.py +29 -28
  39. eodag/plugins/manager.py +176 -41
  40. eodag/plugins/search/__init__.py +6 -5
  41. eodag/plugins/search/base.py +123 -60
  42. eodag/plugins/search/build_search_result.py +1046 -355
  43. eodag/plugins/search/cop_marine.py +132 -39
  44. eodag/plugins/search/creodias_s3.py +19 -68
  45. eodag/plugins/search/csw.py +48 -8
  46. eodag/plugins/search/data_request_search.py +124 -23
  47. eodag/plugins/search/qssearch.py +531 -310
  48. eodag/plugins/search/stac_list_assets.py +85 -0
  49. eodag/plugins/search/static_stac_search.py +23 -24
  50. eodag/resources/ext_product_types.json +1 -1
  51. eodag/resources/product_types.yml +1295 -355
  52. eodag/resources/providers.yml +1819 -3010
  53. eodag/resources/stac.yml +3 -163
  54. eodag/resources/stac_api.yml +2 -2
  55. eodag/resources/user_conf_template.yml +115 -99
  56. eodag/rest/cache.py +2 -2
  57. eodag/rest/config.py +3 -4
  58. eodag/rest/constants.py +0 -1
  59. eodag/rest/core.py +157 -117
  60. eodag/rest/errors.py +181 -0
  61. eodag/rest/server.py +57 -339
  62. eodag/rest/stac.py +133 -581
  63. eodag/rest/types/collections_search.py +3 -3
  64. eodag/rest/types/eodag_search.py +41 -30
  65. eodag/rest/types/queryables.py +42 -32
  66. eodag/rest/types/stac_search.py +15 -16
  67. eodag/rest/utils/__init__.py +14 -21
  68. eodag/rest/utils/cql_evaluate.py +6 -6
  69. eodag/rest/utils/rfc3339.py +2 -2
  70. eodag/types/__init__.py +153 -32
  71. eodag/types/bbox.py +2 -2
  72. eodag/types/download_args.py +4 -4
  73. eodag/types/queryables.py +183 -73
  74. eodag/types/search_args.py +6 -6
  75. eodag/types/whoosh.py +127 -3
  76. eodag/utils/__init__.py +228 -106
  77. eodag/utils/exceptions.py +47 -26
  78. eodag/utils/import_system.py +2 -2
  79. eodag/utils/logging.py +37 -77
  80. eodag/utils/repr.py +65 -6
  81. eodag/utils/requests.py +13 -15
  82. eodag/utils/rest.py +2 -2
  83. eodag/utils/s3.py +231 -0
  84. eodag/utils/stac_reader.py +11 -11
  85. {eodag-3.0.0b3.dist-info → eodag-3.1.0.dist-info}/METADATA +81 -81
  86. eodag-3.1.0.dist-info/RECORD +113 -0
  87. {eodag-3.0.0b3.dist-info → eodag-3.1.0.dist-info}/WHEEL +1 -1
  88. {eodag-3.0.0b3.dist-info → eodag-3.1.0.dist-info}/entry_points.txt +5 -2
  89. eodag/resources/constraints/climate-dt.json +0 -13
  90. eodag/resources/constraints/extremes-dt.json +0 -8
  91. eodag/utils/constraints.py +0 -244
  92. eodag-3.0.0b3.dist-info/RECORD +0 -110
  93. {eodag-3.0.0b3.dist-info → eodag-3.1.0.dist-info}/LICENSE +0 -0
  94. {eodag-3.0.0b3.dist-info → eodag-3.1.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,85 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024, CS GROUP - France, https://www.csgroup.eu/
3
+ #
4
+ # This file is part of EODAG project
5
+ # https://www.github.com/CS-SI/EODAG
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ import logging
19
+ from types import MethodType
20
+ from typing import Any, List
21
+
22
+ from botocore.exceptions import BotoCoreError
23
+
24
+ from eodag.api.product import EOProduct # type: ignore
25
+ from eodag.api.search_result import RawSearchResult
26
+ from eodag.plugins.search.qssearch import StacSearch
27
+ from eodag.utils.exceptions import RequestError
28
+ from eodag.utils.s3 import update_assets_from_s3
29
+
30
+ logger = logging.getLogger("eodag.search.stac_list_assets")
31
+
32
+
33
+ def patched_register_downloader(self, downloader, authenticator):
34
+ """Add the download information to the product.
35
+
36
+ :param self: product to which information should be added
37
+ :param downloader: The download method that it can use
38
+ :class:`~eodag.plugins.download.base.Download` or
39
+ :class:`~eodag.plugins.api.base.Api`
40
+ :param authenticator: The authentication method needed to perform the download
41
+ :class:`~eodag.plugins.authentication.base.Authentication`
42
+ """
43
+ # register downloader
44
+ self.register_downloader_only(downloader, authenticator)
45
+ # and also update assets
46
+ try:
47
+ update_assets_from_s3(
48
+ self, authenticator, getattr(downloader.config, "s3_endpoint", None)
49
+ )
50
+ except BotoCoreError as e:
51
+ raise RequestError.from_error(e, "could not update assets") from e
52
+
53
+
54
+ class StacListAssets(StacSearch):
55
+ """``StacListAssets`` is an extension of :class:`~eodag.plugins.search.qssearch.StacSearch`.
56
+
57
+ It executes a Search on given STAC API endpoint and updates assets with content listed by the plugin using
58
+ ``downloadLink`` :class:`~eodag.api.product._product.EOProduct` property.
59
+
60
+ :param provider: provider name
61
+ :param config: It has the same Search plugin configuration as :class:`~eodag.plugins.search.qssearch.StacSearch` and
62
+ one additional parameter:
63
+
64
+ * :attr:`~eodag.config.PluginConfig.s3_endpoint` (``str``): s3 endpoint if not hosted on AWS
65
+ """
66
+
67
+ def __init__(self, provider, config):
68
+ super(StacSearch, self).__init__(provider, config)
69
+
70
+ def normalize_results(
71
+ self, results: RawSearchResult, **kwargs: Any
72
+ ) -> List[EOProduct]:
73
+ """Build EOProducts from provider results"""
74
+
75
+ products = super(StacSearch, self).normalize_results(results, **kwargs)
76
+
77
+ for product in products:
78
+ # backup original register_downloader to register_downloader_only
79
+ product.register_downloader_only = product.register_downloader
80
+ # patched register_downloader that will also update assets
81
+ product.register_downloader = MethodType(
82
+ patched_register_downloader, product
83
+ )
84
+
85
+ return products
@@ -18,7 +18,7 @@
18
18
  from __future__ import annotations
19
19
 
20
20
  import logging
21
- from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, cast
21
+ from typing import TYPE_CHECKING, Any, Optional
22
22
  from unittest import mock
23
23
 
24
24
  import geojson
@@ -44,23 +44,23 @@ logger = logging.getLogger("eodag.search.static_stac_search")
44
44
  class StaticStacSearch(StacSearch):
45
45
  """Static STAC Catalog search plugin
46
46
 
47
- The available configuration parameters for this plugin are
48
- (to be set in provider configuration):
47
+ This plugin first loads all STAC items found in the catalog, and converts them to
48
+ EOProducts using :class:`~eodag.plugins.search.qssearch.StacSearch`.
49
+ Then it uses crunchers to only keep products matching query parameters.
49
50
 
50
- - **api_endpoint**: (mandatory) path to the catalog (url or local system path)
51
+ The plugin inherits the configuration parameters from :class:`~eodag.plugins.search.qssearch.PostJsonSearch`
52
+ (via the :class:`~eodag.plugins.search.qssearch.StacSearch` inheritance) with the following particularities:
51
53
 
52
- - **max_connections**: (optional) Maximum number of connections for HTTP requests,
53
- defaut is 100.
54
+ :param provider: provider name
55
+ :param config: Search plugin configuration:
54
56
 
55
- - **timeout**: (mandatory) Timeout in seconds for each internal HTTP request,
56
- default is 5.
57
+ * :attr:`~eodag.config.PluginConfig.api_endpoint` (``str``) (**mandatory**): path to the catalog;
58
+ in contrast to the api_endpoint for other plugin types this can be a url or local system path.
59
+ * :attr:`~eodag.config.PluginConfig.max_connections` (``int``): Maximum number of concurrent
60
+ connections for HTTP requests; default: ``100``
61
+ * :attr:`~eodag.config.PluginConfig.timeout` (``int``): Timeout in seconds for each
62
+ internal HTTP request; default: ``5``
57
63
 
58
- This plugin first loads all STAC items found in the catalog, and converts them to
59
- EOProducts using StacSearch.
60
- Then it uses crunchers to only keep products matching query parameters.
61
-
62
- :param provider: An eodag providers configuration dictionary
63
- :param config: Path to the user configuration file
64
64
  """
65
65
 
66
66
  def __init__(self, provider: str, config: PluginConfig) -> None:
@@ -88,19 +88,18 @@ class StaticStacSearch(StacSearch):
88
88
  getattr(self.config, "discover_product_types", {}).get("fetch_url")
89
89
  == "{api_endpoint}/../collections"
90
90
  ):
91
- self.config.discover_product_types = {"fetch_url": None}
91
+ self.config.discover_product_types = {}
92
92
 
93
- def discover_product_types(self, **kwargs: Any) -> Optional[Dict[str, Any]]:
93
+ def discover_product_types(self, **kwargs: Any) -> Optional[dict[str, Any]]:
94
94
  """Fetch product types list from a static STAC Catalog provider using `discover_product_types` conf
95
95
 
96
96
  :returns: configuration dict containing fetched product types information
97
97
  """
98
- fetch_url = cast(
99
- str,
100
- self.config.discover_product_types["fetch_url"].format(
101
- **self.config.__dict__
102
- ),
103
- )
98
+ unformatted_fetch_url = self.config.discover_product_types.get("fetch_url")
99
+ if unformatted_fetch_url is None:
100
+ return None
101
+ fetch_url = unformatted_fetch_url.format(**self.config.__dict__)
102
+
104
103
  collections = fetch_stac_collections(
105
104
  fetch_url,
106
105
  collection=kwargs.get("q"),
@@ -128,7 +127,7 @@ class StaticStacSearch(StacSearch):
128
127
  self,
129
128
  prep: PreparedSearch = PreparedSearch(),
130
129
  **kwargs: Any,
131
- ) -> Tuple[List[EOProduct], Optional[int]]:
130
+ ) -> tuple[list[EOProduct], Optional[int]]:
132
131
  """Perform a search on a static STAC Catalog"""
133
132
 
134
133
  # only return 1 page if pagination is disabled
@@ -143,7 +142,7 @@ class StaticStacSearch(StacSearch):
143
142
  product_type = kwargs.get("productType", prep.product_type)
144
143
  # provider product type specific conf
145
144
  self.product_type_def_params = (
146
- self.get_product_type_def_params(product_type, **kwargs)
145
+ self.get_product_type_def_params(product_type, format_variables=kwargs)
147
146
  if product_type is not None
148
147
  else {}
149
148
  )