fix(web): add edit and delete experiment functionality#8
Merged
Conversation
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.
3e6ba13 to
09be783
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds full edit and delete capabilities to the experiment detail page, complementing the existing scenario-level edit/delete that was already in place.
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 likestatusDelete experiment
delete_experiment()— pure function, validates path exists, callsshutil.rmtree()show_delete_experiment_dialog()—@st.dialogwith confirmation message, warning, and Cancel/Delete buttonsUpdate experiment with smart invalidation
update_experiment()— core update with 3-tier invalidation:_delete_scenario_files(),_invalidate_all_results(),_invalidate_changed_scenarios()helpersEdit experiment modal
show_edit_experiment_modal()—@st.dialog("Edit Experiment", width="large")_init_edit_experiment_state()network_config_form(),distribution_config_form(),simulation_params_form()withedit_exp_*key prefixesHeader layout
[8, 2]to[6, 4]column split:material/edit:), Delete (:material/delete:), Analyze (existing)Test coverage
15 new tests (22 total in file):
TestDeleteExperimentTestUpdateExperimentDiff stats
Test plan
pytest tests/test_web/test_experiment_detail.py -v)pytest— 468 passed, 19 skipped)