forked from SWISDATA/processintel
mining: replace the stateful mining classes with pure functions #66
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ffrauenberger/ProcessIntel#66
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 (the internal state of the mining classes causes problems in the app)
Requested by: the user (2026-10-08)
Where
app/mining_algorithms/mining_interface.py:8-50—MiningInterfaceholdsgraph,min_node_size,logger;create_mining_instancebuilds an instance.app/mining_algorithms/base_mining.py:10-95— the constructor computes events, succession matrix, filtered logs, thresholds, start/end nodes and stores all of it onself.app/mining_algorithms/genetic_mining.py:31-60,:62-135—generate_graphfirst overwritesself.*parameters and results (dependency_matrix,best_individual,petri_net, …), then reads them back.app/mining_algorithms/alpha_mining.py:9,fuzzy_mining.py:8,heuristic_mining.py:8,inductive_mining.py:17,inductive_mining_infrequent.py:16— all subclassBaseMining.app/ui/base_algorithm_ui/base_algorithm_controller.py:42,:70,:78-110,:162— the controller keeps one model instance, callsgenerate_graph(**params)on it and reads getters (get_spm_threshold, …) to find out what the model did.Problem
Each mining algorithm is a class. An instance carries its log, its thresholds, its intermediate results and its graph.
generate_graphchanges that state. So the result depends on the history of the instance, not only on the input.This causes problems in the app:
have_parameters_changedand the threshold syncing exist.Related: #46 (models read and write
st.session_state) and #48 (no parameter contract). This issue is the wider restructuring; those two are parts of it.Fix
Make each algorithm a pure function of its input:
mine_<algorithm>(log, params) -> MiningResult(for examplemine_heuristic,mine_genetic).MiningResultis an immutable value holding the graph and the effective parameters (for example the thresholds after normalizing).logandparamsalways give the same result. No instance fields, nostreamlit, no module-level state, no reading of the clock. A random algorithm (genetic) takes aseedinparams.BaseMining(events, succession matrix, SPM and frequency filters, start/end nodes) become pure helper functions that take their input and return a new value. They do not write toself.MiningInterface,BaseMiningandcreate_mining_instance. Callers get a registry of name to function, with the parameter schema from #48.MiningResultand the lastparams. It calls the function again when the input changes. Streamlit's own caching can be used on top, since the function is pure.Sub-issues
One issue per miner:
mining.alphamining.heuristicmining.fuzzymining.inductivemining.inductive_infrequent(after #70)mining.geneticCheck
git grep -n "^class .*Mining" app/mining_algorithmsreturns nothing, andgit grep -n streamlit app/mining_algorithmsreturns nothing.python -m unittest discover -s tests -p '*_test.py'passes.from a session on 2026-10-08