snakefile + helpers: separate scenario and rdir getter
This commit is contained in:
parent
a04ee4227f
commit
23e1139c21
@ -10,7 +10,7 @@ from snakemake.utils import min_version
|
|||||||
|
|
||||||
min_version("8.5")
|
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)
|
copy_default_files(workflow)
|
||||||
@ -21,7 +21,8 @@ configfile: "config/config.yaml"
|
|||||||
|
|
||||||
|
|
||||||
run = config["run"]
|
run = config["run"]
|
||||||
RDIR = process_run_config(run)
|
scenarios = get_scenarios(run)
|
||||||
|
RDIR = get_rdir(run)
|
||||||
|
|
||||||
logs = path_provider("logs/", RDIR, run["shared_resources"])
|
logs = path_provider("logs/", RDIR, run["shared_resources"])
|
||||||
benchmarks = path_provider("benchmarks/", RDIR, run["shared_resources"])
|
benchmarks = path_provider("benchmarks/", RDIR, run["shared_resources"])
|
||||||
|
@ -39,14 +39,21 @@ def copy_default_files(workflow):
|
|||||||
copyfile(template, target)
|
copyfile(template, target)
|
||||||
|
|
||||||
|
|
||||||
def process_run_config(run):
|
def get_scenarios(run):
|
||||||
scenarios = run.get("scenarios", {})
|
scenario_config = run.get("scenarios", {})
|
||||||
if run["name"] and scenarios.get("enable"):
|
if run["name"] and scenario_config.get("enable"):
|
||||||
fn = Path(scenarios["file"])
|
fn = Path(scenario_config["file"])
|
||||||
scenarios = yaml.safe_load(fn.read_text())
|
scenarios = yaml.safe_load(fn.read_text())
|
||||||
RDIR = "{run}/"
|
|
||||||
if run["name"] == "all":
|
if run["name"] == "all":
|
||||||
run["name"] = list(scenarios.keys())
|
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"]:
|
elif run["name"]:
|
||||||
RDIR = run["name"] + "/"
|
RDIR = run["name"] + "/"
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user