Skip to content

Do not open networks from files with older format version than the installed pandapower version#2912

Open
dlohmeier wants to merge 8 commits intoe2nIEE:developfrom
dlohmeier:fix/older_pp_version
Open

Do not open networks from files with older format version than the installed pandapower version#2912
dlohmeier wants to merge 8 commits intoe2nIEE:developfrom
dlohmeier:fix/older_pp_version

Conversation

@dlohmeier
Copy link
Copy Markdown
Contributor

@dlohmeier dlohmeier commented Mar 10, 2026

In convert_format, an error is raised in case a network is converted with newer format version than the currently installed pandapower version. There is a flag in case a user wants to open a newer network, but this must be actively chosen.

  • in the version checks within convert_format, an error is raised if a network with newer format version than the currently installed pandapower version shall be opened
  • there is an option to ignore this check and only print out a warning
  • removal of the check_net_version function, as this was moved to convert_format and is explicitely used to avoid loading newer network formats than pandapower can handle

Why is this important?
It should be more user friendly to not let a user open a network with a format that is not supported by his installed pandapower version. If this error is not identified, some functions of pandapower might fail or produce wrong results unnoticed. The user should explicitly accept this risk instead of just printing a warning, as altering the network data could ultimately end in a network model that pandapower cannot handle anymore at all.

I also added the flag drop_invalid_geodata that is passed to the convert_format function to the file_io functions to make them more transparent to the user. Otherwise an error might be raised requiring to set this flag, but the user will not be able to set it in the calling function, but needs to first set the convert flag to false and then call the convert_format function with the correct arguments.

# Conflicts:
#	pandapower/convert_format.py
#	pandapower/file_io.py
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.86%. Comparing base (197bc5b) to head (953e225).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2912   +/-   ##
========================================
  Coverage    71.86%   71.86%           
========================================
  Files          351      351           
  Lines        37856    37856           
========================================
+ Hits         27206    27207    +1     
+ Misses       10650    10649    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

"install --upgrade pandapower`).")
logger.warning(msg1 + "Some features may not work as expected.")
if isinstance(net.format_version, str) and Version(net.format_version) >= Version(__format_version__):
# TODO: What if net.format_version is not a string?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should only be the case for very old networks.
isinstance check excludes very old networks as they used int for format_version, Version check is true if the network is newer or equal to the currently installed version.
In my opinion this TODO could be removed or replaced by a comment explaining this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a small comment above. If I got that right, we just assume that if the net.version is integer, this is an old network and it must pass the whole conversion. Let me know if there's a misconception.

@sonarqubecloud
Copy link
Copy Markdown

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.

3 participants