Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable subworkflow #36

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
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
27 changes: 20 additions & 7 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from snakemake.io import expand
from build_test_configs import create_test_config
from os.path import normpath, exists, isdir
from shutil import copyfile
from _helpers import create_country_list

import sys

Expand All @@ -21,6 +22,8 @@ HTTP = HTTPRemoteProvider()
COSTS = "data/costs.csv"
PROFILE = "data/sample_profile.csv"

PYPSAEARTH_FOLDER = "pypsa-earth"

if "config" not in globals() or not config: # skip when used as sub-workflow
if not exists("config.yaml"):
# prepare pypsa-earth config
Expand All @@ -31,6 +34,8 @@ if "config" not in globals() or not config: # skip when used as sub-workflow

configfile: "config.yaml"

config["countries"] = create_country_list(config["countries"])


ATLITE_NPROCESSES = config["atlite"].get("nprocesses", 5)

Expand All @@ -44,13 +49,21 @@ wildcard_constraints:
discountrate="[-+a-zA-Z0-9\.\s]*",


subworkflow pypsaearth:
workdir:
"./pypsa-earth"
snakefile:
"./pypsa-earth/Snakefile"
configfile:
"./config.yaml"
if not config.get("disable_subworkflow", False):

subworkflow pypsaearth:
workdir:
PYPSAEARTH_FOLDER
snakefile:
PYPSAEARTH_FOLDER + "/Snakefile"
configfile:
"./config.pypsa-earth.yaml"


if config.get("disable_subworkflow", False):

def pypsaearth(path):
return PYPSAEARTH_FOLDER + "/" + path


rule clean:
Expand Down
3 changes: 3 additions & 0 deletions config.distribution.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ logging:
level: INFO
format: "%(levelname)s:%(name)s:%(message)s"

# option to disable the subworkflow to ease the analyses
disable_subworkflow: false

scenario:
simpl: ['']
ll: ['copt']
Expand Down
Loading