Skip to content

Commit 93f6e08

Browse files
authoredFeb 5, 2025··
Fix snakemake environment (#177)
* Fix snakemake environment * Add release note
1 parent 54a91ff commit 93f6e08

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed
 

‎docs/release_notes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Upcoming Release
1717
.. To use the features already you have to use the ``master`` branch.
1818
1919
* Include unit test execution and compile_cost_assumptions_usa.py in ci.yaml (https://github.com/PyPSA/technology-data/pull/174)
20+
* Align `snakemake` version and the related `mock_snakemake` to PyPSA-Eur (https://github.com/PyPSA/technology-data/pull/177)
2021

2122
`v0.11.0 <https://github.com/PyPSA/technology-data/releases/tag/v0.11.0>`__ (24th January 2025)
2223
=======================================================================================

‎environment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- python>=3.8
1111
- pip
1212
# for running the package
13-
- snakemake-minimal>=8.5
13+
- snakemake-minimal>=8.5,<8.25 # See https://github.com/snakemake/snakemake/issues/3202
1414
- pandas>=2.1
1515
- pypsa
1616
- pyarrow

‎scripts/_helpers.py

+20-11
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44

55
# coding: utf-8
66

7-
import os
87
import re
98
from pathlib import Path
109

11-
import snakemake as sm
12-
from snakemake.script import Snakemake
13-
1410

1511
class Dict(dict):
1612
"""
@@ -92,6 +88,19 @@ def mock_snakemake(
9288
keyword arguments fixing the wildcards. Only necessary if wildcards are
9389
needed.
9490
"""
91+
import os
92+
93+
import snakemake as sm
94+
from snakemake.api import Workflow
95+
from snakemake.common import SNAKEFILE_CHOICES
96+
from snakemake.script import Snakemake
97+
from snakemake.settings.types import (
98+
ConfigSettings,
99+
DAGSettings,
100+
ResourceSettings,
101+
StorageSettings,
102+
WorkflowSettings,
103+
)
95104

96105
script_dir = Path(__file__).parent.resolve()
97106
if root_dir is None:
@@ -111,7 +120,7 @@ def mock_snakemake(
111120
f" {root_dir} or scripts directory {script_dir}"
112121
)
113122
try:
114-
for p in sm.SNAKEFILE_CHOICES:
123+
for p in SNAKEFILE_CHOICES:
115124
if os.path.exists(p):
116125
snakefile = p
117126
break
@@ -120,12 +129,12 @@ def mock_snakemake(
120129
elif isinstance(configfiles, str):
121130
configfiles = [configfiles]
122131

123-
resource_settings = sm.ResourceSettings()
124-
config_settings = sm.ConfigSettings(configfiles=map(Path, configfiles))
125-
workflow_settings = sm.WorkflowSettings()
126-
storage_settings = sm.StorageSettings()
127-
dag_settings = sm.DAGSettings(rerun_triggers=[])
128-
workflow = sm.Workflow(
132+
resource_settings = ResourceSettings()
133+
config_settings = ConfigSettings(configfiles=map(Path, configfiles))
134+
workflow_settings = WorkflowSettings()
135+
storage_settings = StorageSettings()
136+
dag_settings = DAGSettings(rerun_triggers=[])
137+
workflow = Workflow(
129138
config_settings,
130139
resource_settings,
131140
workflow_settings,

0 commit comments

Comments
 (0)
Please sign in to comment.