Skip to content

Commit

Permalink
code: merge from upstream main
Browse files Browse the repository at this point in the history
  • Loading branch information
finozzifa committed Oct 22, 2024
2 parents 1d44b6f + 489ff8f commit c2b2551
Show file tree
Hide file tree
Showing 4 changed files with 22 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
20 changes: 17 additions & 3 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def get_aggregation_strategies(aggregation_strategies):
return bus_strategies, generator_strategies


def mock_snakemake(rule_name, root_dir=None, submodule_dir=None, **wildcards):
def mock_snakemake(rule_name, root_dir=None, submodule_dir=None, config_file=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 @@ -527,6 +527,12 @@ def mock_snakemake(rule_name, root_dir=None, submodule_dir=None, **wildcards):
----------
rule_name: str
name of the rule for which the snakemake object should be generated
root_dir: str
path to the root directory
submodule_dir: str
path to the submodule directory
config_file: 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 @@ -554,9 +560,17 @@ def mock_snakemake(rule_name, root_dir=None, submodule_dir=None, **wildcards):
if pathlib.Path(p).exists():
snakefile = p
break

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

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

0 comments on commit c2b2551

Please sign in to comment.