Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit dd71f6d

Browse files
committed
Merge branch 'develop'
2 parents b9adc59 + 89c3633 commit dd71f6d

File tree

4 files changed

+65
-77
lines changed

4 files changed

+65
-77
lines changed

CHANGES.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Release history
22
---------------
33

4+
0.4.1 (2021-08-31)
5+
++++++++++++++++++
6+
7+
- LTA products handling with ``sentinelsat``
8+
`v1.1.0 <https://github.com/sentinelsat/sentinelsat/releases/tag/v1.1.0>`_ (#32)
9+
410
0.4.0 (2021-07-30)
511
++++++++++++++++++
612

@@ -9,9 +15,9 @@ Release history
915
- Custom progress_callback usage (#24)
1016
- Download procedure more consistent with EODAG (#17)
1117
- API endpoint update (#19)
12-
- Changed the type of products datetime properties from `datetime` objects to ISO 8601 `str` (#13)
18+
- Changed the type of products datetime properties from ``datetime`` objects to ISO 8601 ``str`` (#13)
1319
- Automatically extracting the downloaded archive by default (#11)
14-
- Removed duplicate `providers.yml` in repository root (thanks @remi-braun)
20+
- Removed duplicate ``providers.yml`` in repository root (thanks @remi-braun)
1521
- Various minor fixes and improvements (#12)(#14)(#15)(#16)(#22)(#23)(#25)
1622

1723
0.3.0 (2021-03-26)

eodag_sentinelsat/eodag_sentinelsat.py

Lines changed: 54 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import ast
2020
import logging as py_logging
2121
import shutil
22+
import types
2223
from datetime import date, datetime
2324

2425
from dateutil.parser import isoparse
@@ -40,7 +41,6 @@
4041
)
4142
from eodag.utils.notebook import NotebookWidgets
4243
from sentinelsat import SentinelAPI, ServerError
43-
from tenacity import retry, retry_if_not_result, stop_after_delay
4444

4545
logger = py_logging.getLogger("eodag.plugins.apis.sentinelsat")
4646

@@ -261,7 +261,8 @@ def download(
261261
:param dict kwargs: ``outputs_prefix`` (str), ``extract`` (bool) can be provided
262262
here and will override any other values defined in a
263263
configuration file or with environment variables.
264-
``checksum`` can be passed to ``sentinelsat.download_all`` directly
264+
``checksum``, ``max_attempts``, ``n_concurrent_dl``, ``fail_fast``
265+
and ``node_filter`` can be passed to ``sentinelsat.download_all`` directly
265266
which is used under the hood.
266267
:returns: The absolute path to the downloaded product in the local filesystem
267268
:rtype: str
@@ -307,9 +308,8 @@ def download_all(
307308
:param dict kwargs: ``outputs_prefix`` (str), ``extract`` (bool) can be provided
308309
here and will override any other values defined in a
309310
configuration file or with environment variables.
310-
``checksum``, ``max_attempts``, ``n_concurrent_dl`` and
311-
``lta_retry_delay`` can be passed to ``sentinelsat.download_all``
312-
directly.
311+
``checksum``, ``max_attempts``, ``n_concurrent_dl``, ``fail_fast``
312+
and ``node_filter`` can be passed to ``sentinelsat.download_all`` directly.
313313
:return: A collection of absolute paths to the downloaded products
314314
:rtype: list
315315
"""
@@ -338,80 +338,63 @@ def download_all(
338338
k: kwargs.pop(k)
339339
for k in list(kwargs)
340340
if k
341-
in ["checksum", "max_attempts", "n_concurrent_dl", "lta_retry_delay"]
341+
in [
342+
"max_attempts",
343+
"checksum",
344+
"n_concurrent_dl",
345+
"fail_fast",
346+
"nodefilter",
347+
]
342348
}
343-
# Download all products
344-
# Three dicts returned by sentinelsat.download_all, their key is the uuid:
345-
# 1. Product information from get_product_info() as well as the path on disk.
346-
# 2. Product information for products successfully triggered for retrieval
347-
# from the long term archive but not downloaded.
348-
# 3. Product information of products where either downloading or triggering failed
349349

350-
# another output for notebooks
351-
nb_info = NotebookWidgets()
352-
353-
def _are_products_missing(results):
354-
"""Check if some products have not been downloaded yet, for ``tenacity`` usage."""
355-
success, ordered, failed = results
356-
if len(ordered) > 0 or len(failed) > 0:
357-
return False
350+
if progress_callback is None:
351+
create_sentinelsat_pbar = ProgressCallback
352+
else:
353+
create_sentinelsat_pbar = progress_callback.copy
354+
355+
# Use eodag progress bars and avoid duplicates
356+
self.api.pbar_count = 0
357+
358+
def _tqdm(self, **kwargs):
359+
"""sentinelsat progressbar wrapper"""
360+
if self.api.pbar_count == 0 and progress_callback is not None:
361+
pbar = progress_callback
362+
for k in kwargs.keys():
363+
setattr(pbar, k, kwargs[k])
364+
pbar.refresh()
358365
else:
359-
return True
360-
361-
def _wait_callback(retry_state):
362-
"""Callback executed after each download attempt failure, for ``tenacity`` usage.
366+
pbar = create_sentinelsat_pbar(**kwargs)
367+
self.api.pbar_count += 1
368+
return pbar
363369

364-
:returns: wait time before next try (in seconds)
365-
"""
366-
retry_info = (
367-
"[Retry #%s] Waiting %ss until next download try (retry every %s' for %s')"
368-
% (retry_state.attempt_number, wait * 60, wait, timeout)
369-
)
370-
logger.info(retry_info)
371-
nb_info.display_html(retry_info)
370+
self.api.downloader._tqdm = types.MethodType(_tqdm, self.api.downloader)
372371

373-
return wait * 60
372+
# another output for notebooks
373+
nb_info = NotebookWidgets()
374374

375-
def _return_last_value(retry_state):
376-
"""Return the result of the last call attempt, for ``tenacity`` usage."""
377-
timeout_info = (
378-
"[Retry #%s] %s' timeout reached when trying to download"
379-
% (retry_state.attempt_number, timeout)
380-
)
381-
logger.info(timeout_info)
382-
nb_info.display_html(timeout_info)
383-
384-
success, ordered, failed = retry_state.outcome.result()
385-
if len(ordered) > 0:
386-
logger.warning(
387-
"%s products have been ordered but could not be downloaded: %s"
388-
% (len(ordered), ", ".join(ordered.keys()))
389-
)
390-
if len(failed) > 0:
391-
logger.warning(
392-
"%s products have failed and could not be downloaded: %s"
393-
% (len(failed), ", ".join(failed.keys()))
394-
)
395-
return success, ordered, failed
396-
397-
@retry(
398-
stop=stop_after_delay(timeout * 60),
399-
wait=_wait_callback,
400-
retry_error_callback=_return_last_value,
401-
retry=retry_if_not_result(_are_products_missing),
375+
retry_info = (
376+
"Will try downloading every %s' for %s' if product is not ONLINE"
377+
% (wait, timeout)
402378
)
403-
def _try_download_all(
404-
uuids_to_download, outputs_prefix, **sentinelsat_kwargs
405-
):
406-
"""Download attempts, for ``tenacity`` usage."""
407-
return self.api.download_all(
408-
uuids_to_download,
409-
directory_path=outputs_prefix,
410-
**sentinelsat_kwargs
411-
)
379+
logger.info(retry_info)
380+
logger.info(
381+
"Once ordered, OFFLINE/LTA product download retries may not be logged"
382+
)
383+
nb_info.display_html(retry_info)
384+
385+
self.api.lta_timeout = timeout * 60
412386

413-
success, _, _ = _try_download_all(
414-
uuids_to_download, outputs_prefix=outputs_prefix, **sentinelsat_kwargs
387+
# Download all products
388+
# Three dicts returned by sentinelsat.download_all, their key is the uuid:
389+
# 1. Product information from get_product_info() as well as the path on disk.
390+
# 2. Product information for products successfully triggered for retrieval
391+
# from the long term archive but not downloaded.
392+
# 3. Product information of products where either downloading or triggering failed
393+
success, _, _ = self.api.download_all(
394+
uuids_to_download,
395+
directory_path=outputs_prefix,
396+
lta_retry_delay=wait * 60,
397+
**sentinelsat_kwargs
415398
)
416399

417400
for pm in product_managers:

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
setup(
2828
name="eodag_sentinelsat",
29-
version="0.4.0",
29+
version="0.4.1",
3030
description="Sentinelsat plugin to EODAG (https://github.com/CS-SI/eodag)",
3131
long_description=readme,
3232
author="CS Systemes d'Information (CSSI)",
@@ -35,10 +35,9 @@
3535
license="GPLv3",
3636
packages=find_packages(),
3737
install_requires=[
38-
"sentinelsat",
38+
"sentinelsat >= 1.1.0",
3939
"eodag >= 2.3.0b1",
4040
"python-dateutil",
41-
"tenacity",
4241
],
4342
extras_require={
4443
"dev": [

tests/test_end_to_end.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_end_to_end_complete_scihub(dag, download_dir):
3434
"""Complete end-to-end test with SCIHUB for search, download and download_all"""
3535
# Search for products that are ONLINE and as small as possible
3636
today = datetime.date.today()
37-
month_span = datetime.timedelta(weeks=4)
37+
month_span = datetime.timedelta(weeks=2)
3838
search_results, _ = dag.search(
3939
productType="S2_MSI_L1C",
4040
start=(today - month_span).isoformat(),

0 commit comments

Comments
 (0)