diff --git a/esmvalcore/_recipe/recipe.py b/esmvalcore/_recipe/recipe.py index 1613f6cf6d..d245880fa0 100644 --- a/esmvalcore/_recipe/recipe.py +++ b/esmvalcore/_recipe/recipe.py @@ -250,25 +250,42 @@ def _add_to_download_list(dataset): def _schedule_for_download(datasets): - """Schedule files for download and show the list of files in the log.""" + """Schedule files for download.""" for dataset in datasets: _add_to_download_list(dataset) for supplementary_ds in dataset.supplementaries: _add_to_download_list(supplementary_ds) - files = list(dataset.files) - for supplementary_ds in dataset.supplementaries: - files.extend(supplementary_ds.files) + +def _log_input_files(datasets: Iterable[Dataset]) -> None: + """Show list of files in log (including supplementaries).""" + for dataset in datasets: + # Only log supplementary variables if present + supplementary_files_str = "" + if dataset.supplementaries: + for sup_ds in dataset.supplementaries: + supplementary_files_str += ( + f"\nwith files for supplementary variable " + f"{sup_ds['short_name']}:\n{_get_files_str(sup_ds)}" + ) logger.debug( - "Using input files for variable %s of dataset %s:\n%s", + "Using input files for variable %s of dataset %s:\n%s%s", dataset.facets['short_name'], - dataset.facets['alias'].replace('_', ' '), - '\n'.join(f'{f} (will be downloaded)' if not f.exists() else str(f) - for f in files), + dataset.facets['alias'].replace('_', ' '), # type: ignore + _get_files_str(dataset), + supplementary_files_str ) +def _get_files_str(dataset: Dataset) -> str: + """Get nice string representation of all files of a dataset.""" + return '\n'.join( + f' {f}' if f.exists() # type: ignore + else f' {f} (will be downloaded)' for f in dataset.files + ) + + def _check_input_files(input_datasets: Iterable[Dataset]) -> set[str]: """Check that the required input files are available.""" missing = set() @@ -517,6 +534,7 @@ def _get_preprocessor_products( _set_version(dataset, input_datasets) USED_DATASETS.append(dataset) _schedule_for_download(input_datasets) + _log_input_files(input_datasets) logger.info("Found input files for %s", dataset.summary(shorten=True)) filename = _get_output_file(