Skip to content

Fix raw OSM build and release process#1956

Merged
lkstrp merged 29 commits intoPyPSA:masterfrom
open-energy-transition:fix-osm-build-and-release
Jan 22, 2026
Merged

Fix raw OSM build and release process#1956
lkstrp merged 29 commits intoPyPSA:masterfrom
open-energy-transition:fix-osm-build-and-release

Conversation

@brynpickering
Copy link
Contributor

Fixes issues found in a soft fork project.

Result of the two changes can be found in this zenodo record: https://zenodo.org/records/18161054

Changes proposed in this Pull Request

  • Delete column filtering when preparing release. It was previously filtering out columns it would later want access to, after column renaming.
  • Use invariant names for virtual buses. This means that when the OSM data updates, the virtual bus ID does not change (previously, the integer naming convention was based on the order of processing the raw data rows, which was not deterministic)

Checklist

  • I tested my contribution locally and it works as intended.
  • Code and workflow changes are sufficiently documented.
  • Changed dependencies are added to pixi.toml (using pixi add <dependency-name>).
  • Changes in configuration options are added in config/config.default.yaml.
  • Changes in configuration options are documented in doc/configtables/*.csv.
  • For new data sources or versions, these instructions <https://pypsa-eur.readthedocs.io/en/latest/data_sources.html>_ have been followed.
  • A release note doc/release_notes.rst is added.

- delete column filtering when preparing release
- use invariant names for virtual buses

---

Co-authored-by: yerbol-akhmetov <yerbol.akhmetov.93@gmail.com>
@fneum fneum requested a review from bobbyxng January 6, 2026 10:30
@bobbyxng
Copy link
Collaborator

bobbyxng commented Jan 6, 2026

Thanks @brynpickering for the PR and suggestion, I like the idea very much to make the virtual buses more persistent/invariant, at the time of implementation, numbering was the easier way to go. Using endpoints is also a good idea, I made a few comments, see the individual conversations. Here are some summarised thoughts:

  • Suggestion to implement some basic sorting (ensuring that bus0 stays 0 and bus1 stays 1 and does not "flip" at some point)
  • Suggestion to clean up the names (needs to be addressed in other parts of the workflow/script), so namings like this "DE_way/25046847-2-110_0-380" do not happen (110 and 380 are "contradicting", ideally only one of the two suffixes is needed --> also unique).
  • Open question: A virtual bus always connects two lines. Both endpoints go into the pool of virtual bus candidates. Before, there was a simple method to drop duplicates based on identical geometry and voltage (and to prioritise "real" substations over virtuals in the naming). I think this was fine before, as there was no "ambition" of having persistent virtual bus names. Now, if we do this correctly, we need to make sure, that we have an invariant/deterministic way of determining the "name-giving" endpoint ("entering" or "exiting" line). One simple idea could be to take the longer of the two lines (similar to taking the largest substation, if they are merged together).

@brynpickering
Copy link
Contributor Author

Thanks for the review @bobbyxng. I have been working with a fork that still uses pypsa <v1 hence the difference with the bug you've seen. PyPSA-Eur doesn't yet require pypsa v1 (the config sets >=0.35.0) so I guess a fix needs to be cross-compatible.

@brynpickering brynpickering requested a review from bobbyxng January 7, 2026 11:21
@brynpickering
Copy link
Contributor Author

Open question: A virtual bus always connects two lines.

Except at stubs, where the virtual bus is the end of one line and that is all. But for the other cases you mention, I see what you mean.

One simple idea could be to take the longer of the two lines (similar to taking the largest substation, if they are merged together)

Seems reasonable. As with other concerns around the underlying data changing, I think it's fine if this isn't strictly persistent if the OSM data changes and the longest line changes.

Copy link
Collaborator

@bobbyxng bobbyxng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updates look good! Almost ready to approve, there are some merge conflicts, that I cannot resolve due to missing rights to your fork. Thanks @brynpickering for improving the OSM grid building process!

brynpickering and others added 17 commits January 20, 2026 12:54
* code: Make path relative to current snakefile

* doc: Add release notes on data layer
* Update locked environment files for all platforms

* trigger

---------

Co-authored-by: lkstrp <62255395+lkstrp@users.noreply.github.com>
Co-authored-by: lkstrp <lkstrp@pm.me>
* Fix Bug 1: Resolve double prefixing caused by f-string coercion.

* Fix Bug 2: Rule retrieve_co2stop not saving files in correct location.
Fix by making filepaths relative to an input or output location.

* Fix Bug 3: make filepaths in rule retrieve_corine relative to the zip_file in `input`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated release notes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* minimal version

* new `config.default.yaml`

* exclude schema from pre-commit

* add model for default config

* add `schema.json`

* ci: add schema in sync check

* duck type model schema

* show schema in docs

* move ci check to unit test

* updade lock file and add data.py schema

* update schema

* fix pre-commit, split workflow

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* shorten workflow name

* fix undocumented literals

* merge changes from PyPSA#1940

* fix docs

* feat: add relative schema definition to config files

* feat: add relative schema definition to config/examples files

Maybe we don't want that, since those would be moved to config/... when being used and
then the link would be broken?

* feat: Use ruamel to add comments back into the config.default.yaml

* fix: readd newlines between top-level sections

* fix(doc): fix broken references

* feat: convert pydantic description links to rst

* feat: add markdownDescription attributes for schema links

* fix literal-includes in docs

* add contributing docs, switch yaml with description in config docs

* remove typing_extension, fix more links

* update schema

* apply review

* docs: add custom validators info (field and model)

* docs: fix links

* update lock file

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jonas Hoersch <jonas.hoersch@openenergytransition.org>
* Fix europe-2013 cutout default value.

* Updated default config and schema to revert to 2013 cutout.

---------

Co-authored-by: Lukas Trippe <lkstrp@pm.me>
* Add messages for all retrieval rules

* Add messages for all build electricity rules

* Add messages to sector building rules

* Add messages for collect rules

* Add messages for solve electricity rules

* Add messages for solve myopic rules

* Add messages for solve overnight rules

* Add messages for solving perfect foresight rules

* Added messages to postprocessing rules

* Add missing qualifiers to messages

* Add missing qualifiers to build elec messages

* Add release note

* Fixed typo in message

* Removed missing wildcard from the message

* Add rule name to message (if not present) for logging

* Fix incorrect wildcard in rule

* feat: Add simple descriptive logger plugin and use by default

The logger plugin registers a derived class of snakemake's DefaultFormatter
which shows the bold message in front of the regular job info block.

* Revert "Add rule name to message (if not present) for logging"

This reverts commit c4fd02e.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add SPDX license metadata to plugin

* Do not track Python eggs

* Rename plugin from descriptive to pypsa

* Add SPDX license metadata to config

* Update plugins/snakemake-logger-plugin-pypsa/README.md

Co-authored-by: Lukas Trippe <lkstrp@pm.me>

* add profiles docummentation

Co-authored-by: Lukas Trippe <lkstrp@pm.me>

* fix: formatting

* Moved plugin code to own repository

* Add pixi.toml from master branch

* Add logger plugin to pixi toml

* Added messages to each of the retrieve rules

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update lock file

---------

Co-authored-by: Jonas Hoersch <jonas.hoersch@openenergytransition.org>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Lukas Trippe <lkstrp@pm.me>
Co-authored-by: Jonas Hörsch <coroa@posteo.de>
* fix: avoid netcdf4 version 1.7.4

* Revert "fix: avoid netcdf4 version 1.7.4"

This reverts commit 23fb6ad.

* pin in `pixi.toml`

---------

Co-authored-by: lkstrp <lkstrp@pm.me>
Co-authored-by: lkstrp <62255395+lkstrp@users.noreply.github.com>
bobbyxng and others added 4 commits January 20, 2026 12:55
* Updated technology-data to v0.13.4.

* Added release note.

* Update data/versions.csv

* Update data/versions.csv

Co-authored-by: Johannes HAMPP <42553970+euronion@users.noreply.github.com>

---------

Co-authored-by: Lukas Trippe <lkstrp@pm.me>
Co-authored-by: Johannes HAMPP <42553970+euronion@users.noreply.github.com>
* Fix mock snakemake for Snakemake API changes.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated pixi.lock.

* Added release notes.

* Make mock_snakemake more robust: Handling different LoggerManager arguments depending on snakemake version.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Lukas Trippe <lkstrp@pm.me>
@bobbyxng
Copy link
Collaborator

bobbyxng commented Jan 20, 2026

@brynpickering: @lkstrp fixed some bugs in the upstream wrt. to workflow testing (#1992). Could you please merge it into your branch/PR? Only when the checks are successful, I can approve.

Thanks!

Edit:// General comment: Missing push rights is due to this fork being managed by OET Github user group (which I am not part of). I don't know if there's a better way to handle this in the future, otherwise everything just takes longer and creates a lot of friction @fneum

@fneum
Copy link
Member

fneum commented Jan 20, 2026

Normally, maintainers of the repositories for which PR is made gain push rights on the branch of the PR, but it might be blocked from OET-org side.

@fneum
Copy link
Member

fneum commented Jan 20, 2026

Failing CI due to #1930, not this PR's fault.

Copy link
Collaborator

@bobbyxng bobbyxng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks @brynpickering!

@lkstrp lkstrp enabled auto-merge (squash) January 22, 2026 09:39
@lkstrp lkstrp merged commit 9450f99 into PyPSA:master Jan 22, 2026
7 checks passed
@lkstrp lkstrp deleted the fix-osm-build-and-release branch January 22, 2026 10:49
@brynpickering
Copy link
Contributor Author

Thanks @bobbyxng ! Any chance you could publish a new zenodo version to the existing record, based on this update (and updating the OSM content more generally)?

@bobbyxng
Copy link
Collaborator

bobbyxng commented Jan 28, 2026

Thanks @bobbyxng ! Any chance you could publish a new zenodo version to the existing record, based on this update (and updating the OSM content more generally)?

Yes, just did not have the time yet :) I wanted to make another PR on improving the workflow (comparison of individual builds) and update the zenodo record in this process. Will prioritise this next! @brynpickering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants