Do not open networks from files with older format version than the installed pandapower version#2912
Do not open networks from files with older format version than the installed pandapower version#2912dlohmeier wants to merge 8 commits intoe2nIEE:developfrom
Conversation
…stalled pandapower version
# Conflicts: # pandapower/convert_format.py # pandapower/file_io.py
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
pandapower/convert_format.py
Outdated
| "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? |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|



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.
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_geodatathat 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.