Skip to content

fix(web): add edit and delete experiment functionality#8

Merged
mcaxtr merged 4 commits intomainfrom
worktree-feature/edit-delete-experiments
Feb 24, 2026
Merged

fix(web): add edit and delete experiment functionality#8
mcaxtr merged 4 commits intomainfrom
worktree-feature/edit-delete-experiments

Conversation

@mcaxtr
Copy link
Copy Markdown
Owner

@mcaxtr mcaxtr commented Feb 24, 2026

Summary

Adds full edit and delete capabilities to the experiment detail page, complementing the existing scenario-level edit/delete that was already in place.

  • Edit experiment: modal dialog with pre-filled forms for name, description, global parameters, and dynamic scenario list
  • Delete experiment: confirmation dialog that removes the entire experiment directory
  • Smart result invalidation: 3-tier strategy preserves results when possible, only invalidating what actually changed
  • Header redesign: action bar now includes Edit, Delete, and Analyze buttons in a balanced layout

Changes

Comparison helpers

  • _params_equal() — numeric-tolerant dict comparison (handles int/float mismatch from JSON deserialization)
  • _scenarios_equal() — compares effective parameters (globals + overrides), strips metadata keys like status

Delete experiment

  • delete_experiment() — pure function, validates path exists, calls shutil.rmtree()
  • show_delete_experiment_dialog()@st.dialog with confirmation message, warning, and Cancel/Delete buttons

Update experiment with smart invalidation

  • update_experiment() — core update with 3-tier invalidation:
    • No-op: nothing changed -> preserve all results
    • Targeted: only changed/removed scenarios -> invalidate those scenario results only
    • Full: global parameter changes -> invalidate all scenario results + experiment analysis
  • _delete_scenario_files(), _invalidate_all_results(), _invalidate_changed_scenarios() helpers
  • Directory rename on name change with collision detection

Edit experiment modal

  • show_edit_experiment_modal()@st.dialog("Edit Experiment", width="large")
  • Pre-seeds session state with current experiment values via _init_edit_experiment_state()
  • Reuses network_config_form(), distribution_config_form(), simulation_params_form() with edit_exp_* key prefixes
  • Dynamic scenario list with add/remove/render matching creation modal patterns
  • Session state lifecycle management with stale-guard detection (prevents leaks on dialog X-close)

Header layout

  • Changed from [8, 2] to [6, 4] column split
  • Three sub-columns: Edit (:material/edit:), Delete (:material/delete:), Analyze (existing)

Test coverage

15 new tests (22 total in file):

Class Tests Coverage
TestDeleteExperiment 4 Directory deletion, result file cleanup, None path error, non-existent dir error
TestUpdateExperiment 11 Name/description/param changes, no-op detection, name collision, empty name, normalized rename, scenario removal, scenario override change, empty scenarios, duplicate labels

Diff stats

spkmc/web/pages/experiment_detail.py     | 795 ++-
tests/test_web/test_experiment_detail.py | 498 ++
2 files changed, 1279 insertions(+), 14 deletions(-)

Test plan

  • All 22 unit tests pass (pytest tests/test_web/test_experiment_detail.py -v)
  • Full suite passes (pytest — 468 passed, 19 skipped)
  • Manual: Edit experiment name -> directory renames, results preserved
  • Manual: Edit global params -> all results invalidated
  • Manual: Delete experiment -> returns to dashboard
  • Manual: X-close edit dialog -> no stale state on reopen

Add _params_equal() for numeric-tolerant dict comparison and
_scenarios_equal() for effective-parameter comparison that strips
metadata keys and merges global defaults before diffing.
Add delete_experiment() pure function and show_delete_experiment_dialog()
with confirmation UI. Includes 4 unit tests covering directory deletion,
result file cleanup, and error cases for None/missing paths.
Add update_experiment() with 3-tier invalidation strategy:
- No-op: nothing changed, preserve all results
- Targeted: only changed/removed scenarios invalidated
- Full: global parameter changes invalidate all results

Includes _delete_scenario_files(), _invalidate_all_results(), and
_invalidate_changed_scenarios() helpers. Handles directory rename
on name change with collision detection.

11 unit tests cover name/description/parameter changes, no-op
detection, collision errors, and scenario-level invalidation.
Add show_edit_experiment_modal() dialog with pre-filled forms for
name, description, global parameters, and dynamic scenario list.
Reuses network_config_form(), distribution_config_form(), and
simulation_params_form() components with edit-scoped key prefixes.

Modify header layout to [6,4] split with [2,1,1] action sub-columns
for Analyze, Edit, and Delete buttons. Icon-only coloring: green
(Analyze), orange (Edit), red (Delete) with nowrap text.

Includes session state lifecycle management with stale-guard
detection to prevent state leaks on dialog X-close.
@mcaxtr mcaxtr force-pushed the worktree-feature/edit-delete-experiments branch from 3e6ba13 to 09be783 Compare February 24, 2026 18:09
@mcaxtr mcaxtr changed the title feat(web): add edit and delete experiment functionality fix(web): add edit and delete experiment functionality Feb 24, 2026
@mcaxtr mcaxtr merged commit 7bfc6ef into main Feb 24, 2026
11 checks passed
@mcaxtr mcaxtr deleted the worktree-feature/edit-delete-experiments branch February 24, 2026 18:33
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.

1 participant