DHI / DHI/modelskill

Need shareable MOUSE and Water Hammer fixtures to support those formats in Network

Open
#686 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
56
Forks
9
Avg merge
57m
Merged PRs (30d)
3

Description

`Network` now has one constructor per modelling product, and each one exists only where a committed test fixture backs it:

| Constructor | Extensions | Fixture |
|---|---|---|
| `Network.from_mike` | `.res1d`, `.res11` | `tests/testdata/network.res1d`, `network_cali.res11` |
| `Network.from_epanet` | `.res` | `tests/testdata/epanet.res` |

Two of the formats mikeio1d can open are refused purely because we have no file to test them with:

- **MOUSE** — `.prf`, `.crf`, `.xrf`
- **Water Hammer** — `.whr`

Neither has a result file in this repo or in [mikeio1d's testdata](https://github.com/DHI/mikeio1d/tree/main/tests/testdata), so there is no way to check whether the existing loader produces a correct network for them. Both currently raise:

```
NotImplementedError: Cannot read '.prf' files. MOUSE results are not supported
yet: modelskill has no test fixture for this format, so support cannot be
verified. Please open an issue if you need it.
```

**What would help:** a small, redistributable result file for either format — ideally from a public or synthetic model rather than a client project. Once one lands in `tests/testdata`, adding the constructor is a docstring plus one delegating call to `Network._from_mikeio1d`, and the extension moves from `_UNSUPPORTED_EXTENSIONS` to its own set in `src/modelskill/network.py`.

One caveat worth recording for whoever picks this up: for MOUSE extensions mikeio1d calls `ResultData.Load()` and *rebuilds* `res1d.network` on the first data read ([`result_reader.py:141-146`](https://github.com/DHI/mikeio1d/blob/main/mikeio1d/result_reader_writer/result_reader.py)), with a comment noting that existing network references are invalidated. `Network._load_res1d_network` captures `ResultReach` objects and then triggers that read, so MOUSE support may need the load forced up front. That cannot be confirmed without a fixture.

### Not fixture problems

Two other formats are refused for a different reason, and no fixture will change that:

- **SWMM** (`.out`) — mikeio1d cannot resolve reach start/end nodes. `ResultReachCreator._get_start_node` indexes `result_data.Nodes[reach.StartNodeIndex]` and raises `ArgumentOutOfRangeException`; mikeio1d's own `test_swmm_network.py` never touches reach connectivity.
- **`.resx`** — `ResultReach.start_node`/`end_node` return `None` by design.

Both are upstream gaps rather than modelskill bugs. `tests/testdata/swmm.out` and `epanet.resx` are committed and asserted against, so if a future mikeio1d starts exposing connectivity for either, those tests fail and tell us a constructor is now possible.

An EPANET file from a confidential project was also used during development to sanity-check `from_epanet` at scale (~8000 reaches); it cannot be committed, hence the smaller public fixture.

Contributor guide

Open the contributing guide

Research direction

Start by inspecting src/modelskill/network.py, especially Network._from_mikeio1d and _load_res1d_network, then review the existing files and assertions in tests/testdata. A suitable first step is to obtain or create a small redistributable MOUSE or Water Hammer result file and run the relevant network tests. Done means the fixture is committed, the supported extension is no longer marked unsupported, and the constructor verifies network loading without invalidated references.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.