ui.export: the export page re-renders the graph and re-pickles the model on every rerun #41

Open
opened 2026-10-06 13:51:28 +00:00 by ffrauenberger · 1 comment
Owner

Severity: improvement (medium)

Where

  • app/ui/export_ui/export_controller.py:194-228
  • app/io_operations/export_operations.py:33-75

Problem

On every script run of the Export page (any widget change, including typing in the DPI field):

  1. pickle_model() serializes the complete model, including the event log and its filtered copies.
  2. The graph is rendered by the external dot process in the selected format, written to disk and read back.
  3. If the format is not PNG, the graph is rendered again as PNG for the preview, written to disk, read back and base64-encoded.

export_graph also mutates the shared Digraph (attr(dpi=…), then dpi="0"). If rendering fails in between, the DPI setting stays on the session's graph.

Related: #20, #31.

Fix

  • Render in memory with graph.pipe(format=…) and cache the result per (graph_source_hash, format, dpi) (st.session_state or st.cache_data)
  • Produce the model export only when the user clicks Export Model (lazy download_button data)
  • Pass the DPI as a render argument instead of mutating the graph

from issues/PERF-005-export-page-rerenders-and-repickles-on-every-rerun.md (code analysis of commit 6bcc646, 2026-10-03)

**Severity:** improvement (medium) ## Where - `app/ui/export_ui/export_controller.py:194-228` - `app/io_operations/export_operations.py:33-75` ## Problem On every script run of the Export page (any widget change, including typing in the DPI field): 1. `pickle_model()` serializes the complete model, including the event log and its filtered copies. 2. The graph is rendered by the external `dot` process in the selected format, written to disk and read back. 3. If the format is not PNG, the graph is rendered **again** as PNG for the preview, written to disk, read back and base64-encoded. `export_graph` also mutates the shared `Digraph` (`attr(dpi=…)`, then `dpi="0"`). If rendering fails in between, the DPI setting stays on the session's graph. Related: #20, #31. ## Fix - Render in memory with `graph.pipe(format=…)` and cache the result per `(graph_source_hash, format, dpi)` (`st.session_state` or `st.cache_data`) - Produce the model export only when the user clicks *Export Model* (lazy `download_button` data) - Pass the DPI as a render argument instead of mutating the graph --- from `issues/PERF-005-export-page-rerenders-and-repickles-on-every-rerun.md` (code analysis of commit 6bcc646, 2026-10-03)
Author
Owner

Reviewed by Codex (GPT-6) against origin/main 6bcc646eb464.

Review: partially correct.

The repeated work and shared-graph DPI mutation are confirmed. The proposed “pass the DPI as a render argument” needs an API qualification: the current Python graphviz.Digraph.pipe()/render() APIs have no dpi= keyword. Use an independent graph copy and set its graph attribute, or render copied DOT through a subprocess with a Graphviz -Gdpi=... option. The in-memory pipe(format=...) proposal remains valid, but it must preserve the chosen DPI without mutating the session graph. Verified the installed pipe signature; see the Graphviz API.

Code references: app/ui/export_ui/export_controller.py:209, app/io_operations/export_operations.py:68.

Reviewed by **Codex (GPT-6)** against origin/main [`6bcc646eb464`](https://code.swisdata.eu/ffrauenberger/ProcessIntel/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4). **Review: partially correct.** The repeated work and shared-graph DPI mutation are confirmed. The proposed “pass the DPI as a render argument” needs an API qualification: the current Python `graphviz.Digraph.pipe()`/`render()` APIs have no `dpi=` keyword. Use an independent graph copy and set its graph attribute, or render copied DOT through a subprocess with a Graphviz `-Gdpi=...` option. The in-memory `pipe(format=...)` proposal remains valid, but it must preserve the chosen DPI without mutating the session graph. Verified the installed `pipe` signature; see the [Graphviz API](https://graphviz.readthedocs.io/en/stable/api.html). Code references: [app/ui/export_ui/export_controller.py:209](https://code.swisdata.eu/ffrauenberger/ProcessIntel/src/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4/app/ui/export_ui/export_controller.py#L209), [app/io_operations/export_operations.py:68](https://code.swisdata.eu/ffrauenberger/ProcessIntel/src/commit/6bcc646eb464e0dd897228b5e49867f65d7255c4/app/io_operations/export_operations.py#L68).
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ffrauenberger/ProcessIntel#41
No description provided.