Skip to content
Open
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:
repos:
# Generic 'file quality' testing
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
# Machine-friendliness
- id: trailing-whitespace
Expand All @@ -24,21 +24,21 @@ repos:

# Python file formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
rev: v0.16.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

# Snakemake file formatting
- repo: https://github.com/snakemake/snakefmt
rev: v0.10.2
rev: v2.0.3
hooks:
- id: snakefmt

# Spelling
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
rev: v2.4.3
hooks:
- id: codespell
files: .*\.(py|smk|md)$|^Snakefile$
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PV and wind area potentials and capacity factors
# PV and wind area potentials and capacity factors

This data module produces area potentials and capacity factors for PV and wind at arbitrary spatial resolution.

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://squidfunk.github.io/mkdocs-material/schema.json

site_name: PV and wind area potentials and capacity factors
site_name: PV and wind area potentials and capacity factors
site_url: https://module_pv_wind.readthedocs.io/
repo_name: module_pv_wind
repo_url: https://github.com/calliope-project/module_pv_wind/
Expand Down
27 changes: 19 additions & 8 deletions tests/integration/Snakefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
# Emulate a user configuring the module.
configfile: workflow.source_path("./test_config.yaml")


# Emulate how another workflow might create inputs for this module.
rule create_external_input:
message: "Example of a rule external to your module."
output:
text_file = "results/module_pv_wind/resources/user/user_message.md"
text_file="results/module_pv_wind/resources/user/user_message.md",
message:
"Example of a rule external to your module."
run:
from pathlib import Path
from textwrap import dedent
text = dedent("""Modular workflows can be used by more than one project!

text = dedent(
"""Modular workflows can be used by more than one project!
For example, this text comes from a file external to the module.
Try your best to make this workflow reusable so that others may benefit from your methods."""
)
file_path = Path(output.text_file)
with file_path.open("w") as f:
f.write(text)


# Import the module and configure it.
# `snakefile:` specifies the module. It can use file paths and special github(...) / gitlab(...) markers
# `prefix:` re-routes all input/output paths of the module, helping to avoid file conflicts.
module module_pv_wind:
snakefile: "../../workflow/Snakefile"
config: config["module_pv_wind"]
prefix: "results/module_pv_wind/"
snakefile:
"../../workflow/Snakefile"
config:
config["module_pv_wind"]
prefix:
"results/module_pv_wind/"


# rename all module rules with a prefix, to avoid naming conflicts.
use rule * from module_pv_wind as module_pv_wind_*


# Request something from the module
rule all:
message: "A generic test case for your module."
default_target: True
input:
"results/module_pv_wind/results/combined_text.md"
"results/module_pv_wind/results/combined_text.md",
message:
"A generic test case for your module."
5 changes: 3 additions & 2 deletions workflow/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ with open(workflow.source_path("internal/settings.yaml"), "r") as f:
include: "rules/automatic.smk"
include: "rules/dummy.smk"


rule all:
message:
"ERROR: Invalid `rule all:` call"
default_target: True
output:
"INVALID",
log:
stderr="logs/all.stderr",
conda:
"envs/shell.yaml"
message:
"ERROR: Invalid `rule all:` call"
shell:
'echo "This workflow must be called as a snakemake module." > {log.stderr}'
2 changes: 1 addition & 1 deletion workflow/internal/config.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ properties:
type: string
enum:
- left
- right
- right
8 changes: 4 additions & 4 deletions workflow/rules/automatic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@


rule dummy_download:
message:
"Download the clio README file."
params:
url=internal["resources"]["automatic"]["dummy_readme"],
output:
readme="resources/automatic/dummy_readme.md",
log:
"logs/dummy_download.log",
conda:
"../envs/shell.yaml"
params:
url=internal["resources"]["automatic"]["dummy_readme"],
message:
"Download the clio README file."
shell:
'curl -sSLo {output.readme} "{params.url}"'
8 changes: 4 additions & 4 deletions workflow/rules/dummy.smk
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
rule dummy_add_text:
message:
"Dummy rule combining user inputs and automatic downloads."
params:
config_text=config["dummy_text"],
input:
user_file="resources/user/user_message.md",
readme="resources/automatic/dummy_readme.md",
Expand All @@ -12,5 +8,9 @@ rule dummy_add_text:
"logs/dummy_add_text.log",
conda:
"../envs/shell.yaml"
params:
config_text=config["dummy_text"],
message:
"Dummy rule combining user inputs and automatic downloads."
script:
"../scripts/dummy_script.py"
1 change: 0 additions & 1 deletion workflow/scripts/download_cutout.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import atlite
import pandas as pd


if __name__ == "__main__":
cutout_params = snakemake.config["build_cutout"]["cutout_params"]

Expand Down