Skip to content

feat: add swmm_NODE_OUTFLOW to legacy and Python bindings#85

Merged
cbuahin merged 5 commits into
developfrom
copilot/swmm6-rel-support-outflow-value
May 28, 2026
Merged

feat: add swmm_NODE_OUTFLOW to legacy and Python bindings#85
cbuahin merged 5 commits into
developfrom
copilot/swmm6-rel-support-outflow-value

Conversation

Copy link
Copy Markdown

Copilot AI commented May 28, 2026

The legacy engine's getNodeValue API had no way to query Node.outflow (total outflow through downstream links), despite the field existing on the struct. The refactored engine already exposes this via swmm_node_get_outflow(). This brings the legacy API and both Python binding layers to parity.

Changes

C/Legacy engine:

  • Added swmm_NODE_OUTFLOW enum value to swmm_NodeProperty in openswmm_solver.h
  • Added case in legacy getNodeValue() returning node->outflow * UCF(FLOW)

Legacy Python bindings:

  • Added swmm_NODE_OUTFLOW to Cython .pxd declaration (solver.pxd)
  • Added SWMMNodeProperties.OUTFLOW enum member in _solver.pyx and _solver.pyi
  • Added outflow property to LegacyNode wrapper in _nodes.py

Refactored Python bindings:

  • Already fully supported (Node.outflow property) — added dedicated unit test

Tests:

  • Legacy: test_get_node_outflow (raw get_value API), test_read_outflow_during_sim, and test_outflow_via_get_value (OOP wrapper)
  • Refactored: test_outflow_property in test_nodes_pythonic.py

Usage

// C legacy API
double outflow = swmm_getValue(swmm_NODE, nodeIndex, swmm_NODE_OUTFLOW);
# Legacy Python bindings
val = solver.get_value(SWMMObjects.NODE, SWMMNodeProperties.OUTFLOW, index)
# or via OOP wrapper
node.outflow

# Refactored Python bindings
solver.nodes["J1"].outflow

Notes

  • Branch from swmm6_rel into develop as requested.

cbuahin added 3 commits May 28, 2026 06:26
Under Python 3.12 + numpy 2.4.6 the type-arg and operator errors that
this # type: ignore was suppressing are no longer raised, so mypy
strict mode reports the comment as unused and fails the typing
workflow. Remove it.

Signed-off-by: cbuahin <caleb.buahin@gmail.com>
node_series, link_series, subcatchment_series and system_series unpacked
self._series_range() into bare s, e, leaving them as Python objects.
Passing them to the swmm_output_get_*_series() C call inside
'with nogil:' then failed with 'Coercion from Python not allowed without
the GIL', breaking the wheel build on every macOS and Windows runner.

Declare s and e as cdef int before the unpack so Cython coerces directly
into C ints and the no-GIL call type-checks.

Signed-off-by: cbuahin <caleb.buahin@gmail.com>
cibuildwheel's manylinux Linux builds were failing in Cythonize steps
that ran right after openswmm/engine/_datetime.cpython-3??-*-linux-gnu.so
was linked into ninja's cwd. 'python -m cython' puts cwd on sys.path[0],
so CPython's datetime.py 'from _datetime import *' picked up our SWMM
_datetime module instead of the stdlib accelerator. The cleanup block
then deleted _check_date_fields (cp310) / 'datetime' (cp312) from
datetime's namespace, breaking every subsequent datetime use during
Cython's own import of xml.sax.saxutils -> calendar -> datetime.

Set WORKING_DIRECTORY on the Cython add_custom_command to the per-target
cython_gen/<target> folder, which only ever holds generated .cxx output
and contains no importable top-level names. macOS / Windows weren't
affected because their build ordering happens to cythonize the offending
.pyx files before _datetime.so is linked, but the same race could bite
on those platforms in different builds.

Signed-off-by: cbuahin <caleb.buahin@gmail.com>
Copilot AI linked an issue May 28, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Support for 'outflow' value in getNodeValue method Add swmm_NODE_OUTFLOW support to getNodeValue API May 28, 2026
Copilot AI requested a review from cbuahin May 28, 2026 10:50
@cbuahin
Copy link
Copy Markdown
Member

cbuahin commented May 28, 2026

@copilot , the pull request should be going into develop.

Copy link
Copy Markdown
Author

Copilot AI commented May 28, 2026

@copilot , the pull request should be going into develop.

I've updated the PR base branch to target develop.

@cbuahin cbuahin changed the base branch from main to develop May 28, 2026 16:37
Copilot AI force-pushed the copilot/swmm6-rel-support-outflow-value branch from 5f5e1ac to 4b5800f Compare May 28, 2026 16:42
Add swmm_NODE_OUTFLOW enum value to swmm_NodeProperty and handle it
in getNodeValue() to return node->outflow converted to user flow units.

The refactored engine already exposes this via swmm_node_get_outflow().
This change brings the legacy engine to parity.

Resolves support for 'outflow' value in getNodeValue method.
Ref: USEPA#168
Copilot AI changed the title Add swmm_NODE_OUTFLOW support to getNodeValue API feat(legacy): add swmm_NODE_OUTFLOW to getNodeValue API May 28, 2026
@cbuahin
Copy link
Copy Markdown
Member

cbuahin commented May 28, 2026

@copilot , I want to make sure the python bindings both legacy and refactored surface this new variable with relevant unit tests.

Copy link
Copy Markdown
Author

Copilot AI commented May 28, 2026

@copilot , I want to make sure the python bindings both legacy and refactored surface this new variable with relevant unit tests.

Done in commit feat(python): expose NODE_OUTFLOW in legacy and refactored bindings with tests.

Changes made:

  • Legacy bindings: Added swmm_NODE_OUTFLOW to the Cython .pxd, SWMMNodeProperties.OUTFLOW enum in _solver.pyx and _solver.pyi, and an outflow property on LegacyNode.
  • Refactored bindings: Already had Node.outflow exposed — added a dedicated unit test.
  • Tests: Added test_get_node_outflow (legacy get_value API), test_read_outflow_during_sim and test_outflow_via_get_value (legacy OOP wrapper), and test_outflow_property (refactored engine).

Copilot AI changed the title feat(legacy): add swmm_NODE_OUTFLOW to getNodeValue API feat: add swmm_NODE_OUTFLOW to legacy and Python bindings May 28, 2026
Copy link
Copy Markdown
Member

@cbuahin cbuahin 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!

@cbuahin cbuahin marked this pull request as ready for review May 28, 2026 17:02
@cbuahin cbuahin merged commit 58c2f82 into develop May 28, 2026
1 check passed
@jubilee2
Copy link
Copy Markdown

I’ve been running my own build with this feature for a while—really excited to see it officially supported now. Thanks for pushing this forward.

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.

Support for 'outflow' value in getNodeValue method

3 participants