Skip to content

Conversation

@jorgenherje
Copy link
Collaborator

@jorgenherje jorgenherje commented Dec 15, 2025

Summary

Create flow network per tree type and provide to front-end for selection.

This PR fixes incorrect dataframe filtering in the Flow Network back-end and migrates the implementation from pandas/pyArrow to polars for better performance. The front-end now supports tree type selection for visualization.

Back-end Changes

  • Build full network per tree type: Provide to front-end as it does not exist metadata making it possible to select up front. (Must then download gruptree table from Sumo and read data anyways).
  • Fixed filtering bug: Corrected GroupTreeDataframeModel to properly filter dataframes based on tree type (GRUPTREE vs BRANPROP)
  • Performance improvement: Replace pandas with polars for better performance for dataframes. Replaced pyArrow Table with polars DataFrame as well, as it is easier to interact with.
  • Code organization: Refactored and moved utilities to _utils/ folder for better structure
    • _group_tree_dataframe_model.py renamed to group_tree_dataframe_model.py and placed in _utils folder
  • New test coverage: Added comprehensive tests for group tree filtering

Front-end Changes

  • Added tree type selection control in Flow Network settings
  • Updated state management to handle different tree types
  • Adjusted API integration to support tree type parameter

Technical Details

  • Refactored group_tree_dataframe_model.py with corrected filtering logic
  • Split network utilities into dedicated modules under _utils/
  • Updated flow_network_assembler.py to use polars
  • Enhanced API router and schemas to support tree type selection

TODO:


Closes: #1149

…-end

- Group tree dataframe model: create_df_for_tree_type, which separates sumo table data into correct dataframes per tree type.
- Make end-point return network for each existing tree type.
- Make Tree type a setting in front-end to being able to select.
- Remove usage if pa.Table in assembler, and utilize Polars Dataframe. Seems to be just as efficient.
- Some linting/typing fixes
- Fix unit test
@jorgenherje jorgenherje self-assigned this Dec 15, 2025
@jorgenherje jorgenherje added bug Something isn't working 2025 EOY release labels Dec 15, 2025
@jorgenherje jorgenherje changed the title [Fix]: Create correct flow network based on tree types [Fix]: Create correct flow network per tree types, and make tree type selectable in front-end Dec 16, 2025
Change form pa.Table to pl.Dataframe, convert from pa.Table -> pl.Dataframe in the FlowNetworkAssembler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2025 EOY release bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvements to the FlowNetwork module

1 participant