Build a NetworkModelResult straight from a result file - #699
Draft
jpalm3r wants to merge 4 commits into
Draft
Conversation
jpalm3r
force-pushed
the
network-model-from-path
branch
from
August 10, 2026 13:26
74700cd to
db99d3c
Compare
jpalm3r
force-pushed
the
network-model-from-path
branch
from
August 10, 2026 13:51
8d3d606 to
37bda9e
Compare
_network_from_path picks the constructor from the extension, and an EPANET .res also gets the .resx and .inp sitting beside it: without the .inp no reach has a length, so reach matching cannot work at all. A companion the caller never asked for is named in the error when the load fails, along with the explicit call that skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Every other model result class takes a path, so a network workflow needed an extra import and an extra line for no reason. A Network object still works. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The MIKE+ example loses a line: the whole workflow now starts from a result file path. ADR-012 records why the model result layer may read the extension table where Network may not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
mikeio1d decodes '.res' text as UTF-8 but '.resx' text as the Windows ANSI codepage, so a node named 'ØST' in one file is 'ØST' in the other. Four Danish tank names in a real EPANET model were enough to make the two files look like different models and fail validation. Worse when validation passed: the merge looks locations up by the main file's name, so those nodes lost their companion quantities silently. The repair is only used when it produces a name the main file actually has, so a companion from a genuinely different model still raises. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jpalm3r
force-pushed
the
network-model-from-path
branch
from
August 10, 2026 14:02
37bda9e to
a5dec82
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NetworkModelResultwas the only model result class that could not be built from a file.PointModelResult,GridModelResult,DfsuModelResultand even the network's ownNodeModelResultall take a path, so a network workflow needed an extra import and an extra line for no reason.A
Networkstill works, unchanged.The extension picks the constructor
ADR-012 keeps one
Networkconstructor per modelling product, and rejected guessing the product from the file. This reads the extension anyway, one layer up, for the reason that objection does not reach here: the tables already map each extension to exactly one product —.resis EPANET's and nobody else's — and the answer is reported inmr.network. Unreadable formats come back with the refusal messages already written for them, so.outstill explains where SWMM keeps its topology. The ADR records the exemption.Network.from_mike/from_epanetstay the only way in when a file needs named companions or selective loading, and the guide says so.An EPANET file collects its companions
An EPANET run writes up to three files, and the
.resalone gives no reach lengths at all — so a network built from the path would silently be one on which reach matching cannot work. A path picks up the.resxand.inpsharing its folder and stem.The companion validation already refuses a
.resxfrom a different run. Since these were never asked for, a failure now names the file that was picked up and the explicit call that skips it.Bug fix: companion names arrive in two encodings
Found on a real MIKE+ EPANET model. mikeio1d decodes
.restext as UTF-8 but.resxtext as the Windows ANSI codepage, so a node namedØSTin one file isØSTin the other:The four Danish tank names were enough to make one model look like two. This predates the path constructor —
from_epanet(res, resx=...)fails identically — and the louder half was not the worse half: the merge looks companions up by the main file's name, so had validation passed, those tanks would have lost theirVolumeandVolume Percentagewithout a word.A companion is now keyed by the main file's names. The repair is used only when it produces a name the
.resactually has, so a companion from a genuinely different model still raises as before.Notes for review
modelskill.networkinside the branch, somodelskill.model.networkstays importable withoutnetworkxandmikeio1d(ADR-010).Stack created with GitHub Stacks CLI • Give Feedback 💬