diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 23c6c118..c68f4a36 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -17,6 +17,7 @@ Upcoming Release .. To use the features already you have to use the ``master`` branch. * Include unit test execution and compile_cost_assumptions_usa.py in ci.yaml (https://github.com/PyPSA/technology-data/pull/174) +* Align `snakemake` version and the related `mock_snakemake` to PyPSA-Eur (https://github.com/PyPSA/technology-data/pull/177) `v0.11.0 `__ (24th January 2025) ======================================================================================= diff --git a/environment.yaml b/environment.yaml index e7b04519..2b995d79 100644 --- a/environment.yaml +++ b/environment.yaml @@ -10,7 +10,7 @@ dependencies: - python>=3.8 - pip # for running the package -- snakemake-minimal>=8.5 +- snakemake-minimal>=8.5,<8.25 # See https://github.com/snakemake/snakemake/issues/3202 - pandas>=2.1 - pypsa - pyarrow diff --git a/scripts/_helpers.py b/scripts/_helpers.py index 84472b46..43abadf8 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -4,13 +4,9 @@ # coding: utf-8 -import os import re from pathlib import Path -import snakemake as sm -from snakemake.script import Snakemake - class Dict(dict): """ @@ -92,6 +88,19 @@ def mock_snakemake( keyword arguments fixing the wildcards. Only necessary if wildcards are needed. """ + import os + + import snakemake as sm + from snakemake.api import Workflow + from snakemake.common import SNAKEFILE_CHOICES + from snakemake.script import Snakemake + from snakemake.settings.types import ( + ConfigSettings, + DAGSettings, + ResourceSettings, + StorageSettings, + WorkflowSettings, + ) script_dir = Path(__file__).parent.resolve() if root_dir is None: @@ -111,7 +120,7 @@ def mock_snakemake( f" {root_dir} or scripts directory {script_dir}" ) try: - for p in sm.SNAKEFILE_CHOICES: + for p in SNAKEFILE_CHOICES: if os.path.exists(p): snakefile = p break @@ -120,12 +129,12 @@ def mock_snakemake( elif isinstance(configfiles, str): configfiles = [configfiles] - resource_settings = sm.ResourceSettings() - config_settings = sm.ConfigSettings(configfiles=map(Path, configfiles)) - workflow_settings = sm.WorkflowSettings() - storage_settings = sm.StorageSettings() - dag_settings = sm.DAGSettings(rerun_triggers=[]) - workflow = sm.Workflow( + resource_settings = ResourceSettings() + config_settings = ConfigSettings(configfiles=map(Path, configfiles)) + workflow_settings = WorkflowSettings() + storage_settings = StorageSettings() + dag_settings = DAGSettings(rerun_triggers=[]) + workflow = Workflow( config_settings, resource_settings, workflow_settings,