6060 from collections .abc import Iterable , Sequence
6161
6262 from esmvalcore .config import Session
63+ from esmvalcore .io .protocol import DataElement
6364 from esmvalcore .typing import Facets
6465
6566logger = logging .getLogger (__name__ )
@@ -328,20 +329,12 @@ def _update_weighting_settings(
328329 _exclude_dataset (settings , facets , "weighting_landsea_fraction" )
329330
330331
331- def _add_to_download_list (dataset : Dataset ) -> None :
332- """Add the files of `dataset` to `DOWNLOAD_FILES`."""
333- for i , file in enumerate (dataset .files ):
334- if isinstance (file , esgf .ESGFFile ):
335- DOWNLOAD_FILES .add (file )
336- dataset .files [i ] = file .local_file (dataset .session ["download_dir" ])
337-
338-
339332def _schedule_for_download (datasets : Iterable [Dataset ]) -> None :
340333 """Schedule files for download."""
341334 for dataset in datasets :
342- _add_to_download_list (dataset )
335+ DOWNLOAD_FILES . update (dataset . files )
343336 for supplementary_ds in dataset .supplementaries :
344- _add_to_download_list (supplementary_ds )
337+ DOWNLOAD_FILES . update (supplementary_ds . files )
345338
346339
347340def _log_input_files (datasets : Iterable [Dataset ]) -> None :
@@ -367,12 +360,7 @@ def _log_input_files(datasets: Iterable[Dataset]) -> None:
367360
368361def _get_files_str (dataset : Dataset ) -> str :
369362 """Get nice string representation of all files of a dataset."""
370- return "\n " .join (
371- f" { f } "
372- if f .exists () # type: ignore
373- else f" { f } (will be downloaded)"
374- for f in dataset .files
375- )
363+ return "\n " .join (f" { f } " for f in dataset .files )
376364
377365
378366def _check_input_files (input_datasets : Iterable [Dataset ]) -> set [str ]:
@@ -916,7 +904,7 @@ def __init__(
916904 # Clear the global variable containing the set of files to download
917905 DOWNLOAD_FILES .clear ()
918906 USED_DATASETS .clear ()
919- self ._download_files : set [esgf . ESGFFile ] = set ()
907+ self ._download_files : set [DataElement ] = set ()
920908 self .session = session
921909 self .session ["write_ncl_interface" ] = self ._need_ncl (
922910 raw_recipe ["diagnostics" ],
@@ -1342,8 +1330,8 @@ def run(self) -> None:
13421330 filled_recipe = self .write_filled_recipe ()
13431331
13441332 # Download required data
1345- if self . session [ "search_esgf" ] != "never" :
1346- esgf . download ( self . _download_files , self . session [ "download_dir" ] )
1333+ for file in self . _download_files :
1334+ file . prepare ( )
13471335
13481336 self .tasks .run (max_parallel_tasks = self .session ["max_parallel_tasks" ])
13491337 logger .info (
0 commit comments