From 74185560e0570cb15662fca8784adb8b3fa93aa2 Mon Sep 17 00:00:00 2001
From: Philipp Glaum
Date: Wed, 10 Apr 2024 12:04:45 +0200
Subject: [PATCH 1/3] initial implementation
---
Snakefile | 8 +++++++-
config/config.default.yaml | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/Snakefile b/Snakefile
index ba93a869..ed60c0f5 100644
--- a/Snakefile
+++ b/Snakefile
@@ -22,7 +22,13 @@ configfile: "config/config.yaml"
run = config["run"]
scenarios = get_scenarios(run)
-RDIR = get_rdir(run)
+prefix = run.get("prefix", "")
+rdir = get_rdir(run)
+
+if prefix:
+ RDIR = f"{prefix}/{rdir}"
+else:
+ RDIR = rdir
logs = path_provider("logs/", RDIR, run["shared_resources"])
benchmarks = path_provider("benchmarks/", RDIR, run["shared_resources"])
diff --git a/config/config.default.yaml b/config/config.default.yaml
index 235c238d..61ef8c1b 100644
--- a/config/config.default.yaml
+++ b/config/config.default.yaml
@@ -20,6 +20,7 @@ remote:
# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#run
run:
+ prefix: ""
name: ""
scenarios:
enable: false
From 05a3c43c30bd82a20f2c50f5a901a26cad2da6a6 Mon Sep 17 00:00:00 2001
From: Philipp Glaum
Date: Wed, 10 Apr 2024 12:23:28 +0200
Subject: [PATCH 2/3] move prefix from Snakefile to get_dir function
---
Snakefile | 8 +-------
scripts/_helpers.py | 5 +++++
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/Snakefile b/Snakefile
index ed60c0f5..ba93a869 100644
--- a/Snakefile
+++ b/Snakefile
@@ -22,13 +22,7 @@ configfile: "config/config.yaml"
run = config["run"]
scenarios = get_scenarios(run)
-prefix = run.get("prefix", "")
-rdir = get_rdir(run)
-
-if prefix:
- RDIR = f"{prefix}/{rdir}"
-else:
- RDIR = rdir
+RDIR = get_rdir(run)
logs = path_provider("logs/", RDIR, run["shared_resources"])
benchmarks = path_provider("benchmarks/", RDIR, run["shared_resources"])
diff --git a/scripts/_helpers.py b/scripts/_helpers.py
index 64ccab87..dfedcaea 100644
--- a/scripts/_helpers.py
+++ b/scripts/_helpers.py
@@ -59,6 +59,11 @@ def get_rdir(run):
RDIR = run["name"] + "/"
else:
RDIR = ""
+
+ prefix = run.get("prefix", "")
+ if prefix:
+ RDIR = f"{prefix}/{RDIR}"
+
return RDIR
From 8a0c12b579976491885d642a5d2a1431d8c88d6f Mon Sep 17 00:00:00 2001
From: Fabian Neumann
Date: Wed, 10 Apr 2024 16:56:35 +0200
Subject: [PATCH 3/3] add doc and release notes
---
doc/configtables/run.csv | 1 +
doc/release_notes.rst | 3 +++
2 files changed, 4 insertions(+)
diff --git a/doc/configtables/run.csv b/doc/configtables/run.csv
index 2835a324..44f06165 100644
--- a/doc/configtables/run.csv
+++ b/doc/configtables/run.csv
@@ -1,5 +1,6 @@
,Unit,Values,Description
name,--,str/list,"Specify a name for your run. Results will be stored under this name. If ``scenario: enable:`` is set to ``true``, the name must contain a subset of scenario names defined in ``scenario: file:``. If the name is 'all', all defined scenarios will be run."
+prefix,--,str,"Prefix for the run name which is used as a top-layer directory name in the results and resources folders."
scenarios,,,
-- enable,bool,"{true, false}","Switch to select whether workflow should generate scenarios based on ``file``."
-- file,str,,"Path to the scenario yaml file. The scenario file contains config overrides for each scenario. In order to be taken account, ``run: scenarios`` has to be set to ``true`` and ``run: name`` has to be a subset of top level keys given in the scenario file. In order to automatically create a `scenario.yaml` file based on a combination of settings, alter and use the ``config/create_scenarios.py`` script in the ``config`` directory."
diff --git a/doc/release_notes.rst b/doc/release_notes.rst
index b782a6df..79dfadcc 100644
--- a/doc/release_notes.rst
+++ b/doc/release_notes.rst
@@ -152,6 +152,9 @@ Upcoming Release
- Collection rules get a new wildcard ``run=config["run"]["name"]`` so they
can collect outputs across different scenarios.
+ - It is further possible to encapsulate your scenarios in a directory using
+ the setting ``run: prefix:``.
+
- **Warning:** One caveat remains for the scenario management with myopic or
perfect foresight pathway optimisation. The first investment period must be
shared across all scenarios. The reason is that the ``wildcard_constraints``