From b2daf232dfe94cb5ba970dada2cade04d19aa0e8 Mon Sep 17 00:00:00 2001 From: Markus Rye Foss <8709797+markusrf@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:36:41 +0100 Subject: [PATCH] fix: check that time series file exists (#716) --- .../yaml/domain/time_series_collections.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libecalc/presentation/yaml/domain/time_series_collections.py b/src/libecalc/presentation/yaml/domain/time_series_collections.py index 7cdf279dd9..244e0fe18b 100644 --- a/src/libecalc/presentation/yaml/domain/time_series_collections.py +++ b/src/libecalc/presentation/yaml/domain/time_series_collections.py @@ -21,7 +21,17 @@ def __init__(self, time_series: list[YamlTimeSeriesCollection], resources: dict[ time_series_collections: dict[str, TimeSeriesCollection] = {} errors: list[ModelValidationError] = [] for time_series_collection in time_series: - resource = resources[time_series_collection.file] + resource = resources.get(time_series_collection.file) + if resource is None: + errors.append( + ModelValidationError( + data=None, + location=Location(keys=[]), + message=f"There is no resource file '{time_series_collection.file}'", + file_context=None, + ) + ) + continue try: time_series_collections[time_series_collection.name] = TimeSeriesCollection.from_yaml( resource=resource,