forked from SWISDATA/processintel
ui.base_algorithm: run long-running mining outside the UI script thread #54
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ffrauenberger/ProcessIntel#54
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: improvement (high: a parameter change during mining runs two minings at once on one model; reproduced as a crash)
Where
app/ui/base_algorithm_ui/base_algorithm_view.py:188-200app/ui/base_algorithm_ui/base_algorithm_controller.py:239-260app/mining_algorithms/genetic_mining.py:28-29,:110-166app/ui/genetic_miner_ui/genetic_miner_controller.py:152-205— the genetic miner's ownrun()app/ui/base_algorithm_ui/base_algorithm_controller.py:216-219— model construction outside the spinnerProblem
perform_miningruns insidest.spinnerin the Streamlit script thread:Corrections from the review
runner.fastRerunsdefaults toTrue. A widget change during mining starts a new script run at once, which callsperform_miningon the same model while the old thread is still computing. For the genetic miner this was reproduced asRuntimeError: Set changed size during iterationand a lost graph. The genetic controller then reports a population-size problem (genetic_miner_controller.py:190-194). For the other miners theRuntimeErroris not caught (base_algorithm_controller.py:242-261).process_session_state, outside any spinner (base_algorithm_controller.py:216-219). ForAlphaMiningthis is the full XL/YL computation (alpha_mining.py:17).st.session_state(#46).Related: #3, #31, #39.
Fix
In this order:
base_mining.py:121-124,:755-783) into the controller, and pass all parameters togenerate_graph.(log, algorithm, params) → result. Run it in a bounded executor kept inst.cache_resource, and keep the job handle inst.session_state. A new request cancels the previous job of the same session.st.fragment(run_every=…). The view shows progress and a Cancel button.(log_fingerprint, algorithm, params).Interim fix, small and independent: set
runner.fastReruns = falseinapp/.streamlit/config.toml. This serializes reruns per session and removes the concurrent-mining crash. It does not fix the cross-session cancellation or the GIL contention.Check
tests/mining_algorithms/genetic_mining_test.py: twoGeneticMininginstances run in parallel threads, and both produce a graph (fails today).perform_miningwhile one is running cancels the first and does not raise.from
issues/ARCH-009-long-running-mining-on-ui-thread.md(code analysis of commit6bcc646, 2026-10-03), corrected by the review inverdicts-claude/ARCH-009-long-running-mining-on-ui-thread.md