Skip to content

Commit

Permalink
Merge branch 'pypsa-meets-earth:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
SermishaNarayana authored Oct 17, 2024
2 parents e85f01d + 489ff8f commit 60b9453
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exclude: ^(LICENSES)

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
Expand Down Expand Up @@ -49,7 +49,7 @@ repos:

# Formatting with "black" coding style
- repo: https://github.com/psf/black
rev: 24.8.0
rev: 24.10.0
hooks:
# Format Python files
- id: black
Expand Down
2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ E.g. if a new rule becomes available describe how to use it `make test` and in o

* Fix the mismatch between buses and x, y locations while creating H2 Stores `PR #1134 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1134>`_

* Enable configfile specification for mock_snakemake `PR #1135 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1135>`_

PyPSA-Earth 0.4.1
=================

Expand Down
2 changes: 1 addition & 1 deletion envs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies:
# GIS dependencies:
- cartopy
- descartes
- rasterio!=1.2.10
- rasterio!=1.2.10, <=1.3.11
- rioxarray

# Plotting
Expand Down
18 changes: 15 additions & 3 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,9 @@ def get_aggregation_strategies(aggregation_strategies):
return bus_strategies, generator_strategies


def mock_snakemake(rulename, root_dir=None, submodule_dir=None, **wildcards):
def mock_snakemake(
rulename, root_dir=None, submodule_dir=None, configfile=None, **wildcards
):
"""
This function is expected to be executed from the "scripts"-directory of "
the snakemake project. It returns a snakemake.script.Snakemake object,
Expand All @@ -534,6 +536,8 @@ def mock_snakemake(rulename, root_dir=None, submodule_dir=None, **wildcards):
----------
rulename: str
name of the rule for which the snakemake object should be generated
configfile: str
path to config file to be used in mock_snakemake
wildcards:
keyword arguments fixing the wildcards. Only necessary if wildcards are
needed.
Expand Down Expand Up @@ -566,9 +570,17 @@ def mock_snakemake(rulename, root_dir=None, submodule_dir=None, **wildcards):
if os.path.exists(p):
snakefile = p
break

if isinstance(configfile, str):
with open(configfile, "r") as file:
configfile = yaml.safe_load(file)

workflow = sm.Workflow(
snakefile, overwrite_configfiles=[], rerun_triggers=[]
) # overwrite_config=config
snakefile,
overwrite_configfiles=[],
rerun_triggers=[],
overwrite_config=configfile,
)
workflow.include(snakefile)
workflow.global_resources = {}
try:
Expand Down

0 comments on commit 60b9453

Please sign in to comment.