Download Plugins#
Download plugins must inherit the following class and implement download():
- class eodag.plugins.download.base.Download(provider, config)[source]#
Base Download Plugin.
A Download plugin has two download methods that it must implement:
download: download a singleEOProductdownload_all: download multiple products from aSearchResult
They must:
download data in the
output_dirfolder defined in the plugin’s configuration or passed through kwargsextract products from their archive (if relevant) if
extractis set toTrue(Trueby default)save a product in an archive/directory (in
output_dir) whose name must be the product’stitlepropertyupdate the product’s
locationattribute once its data is downloaded (and eventually after it’s extracted) to the product’s location given as a file URI (e.g.file:///tmp/product_folderon Linux orfile:///C:/Users/username/AppData/Local/Tempon Windows)save a record file in the directory
{output_dir}/.downloadedwhose name is built on the MD5 hash of the product’sproduct_typeandproperties['id']attributes (hashlib.md5((product.product_type+"-"+product.properties['id']).encode("utf-8")).hexdigest()) and whose content is the product’sremote_locationattribute itself.not try to download a product whose
locationattribute already points to an existing file/directorynot try to download a product if its record file exists as long as the expected product’s file/directory. If the record file only is found, it must be deleted (it certainly indicates that the download didn’t complete)
- Parameters:
provider (
str) – An eodag providers configuration dictionaryconfig (
PluginConfig) – Path to the user configuration file
- download(product, auth=None, progress_callback=None, wait=0.2, timeout=10, **kwargs)[source]#
Base download method. Not available, it must be defined for each plugin.
- Parameters:
product (
EOProduct) – The EO product to downloadauth (
AuthBase|S3ServiceResource|None, default:None) – (optional) authenticated objectprogress_callback (
ProgressCallback|None, default:None) – (optional) A progress callbackwait (
float, default:0.2) – (optional) If download fails, wait time in minutes between two download triestimeout (
float, default:10) – (optional) If download fails, maximum time in minutes before stop retrying to downloadkwargs (
Unpack[DownloadConf]) – output_dir (str), extract (bool), delete_archive (bool) and dl_url_params (dict) can be provided as additional kwargs and will override any other values defined in a configuration file or with environment variables.
- Return type:
- Returns:
The absolute path to the downloaded product in the local filesystem (e.g.
/tmp/product.zipon Linux orC:\\Users\\username\\AppData\\Local\\Temp\\product.zipon Windows)
- download_all(products, auth=None, downloaded_callback=None, progress_callback=None, wait=0.2, timeout=10, **kwargs)[source]#
Base download_all method.
This specific implementation uses the
eodag.plugins.download.base.Download.download()method implemented by the plugin to sequentially attempt to download products.- Parameters:
products (
SearchResult) – Products to downloadauth (
AuthBase|S3ServiceResource|None, default:None) – (optional) authenticated objectdownloaded_callback (
DownloadedCallback|None, default:None) – (optional) A method or a callable object which takes as parameter theproduct. You can use the base classDownloadedCallbackand override its__call__method. Will be called each time a product finishes downloadingprogress_callback (
ProgressCallback|None, default:None) – (optional) A progress callbackwait (
float, default:0.2) – (optional) If download fails, wait time in minutes between two download triestimeout (
float, default:10) – (optional) If download fails, maximum time in minutes before stop retrying to downloadkwargs (
Unpack[DownloadConf]) – output_dir (str), extract (bool), delete_archive (bool) and dl_url_params (dict) can be provided as additional kwargs and will override any other values defined in a configuration file or with environment variables.
- Return type:
- Returns:
List of absolute paths to the downloaded products in the local filesystem (e.g.
['/tmp/product.zip']on Linux or['C:\Users\username\AppData\Local\Temp\product.zip']on Windows)
This table lists all the download plugins currently available:
|
HTTPDownload plugin. |
|
Download on AWS using S3 protocol. |
|
Download on creodias s3 from their VMs (extension of |
Download methods call graph#
Here is a graph showing how download methods are called from API to plugin:
Progress bars#
While downloading, progress bars are generated using ProgressCallback. They are instantiated
and closed in EOProduct.download() which means that plugins do
not need to handle this part. Using download_all(), one progress bar will be
created and closed for each product.
The same progress bar will always be used to track both individual product download and extraction.
If a custom ProgressCallback is passed as argument of
download() or download_all(), it
will be used and duplicated to create bars to track download_all/download. The same bar will be used for all
products, and will not be closed by eodag.
Output |
|||
|---|---|---|---|
Default |
|
||
Passed |
|
||
Default |
Default |
|
|
Passed |
Passed |
|