Check if scenario file exists before attempting to load

Useful when running the `create_scenarios` rule the first time.
This commit is contained in:
Koen van Greevenbroek 2024-03-26 11:57:21 +01:00
parent 60fe95ddf7
commit 8b2a068b3a

View File

@ -43,10 +43,11 @@ def get_scenarios(run):
scenario_config = run.get("scenarios", {})
if run["name"] and scenario_config.get("enable"):
fn = Path(scenario_config["file"])
scenarios = yaml.safe_load(fn.read_text())
if run["name"] == "all":
run["name"] = list(scenarios.keys())
return scenarios
if fn.exists():
scenarios = yaml.safe_load(fn.read_text())
if run["name"] == "all":
run["name"] = list(scenarios.keys())
return scenarios
return {}