snakefile + helpers: separate scenario and rdir getter

This commit is contained in:
Fabian 2024-03-19 09:39:35 +01:00
parent a04ee4227f
commit 23e1139c21
2 changed files with 15 additions and 7 deletions

View File

@ -10,7 +10,7 @@ from snakemake.utils import min_version
min_version("8.5")
from scripts._helpers import path_provider, copy_default_files, process_run_config
from scripts._helpers import path_provider, copy_default_files, get_scenarios, get_rdir
copy_default_files(workflow)
@ -21,7 +21,8 @@ configfile: "config/config.yaml"
run = config["run"]
RDIR = process_run_config(run)
scenarios = get_scenarios(run)
RDIR = get_rdir(run)
logs = path_provider("logs/", RDIR, run["shared_resources"])
benchmarks = path_provider("benchmarks/", RDIR, run["shared_resources"])

View File

@ -39,14 +39,21 @@ def copy_default_files(workflow):
copyfile(template, target)
def process_run_config(run):
scenarios = run.get("scenarios", {})
if run["name"] and scenarios.get("enable"):
fn = Path(scenarios["file"])
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())
RDIR = "{run}/"
if run["name"] == "all":
run["name"] = list(scenarios.keys())
return scenarios
return {}
def get_rdir(run):
scenario_config = run.get("scenarios", {})
if run["name"] and scenario_config.get("enable"):
RDIR = "{run}/"
elif run["name"]:
RDIR = run["name"] + "/"
else: