Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ if config["foresight"] == "perfect":
include: "rules/solve_perfect.smk"


# Pypsa-DE requires the scenario management by default
onstart:
scenarios_file = Path(config["run"]["scenarios"]["file"])
manual_file = Path(config["run"]["scenarios"]["manual_file"])

if not scenarios_file.exists():
print(
f"\033[91mWARNING: {scenarios_file} does not exist. Please run `snakemake build_scenarios` to create it.\033[0m"
)
elif manual_file.exists():
if scenarios_file.stat().st_mtime < manual_file.stat().st_mtime:
print(
f"\033[91mWARNING: {manual_file} is newer than {scenarios_file}. Please run `snakemake build_scenarios` to update {scenarios_file}.\033[0m"
)
else:
print(
f"\033[91mWARNING: {manual_file} does not exist. Please create it to use the scenario management.\033[0m"
)
print(
f"Scenario file {scenarios_file} exists and is up to date. Starting workflow."
)


rule all:
input:
expand(RESULTS + "graphs/costs.svg", run=config["run"]["name"]),
Expand Down Expand Up @@ -149,15 +172,6 @@ rule all:
default_target: True


rule create_scenarios:
output:
config["run"]["scenarios"]["file"],
conda:
"envs/environment.yaml"
script:
"config/create_scenarios.py"


rule purge:
run:
import builtins
Expand Down
Loading