feat: overload monitoring tests and frontend fixes#37
Merged
Conversation
- Add comprehensive API and service tests for overload monitoring - Fix PDF result display and merge analysis steps in frontend - Add support for monitoring deselected overloads - Improve OverloadPanel and ActionFeed components
- Keep 'without permanent limits' count static - Show deselected count separately as requested
- Import and call enrich_actions_lazy after load_actions in update_config so that action 'content'/set_bus is computed on demand from 'switches' (PR marota/Expert_op4grid_recommender#49 compatibility) - Auto-generated disco_ actions now only store description fields; their content is derived lazily by LazyActionDict._build_disco_content - Rewrite test_recommender_simulation.py to load and verify the new lazy-format action dictionary (reduced_model_actions_test_pypowsybl.json): tests for absence of pre-computed content, LazyActionDict 'content' availability, and correct variant management during simulate_manual_action - Patch enrich_actions_lazy in test_recommender_service.py to keep those unit tests isolated from the real library https://claude.ai/code/session_01HfipZethVhYX7gQJ92oEEr
…e_ids, fix sanitize_for_json recursion Three root causes fixed: 1. conftest.py: now tries importlib.import_module() before installing a MagicMock stub, so real packages (pypowsybl, expert_op4grid_recommender and its submodules) are used when available. Mocks are only installed for packages that genuinely cannot be imported (e.g. alphaDeesp, which is not in the test environment). This makes TestRecommenderSimulationRealData run against the real pypowsybl network and real data_loader instead of opaque MagicMock objects. 2. recommender_service._get_base_network: adds a get_line_ids() convenience method to the returned pypowsybl Network object (Network.get_lines() returns a DataFrame; the tests and some service helpers need a plain list of IDs via get_line_ids()). 3. sanitize_for_json: the else-branch called obj.to_dict() and recursed unconditionally. For MagicMock objects (and any object whose to_dict() returns a non-dict), this caused infinite recursion and an eventual OOM kill. Now the result of to_dict() is checked with isinstance(d, dict) before recursing; otherwise str(obj) is returned immediately. 4. test_simulate_manual_action_sets_correct_variant: the _variant_id assertion referenced mock_get_obs.return_value (the auto-generated mock return-value, which is distinct from mock_obs returned by the side_effect function) instead of mock_obs directly. Corrected to assert mock_obs._variant_id. https://claude.ai/code/session_01HfipZethVhYX7gQJ92oEEr
Implement lazy-loading for action content in recommender service
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.
feat: Overload Monitoring Refinement and Comprehensive Testing
This PR consolidates several improvements to the N-1 overload monitoring flow and introduces a robust testing suite for both backend logic and frontend integration.
🚀 Key Improvements
1. Focused Analysis & Action Cards
2. Dynamic Monitoring Warning
(effective count) ... incl. X deselectedto provide better context.3. UI/UX Optimizations
🧪 Comprehensive Testing Suite
Introduced a suite of API and service-level tests to ensure stability and correctness of the split analysis flow:
/api/run-analysis-step1andstep2.pdf,result).selected_overloads,monitor_deselected,all_overloads).🛠 Technical Changes
expert_backend/main.pyandrecommender_service.pyto support the refined analysis flow and fixed PDF path resolution.App.tsx,OverloadPanel.tsx, andActionFeed.tsxfor better state management and UI performance.test_overload_filtering.py,test_recommender_simulation.py, andtest_split_analysis.py.Based on work from conversations 1cff2d49-4df1-4b36-ab6c-0577cf9248dd and f046a5e1-7850-4f96-ada9-b7656b533402.