Bug: TypeError when using source: build for cutout (str / str path division)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 615
- Forks
- 459
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 6
Description
Version Checks (indicate both or one)
-
I have confirmed this bug exists on the lastest release of PyPSA-Eur.
-
I have confirmed this bug exists on the current
masterbranch of PyPSA-Eur.
Issue Description
Bug Description
When setting data.cutout.source: build in config.yaml, Snakemake throws a TypeError:
unsupported operand type(s) for /: 'str' and 'str'
Location
rules/build_electricity.smk, line 202
Cause
dataset_version() returns folder as a string (via .as_posix()),
but the code uses the / operator which requires a Path object:
cutout=CUTOUT_DATASET["folder"] / "{cutout}.nc" # ← Bug
In retrieve.smk the same issue is correctly handled with +:
CUTOUT_DATASET["folder"] + "/{cutout}.nc" # ← Correct
Fix
Change line 202 in rules/build_electricity.smk from:
cutout=CUTOUT_DATASET["folder"] / "{cutout}.nc"
to:
cutout=CUTOUT_DATASET["folder"] + "/{cutout}.nc"
Context
This only occurs when using historical weather years not available
on data.pypsa.org (e.g. 1965), which requires source: build.
Version
v2026.02.0
Reproducible Example
1. Set in config.yaml:
data:
cutout:
source: build
version: latest
2. Run:
snakemake --cores 4 data/cutout/build/unknown/europe-1965-era5.nc
3. Error occurs immediately before any download starts
Expected Behavior
Snakemake should successfully create the build_cutout rule and
start downloading ERA5 data. The output path should be correctly
constructed as a string, consistent with how retrieve.smk handles
the same variable using + instead of /.
Installed Versions
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read rules/build_electricity.smk around line 202 and compare its cutout path construction with the corresponding handling in rules/retrieve.smk. Run snakemake --cores 4 data/cutout/build/unknown/europe-1965-era5.nc and confirm the build_cutout rule is created and starts downloading ERA5 data without the TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100