eodag 3.0.0b2__py3-none-any.whl → 3.0.1__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 (84) hide show
  1. eodag/__init__.py +6 -8
  2. eodag/api/core.py +295 -287
  3. eodag/api/product/__init__.py +10 -4
  4. eodag/api/product/_assets.py +2 -14
  5. eodag/api/product/_product.py +16 -30
  6. eodag/api/product/drivers/__init__.py +7 -2
  7. eodag/api/product/drivers/base.py +0 -3
  8. eodag/api/product/metadata_mapping.py +12 -31
  9. eodag/api/search_result.py +33 -12
  10. eodag/cli.py +35 -19
  11. eodag/config.py +455 -155
  12. eodag/plugins/apis/base.py +13 -7
  13. eodag/plugins/apis/ecmwf.py +16 -7
  14. eodag/plugins/apis/usgs.py +68 -16
  15. eodag/plugins/authentication/aws_auth.py +25 -7
  16. eodag/plugins/authentication/base.py +10 -1
  17. eodag/plugins/authentication/generic.py +14 -3
  18. eodag/plugins/authentication/header.py +12 -4
  19. eodag/plugins/authentication/keycloak.py +41 -22
  20. eodag/plugins/authentication/oauth.py +11 -1
  21. eodag/plugins/authentication/openid_connect.py +183 -167
  22. eodag/plugins/authentication/qsauth.py +12 -4
  23. eodag/plugins/authentication/sas_auth.py +19 -2
  24. eodag/plugins/authentication/token.py +59 -11
  25. eodag/plugins/authentication/token_exchange.py +19 -19
  26. eodag/plugins/crunch/base.py +7 -2
  27. eodag/plugins/crunch/filter_date.py +8 -11
  28. eodag/plugins/crunch/filter_latest_intersect.py +5 -7
  29. eodag/plugins/crunch/filter_latest_tpl_name.py +2 -5
  30. eodag/plugins/crunch/filter_overlap.py +9 -15
  31. eodag/plugins/crunch/filter_property.py +9 -14
  32. eodag/plugins/download/aws.py +84 -99
  33. eodag/plugins/download/base.py +36 -77
  34. eodag/plugins/download/creodias_s3.py +11 -2
  35. eodag/plugins/download/http.py +134 -109
  36. eodag/plugins/download/s3rest.py +37 -43
  37. eodag/plugins/manager.py +173 -41
  38. eodag/plugins/search/__init__.py +9 -9
  39. eodag/plugins/search/base.py +35 -35
  40. eodag/plugins/search/build_search_result.py +55 -64
  41. eodag/plugins/search/cop_marine.py +113 -32
  42. eodag/plugins/search/creodias_s3.py +20 -8
  43. eodag/plugins/search/csw.py +41 -1
  44. eodag/plugins/search/data_request_search.py +119 -14
  45. eodag/plugins/search/qssearch.py +619 -197
  46. eodag/plugins/search/static_stac_search.py +25 -23
  47. eodag/resources/ext_product_types.json +1 -1
  48. eodag/resources/product_types.yml +211 -56
  49. eodag/resources/providers.yml +1762 -1809
  50. eodag/resources/stac.yml +3 -163
  51. eodag/resources/user_conf_template.yml +134 -119
  52. eodag/rest/config.py +1 -2
  53. eodag/rest/constants.py +0 -1
  54. eodag/rest/core.py +70 -92
  55. eodag/rest/errors.py +181 -0
  56. eodag/rest/server.py +24 -330
  57. eodag/rest/stac.py +105 -630
  58. eodag/rest/types/eodag_search.py +17 -15
  59. eodag/rest/types/queryables.py +5 -14
  60. eodag/rest/types/stac_search.py +18 -13
  61. eodag/rest/utils/rfc3339.py +0 -1
  62. eodag/types/__init__.py +24 -6
  63. eodag/types/download_args.py +14 -5
  64. eodag/types/queryables.py +1 -2
  65. eodag/types/search_args.py +10 -11
  66. eodag/types/whoosh.py +0 -2
  67. eodag/utils/__init__.py +97 -136
  68. eodag/utils/constraints.py +0 -8
  69. eodag/utils/exceptions.py +23 -9
  70. eodag/utils/import_system.py +0 -4
  71. eodag/utils/logging.py +37 -80
  72. eodag/utils/notebook.py +4 -4
  73. eodag/utils/requests.py +13 -23
  74. eodag/utils/rest.py +0 -4
  75. eodag/utils/stac_reader.py +3 -15
  76. {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/METADATA +41 -24
  77. eodag-3.0.1.dist-info/RECORD +109 -0
  78. {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/WHEEL +1 -1
  79. {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/entry_points.txt +1 -0
  80. eodag/resources/constraints/climate-dt.json +0 -13
  81. eodag/resources/constraints/extremes-dt.json +0 -8
  82. eodag-3.0.0b2.dist-info/RECORD +0 -110
  83. {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/LICENSE +0 -0
  84. {eodag-3.0.0b2.dist-info → eodag-3.0.1.dist-info}/top_level.txt +0 -0
@@ -79,17 +79,17 @@ class Download(PluginTopic):
79
79
 
80
80
  They must:
81
81
 
82
- - download data in the ``outputs_prefix`` folder defined in the plugin's
82
+ - download data in the ``output_dir`` folder defined in the plugin's
83
83
  configuration or passed through kwargs
84
- - extract products from their archive (if relevant) if ``extract`` is set to True
85
- (True by default)
86
- - save a product in an archive/directory (in ``outputs_prefix``) whose name must be
84
+ - extract products from their archive (if relevant) if ``extract`` is set to ``True``
85
+ (``True`` by default)
86
+ - save a product in an archive/directory (in ``output_dir``) whose name must be
87
87
  the product's ``title`` property
88
88
  - update the product's ``location`` attribute once its data is downloaded (and
89
89
  eventually after it's extracted) to the product's location given as a file URI
90
- (e.g. 'file:///tmp/product_folder' on Linux or
91
- 'file:///C:/Users/username/AppData/LOcal/Temp' on Windows)
92
- - save a *record* file in the directory ``outputs_prefix/.downloaded`` whose name
90
+ (e.g. ``file:///tmp/product_folder`` on Linux or
91
+ ``file:///C:/Users/username/AppData/Local/Temp`` on Windows)
92
+ - save a *record* file in the directory ``{output_dir}/.downloaded`` whose name
93
93
  is built on the MD5 hash of the product's ``product_type`` and ``properties['id']``
94
94
  attributes (``hashlib.md5((product.product_type+"-"+product.properties['id']).encode("utf-8")).hexdigest()``)
95
95
  and whose content is the product's ``remote_location`` attribute itself.
@@ -100,9 +100,7 @@ class Download(PluginTopic):
100
100
  (it certainly indicates that the download didn't complete)
101
101
 
102
102
  :param provider: An eodag providers configuration dictionary
103
- :type provider: dict
104
103
  :param config: Path to the user configuration file
105
- :type config: str
106
104
  """
107
105
 
108
106
  def __init__(self, provider: str, config: PluginConfig) -> None:
@@ -122,25 +120,18 @@ class Download(PluginTopic):
122
120
  Base download method. Not available, it must be defined for each plugin.
123
121
 
124
122
  :param product: The EO product to download
125
- :type product: :class:`~eodag.api.product._product.EOProduct`
126
123
  :param auth: (optional) authenticated object
127
- :type auth: Optional[Union[AuthBase, Dict[str, str]]]
128
124
  :param progress_callback: (optional) A progress callback
129
- :type progress_callback: :class:`~eodag.utils.ProgressCallback`
130
125
  :param wait: (optional) If download fails, wait time in minutes between two download tries
131
- :type wait: int
132
126
  :param timeout: (optional) If download fails, maximum time in minutes before stop retrying
133
127
  to download
134
- :type timeout: int
135
- :param kwargs: `outputs_prefix` (str), `extract` (bool), `delete_archive` (bool)
128
+ :param kwargs: `output_dir` (str), `extract` (bool), `delete_archive` (bool)
136
129
  and `dl_url_params` (dict) can be provided as additional kwargs
137
130
  and will override any other values defined in a configuration
138
131
  file or with environment variables.
139
- :type kwargs: Union[str, bool, dict]
140
132
  :returns: The absolute path to the downloaded product in the local filesystem
141
- (e.g. '/tmp/product.zip' on Linux or
142
- 'C:\\Users\\username\\AppData\\Local\\Temp\\product.zip' on Windows)
143
- :rtype: str
133
+ (e.g. ``/tmp/product.zip`` on Linux or
134
+ ``C:\\Users\\username\\AppData\\Local\\Temp\\product.zip`` on Windows)
144
135
  """
145
136
  raise NotImplementedError(
146
137
  "A Download plugin must implement a method named download"
@@ -159,23 +150,16 @@ class Download(PluginTopic):
159
150
  Base _stream_download_dict method. Not available, it must be defined for each plugin.
160
151
 
161
152
  :param product: The EO product to download
162
- :type product: :class:`~eodag.api.product._product.EOProduct`
163
153
  :param auth: (optional) authenticated object
164
- :type auth: Optional[Union[AuthBase, Dict[str, str]]]
165
154
  :param progress_callback: (optional) A progress callback
166
- :type progress_callback: :class:`~eodag.utils.ProgressCallback`
167
155
  :param wait: (optional) If download fails, wait time in minutes between two download tries
168
- :type wait: int
169
156
  :param timeout: (optional) If download fails, maximum time in minutes before stop retrying
170
157
  to download
171
- :type timeout: int
172
- :param kwargs: `outputs_prefix` (str), `extract` (bool), `delete_archive` (bool)
173
- and `dl_url_params` (dict) can be provided as additional kwargs
158
+ :param kwargs: ``output_dir`` (str), ``extract`` (bool), ``delete_archive`` (bool)
159
+ and ``dl_url_params`` (dict) can be provided as additional kwargs
174
160
  and will override any other values defined in a configuration
175
161
  file or with environment variables.
176
- :type kwargs: Union[str, bool, dict]
177
- :returns: Dictionnary of :class:`~fastapi.responses.StreamingResponse` keyword-arguments
178
- :rtype: dict
162
+ :returns: Dictionary of :class:`~fastapi.responses.StreamingResponse` keyword-arguments
179
163
  """
180
164
  raise NotImplementedError(
181
165
  "Download streaming must be implemented using a method named _stream_download_dict"
@@ -190,11 +174,8 @@ class Download(PluginTopic):
190
174
  """Check if file has already been downloaded, and prepare product download
191
175
 
192
176
  :param product: The EO product to download
193
- :type product: :class:`~eodag.api.product._product.EOProduct`
194
177
  :param progress_callback: (optional) A progress callback
195
- :type progress_callback: :class:`~eodag.utils.ProgressCallback` or None
196
178
  :returns: fs_path, record_filename
197
- :rtype: Tuple[Optional[str], Optional[str]]
198
179
  """
199
180
  if product.location != product.remote_location:
200
181
  fs_path = uri_to_path(product.location)
@@ -216,18 +197,18 @@ class Download(PluginTopic):
216
197
  f"Download url: {url}",
217
198
  )
218
199
 
219
- outputs_prefix = (
220
- kwargs.pop("outputs_prefix", None)
221
- or getattr(self.config, "outputs_prefix", tempfile.gettempdir())
200
+ output_dir = (
201
+ kwargs.pop("output_dir", None)
202
+ or getattr(self.config, "output_dir", tempfile.gettempdir())
222
203
  or tempfile.gettempdir()
223
204
  )
224
- outputs_extension = kwargs.get("outputs_extension", None) or getattr(
225
- self.config, "outputs_extension", ".zip"
205
+ output_extension = kwargs.get("output_extension", None) or getattr(
206
+ self.config, "output_extension", ".zip"
226
207
  )
227
208
 
228
209
  # Strong asumption made here: all products downloaded will be zip files
229
210
  # If they are not, the '.zip' extension will be removed when they are downloaded and returned as is
230
- prefix = os.path.abspath(outputs_prefix)
211
+ prefix = os.path.abspath(output_dir)
231
212
  sanitized_title = sanitize(product.properties["title"])
232
213
  if sanitized_title == product.properties["title"]:
233
214
  collision_avoidance_suffix = ""
@@ -235,10 +216,10 @@ class Download(PluginTopic):
235
216
  collision_avoidance_suffix = "-" + sanitize(product.properties["id"])
236
217
  fs_path = os.path.join(
237
218
  prefix,
238
- f"{sanitize(product.properties['title'])}{collision_avoidance_suffix}{outputs_extension}",
219
+ f"{sanitize(product.properties['title'])}{collision_avoidance_suffix}{output_extension}",
239
220
  )
240
221
  fs_dir_path = (
241
- fs_path.replace(outputs_extension, "") if outputs_extension else fs_path
222
+ fs_path.replace(output_extension, "") if output_extension else fs_path
242
223
  )
243
224
  download_records_dir = os.path.join(prefix, ".downloaded")
244
225
  try:
@@ -292,9 +273,7 @@ class Download(PluginTopic):
292
273
  (``hashlib.md5((product.product_type+"-"+product.properties['id']).encode("utf-8")).hexdigest()``)
293
274
 
294
275
  :param product: The product to calculate the record hash
295
- :type product: :class:`~eodag.api.product._product.EOProduct`
296
276
  :returns: The MD5 hash
297
- :rtype: str
298
277
  """
299
278
  # In some unit tests, `product.product_type` is `None` and `product.properties["id"]` is `ìnt`
300
279
  product_hash = str(product.product_type) + "-" + str(product.properties["id"])
@@ -309,9 +288,7 @@ class Download(PluginTopic):
309
288
  WARNING: A strong assumption is made here: there is only one subdirectory per level
310
289
 
311
290
  :param product_path: The path to the extracted product
312
- :type product_path: str
313
291
  :returns: The path to the extracted product with the right depth
314
- :rtype: str
315
292
  """
316
293
  archive_depth = getattr(self.config, "archive_depth", 1)
317
294
  count = 1
@@ -329,11 +306,8 @@ class Download(PluginTopic):
329
306
  """Finalize the download process.
330
307
 
331
308
  :param fs_path: The path to the local zip archive downloaded or already present
332
- :type fs_path: str
333
309
  :param progress_callback: (optional) A progress callback
334
- :type progress_callback: :class:`~eodag.utils.ProgressCallback` or None
335
310
  :returns: The absolute path to the product
336
- :rtype: str
337
311
  """
338
312
  # progress bar init
339
313
  if progress_callback is None:
@@ -365,11 +339,11 @@ class Download(PluginTopic):
365
339
  if delete_archive is not None
366
340
  else getattr(self.config, "delete_archive", True)
367
341
  )
368
- outputs_extension = kwargs.pop("outputs_extension", ".zip")
342
+ output_extension = kwargs.pop("output_extension", ".zip")
369
343
 
370
344
  product_path = (
371
- fs_path[: fs_path.index(outputs_extension)]
372
- if outputs_extension in fs_path
345
+ fs_path[: fs_path.index(output_extension)]
346
+ if output_extension in fs_path
373
347
  else fs_path
374
348
  )
375
349
  product_path_exists = os.path.exists(product_path)
@@ -396,9 +370,7 @@ class Download(PluginTopic):
396
370
  )
397
371
  progress_callback(1, total=1)
398
372
  return product_path
399
- outputs_prefix = (
400
- kwargs.pop("outputs_prefix", None) or self.config.outputs_prefix
401
- )
373
+ output_dir = kwargs.pop("output_dir", None) or self.config.output_dir
402
374
 
403
375
  if not os.path.exists(product_path):
404
376
  logger.info("Extraction activated")
@@ -407,9 +379,9 @@ class Download(PluginTopic):
407
379
  )
408
380
  progress_callback.refresh()
409
381
 
410
- outputs_dir = os.path.join(outputs_prefix, product_path)
382
+ product_dir = os.path.join(output_dir, product_path)
411
383
  tmp_dir = tempfile.TemporaryDirectory()
412
- extraction_dir = os.path.join(tmp_dir.name, os.path.basename(outputs_dir))
384
+ extraction_dir = os.path.join(tmp_dir.name, os.path.basename(product_dir))
413
385
 
414
386
  if fs_path.endswith(".zip"):
415
387
  with zipfile.ZipFile(fs_path, "r") as zfile:
@@ -427,10 +399,10 @@ class Download(PluginTopic):
427
399
  # then, we create a directory in which we place this file
428
400
  product_extraction_path = self._resolve_archive_depth(extraction_dir)
429
401
  if os.path.isfile(product_extraction_path) and not os.path.isdir(
430
- outputs_dir
402
+ product_dir
431
403
  ):
432
- os.makedirs(outputs_dir)
433
- shutil.move(product_extraction_path, outputs_dir)
404
+ os.makedirs(product_dir)
405
+ shutil.move(product_extraction_path, product_dir)
434
406
 
435
407
  elif fs_path.endswith(".tar") or fs_path.endswith(".tar.gz"):
436
408
  with tarfile.open(fs_path, "r") as zfile:
@@ -441,10 +413,10 @@ class Download(PluginTopic):
441
413
  # then, we create a directory in which we place this file
442
414
  product_extraction_path = self._resolve_archive_depth(extraction_dir)
443
415
  if os.path.isfile(product_extraction_path) and not os.path.isdir(
444
- outputs_dir
416
+ product_dir
445
417
  ):
446
- os.makedirs(outputs_dir)
447
- shutil.move(product_extraction_path, outputs_dir)
418
+ os.makedirs(product_dir)
419
+ shutil.move(product_extraction_path, product_dir)
448
420
  else:
449
421
  progress_callback(1, total=1)
450
422
 
@@ -483,32 +455,23 @@ class Download(PluginTopic):
483
455
  implemented by the plugin to **sequentially** attempt to download products.
484
456
 
485
457
  :param products: Products to download
486
- :type products: :class:`~eodag.api.search_result.SearchResult`
487
458
  :param auth: (optional) authenticated object
488
- :type auth: Optional[Union[AuthBase, Dict[str, str]]]
489
459
  :param downloaded_callback: (optional) A method or a callable object which takes
490
460
  as parameter the ``product``. You can use the base class
491
- :class:`~eodag.api.product.DownloadedCallback` and override
461
+ :class:`~eodag.utils.DownloadedCallback` and override
492
462
  its ``__call__`` method. Will be called each time a product
493
463
  finishes downloading
494
- :type downloaded_callback: Callable[[:class:`~eodag.api.product._product.EOProduct`], None]
495
- or None
496
464
  :param progress_callback: (optional) A progress callback
497
- :type progress_callback: :class:`~eodag.utils.ProgressCallback`
498
465
  :param wait: (optional) If download fails, wait time in minutes between two download tries
499
- :type wait: int
500
466
  :param timeout: (optional) If download fails, maximum time in minutes before stop retrying
501
467
  to download
502
- :type timeout: int
503
- :param kwargs: `outputs_prefix` (str), `extract` (bool), `delete_archive` (bool)
468
+ :param kwargs: `output_dir` (str), `extract` (bool), `delete_archive` (bool)
504
469
  and `dl_url_params` (dict) can be provided as additional kwargs
505
470
  and will override any other values defined in a configuration
506
471
  file or with environment variables.
507
- :type kwargs: Union[str, bool, dict]
508
472
  :returns: List of absolute paths to the downloaded products in the local
509
473
  filesystem (e.g. ``['/tmp/product.zip']`` on Linux or
510
474
  ``['C:\\Users\\username\\AppData\\Local\\Temp\\product.zip']`` on Windows)
511
- :rtype: list
512
475
  """
513
476
  # Products are going to be removed one by one from this sequence once
514
477
  # downloaded.
@@ -632,14 +595,10 @@ class Download(PluginTopic):
632
595
  exception is thrown until `timeout` minutes.
633
596
 
634
597
  :param product: The EO product to download
635
- :type product: :class:`~eodag.api.product._product.EOProduct`
636
598
  :param wait: If download fails, wait time in minutes between two download tries
637
- :type wait: int
638
599
  :param timeout: If download fails, maximum time in minutes before stop retrying
639
600
  to download
640
- :type timeout: int
641
601
  :returns: decorator
642
- :rtype: Callable[[Callable[..., T]], Callable[..., T]]
643
602
  """
644
603
 
645
604
  def decorator(download: Callable[..., T]) -> Callable[..., T]:
@@ -670,7 +629,7 @@ class Download(PluginTopic):
670
629
  not_available_info = str(e)
671
630
 
672
631
  if datetime_now >= product.next_try and datetime_now < stop_time:
673
- wait_seconds = (
632
+ wait_seconds: Union[float, int] = (
674
633
  datetime_now - product.next_try + timedelta(minutes=wait)
675
634
  ).seconds
676
635
  retry_count += 1
@@ -25,7 +25,16 @@ from eodag.utils.exceptions import MisconfiguredError
25
25
 
26
26
  class CreodiasS3Download(AwsDownload):
27
27
  """
28
- Download on creodias s3 from their VMs
28
+ Download on creodias s3 from their VMs (extension of :class:`~eodag.plugins.download.aws.AwsDownload`)
29
+
30
+ :param provider: provider name
31
+ :param config: Download plugin configuration:
32
+
33
+ * :attr:`~eodag.config.PluginConfig.type` (``str``) (**mandatory**): CreodiasS3Download
34
+ * :attr:`~eodag.config.PluginConfig.base_uri` (``str``) (**mandatory**): s3 endpoint url
35
+ * :attr:`~eodag.config.PluginConfig.s3_bucket` (``str``) (**mandatory**): bucket where the products can be found
36
+ * :attr:`~eodag.config.PluginConfig.ssl_verify` (``bool``): if the ssl certificates should be
37
+ verified in requests; default: ``True``
29
38
  """
30
39
 
31
40
  def _get_authenticated_objects_unsigned(self, bucket_name, prefix, auth_dict):
@@ -50,7 +59,7 @@ class CreodiasS3Download(AwsDownload):
50
59
 
51
60
  s3_session = boto3.session.Session(**auth_dict)
52
61
  s3_resource = s3_session.resource(
53
- "s3", endpoint_url=getattr(self.config, "base_uri", None)
62
+ "s3", endpoint_url=getattr(self.config, "s3_endpoint", None)
54
63
  )
55
64
  objects = s3_resource.Bucket(bucket_name).objects.filter()
56
65
  list(objects.filter(Prefix=prefix).limit(1))