-
Notifications
You must be signed in to change notification settings - Fork 29
Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Sierd <[email protected]>
Co-authored-by: Sierd <[email protected]>
Co-authored-by: Sierd <[email protected]>
Co-authored-by: Sierd <[email protected]>
Co-authored-by: Sierd <[email protected]>
…i package structure Co-authored-by: Sierd <[email protected]>
Co-authored-by: Sierd <[email protected]>
Completed! Here's what I've implemented: ✅ #1 Code OrganizationCreated modular package structure:
✅ #2 Code Duplication
✅ Export FunctionalityPNG Export (7 functions):
MP4 Animations (2 functions):
📋 Additional Improvements ProposedCreated High Priority:
Medium Priority:
Long-term:
All changes maintain 100% backward compatibility. Ready for review! Commits: fbc587c (docs), 6caabaf (organization), d95027d (export) |
|
@copilot continue the refracturing and splitting gui_app_backup.py into smaller modules (tabs, visualizers, etc.) |
…plication.py Co-authored-by: Sierd <[email protected]>
Completed! Here's what I've done: ✅ Renamed File
✅ Extracted Domain VisualizerCreated
✅ Refactored Application
📦 New Structure🎯 Benefits
🚀 NextReady to extract:
Commit: 6083e1d |
|
@copilot Continue to make the code more modular by moving more stuff to the visualisers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request refactors the monolithic aeolis/gui.py file (2,688 lines) into a modular package structure to improve maintainability, readability, and code organization. The refactoring extracts utilities, constants, and specialized visualizers into separate modules while maintaining 100% backward compatibility.
Key changes:
- Modularized GUI code into separate packages (
aeolis/gui/withutils.py,visualizers/,application.py,main.py) - Extracted constants and utility functions to reduce code duplication by ~25%
- Created specialized visualizer classes for domain, wind, output 2D/1D, and model runner functionality
- Enhanced documentation with comprehensive docstrings
- Removed the monolithic
aeolis/gui.pyfile (2,688 lines deleted)
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 29 comments.
Show a summary per file
| File | Description |
|---|---|
| aeolis/gui/visualizers/wind.py | New module handling wind input visualization (time series and wind rose) with PNG export |
| aeolis/gui/visualizers/output_2d.py | New module for 2D NetCDF output visualization with PNG/MP4 export |
| aeolis/gui/visualizers/output_1d.py | New module for 1D transect visualization with held plots and animation export |
| aeolis/gui/visualizers/model_runner.py | New module for executing AeoLiS simulations with real-time logging |
| aeolis/gui/visualizers/domain.py | New module for domain setup visualization (bed, vegetation, etc.) |
| aeolis/gui/visualizers/init.py | Package initialization exporting visualizer classes |
| aeolis/gui/utils.py | Centralized utilities and constants (259 lines) |
| aeolis/gui/application.py | Main GUI application class refactored to use modular visualizers (1,480 lines) |
| aeolis/gui/init.py | Package initialization for backward compatibility |
| aeolis/gui/main.py | Entry point launcher for the GUI |
| aeolis/gui.py | Original monolithic file removed (-2,688 lines) |
| REFACTORING_SUMMARY.md | Documentation of refactoring work and metrics |
| GUI_REFACTORING_ANALYSIS.md | Analysis and recommendations document |
| ADDITIONAL_IMPROVEMENTS.md | Proposed future improvements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if progress_window.winfo_exists(): | ||
| progress_bar['value'] = frame_num + 1 | ||
| progress_window.update() | ||
| except: |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
aeolis/gui/gui_tabs/output_2d.py
Outdated
| try: | ||
| if progress_window.winfo_exists(): | ||
| progress_window.destroy() | ||
| except: |
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
@copilot rename the visualisers folder to gui_tabs and adapt the code accoordingly keeping identical functionality. |
Co-authored-by: Sierd <[email protected]>
Completed! Renamed Changes made:
Structure: Verification: Commit: 346b3e7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aeolis/gui/gui_tabs/output_2d.py
Outdated
| HILLSHADE_AZIMUTH, HILLSHADE_ALTITUDE, | ||
| NC_COORD_VARS, VARIABLE_LABELS, VARIABLE_TITLES, |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'HILLSHADE_AZIMUTH' is not used.
Import of 'HILLSHADE_ALTITUDE' is not used.
Import of 'VARIABLE_LABELS' is not used.
Import of 'VARIABLE_TITLES' is not used.
| HILLSHADE_AZIMUTH, HILLSHADE_ALTITUDE, | |
| NC_COORD_VARS, VARIABLE_LABELS, VARIABLE_TITLES, | |
| NC_COORD_VARS, |
| if progress_window.winfo_exists(): | ||
| progress_bar['value'] = frame_num + 1 | ||
| progress_window.update() | ||
| except: |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
aeolis/gui/gui_tabs/output_2d.py
Outdated
| try: | ||
| self.output_colorbar_ref[0].update_normal(im) | ||
| self.output_colorbar_ref[0].set_label(cbar_label) | ||
| except: |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
| except: | |
| except Exception: |
| if progress_window.winfo_exists(): | ||
| progress_bar['value'] = frame_num + 1 | ||
| progress_window.update() | ||
| except: |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
aeolis/gui/gui_tabs/output_2d.py
Outdated
| try: | ||
| if 'progress_window' in locals() and progress_window.winfo_exists(): | ||
| progress_window.destroy() | ||
| except: |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except block directly handles BaseException.
| except: | |
| except Exception: |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
* add wind plotting functionality * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]>
* add wind plotting functionality * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation * Phase 2: Extract helper methods and reduce code duplication * Phase 3: Add variable label/title constants and improve docstrings * Final: Add comprehensive refactoring documentation and summary * Add export functionality: PNG and MP4 animations for all visualizations * Phase 4: Begin code organization - extract utils module and create gui package structure * Add comprehensive additional improvements proposal document * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py * Update aeolis/gui/application.py * Update aeolis/gui/visualizers/domain.py * Update aeolis/gui/visualizers/domain.py * Update aeolis/gui/main.py * Update aeolis/gui/visualizers/output_2d.py * Apply suggestions from code review * Rename visualizers folder to gui_tabs and update all imports * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review --------- --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]>
#268) * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * Delete ADDITIONAL_IMPROVEMENTS.md * deleted md files --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]>
* Gui v0.2 added (#264) * add wind plotting functionality * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * removed Carcans from Main * Refactor GUI: Complete modular architecture with all GUI tabs extract… (#268) * Refactor GUI: Complete modular architecture with all GUI tabs extracted, export functionality, and utilities (#263) * Initial plan * Phase 1: Add constants, utility functions, and improve documentation Co-authored-by: Sierd <[email protected]> * Phase 2: Extract helper methods and reduce code duplication Co-authored-by: Sierd <[email protected]> * Phase 3: Add variable label/title constants and improve docstrings Co-authored-by: Sierd <[email protected]> * Final: Add comprehensive refactoring documentation and summary Co-authored-by: Sierd <[email protected]> * Add export functionality: PNG and MP4 animations for all visualizations Co-authored-by: Sierd <[email protected]> * Phase 4: Begin code organization - extract utils module and create gui package structure Co-authored-by: Sierd <[email protected]> * Add comprehensive additional improvements proposal document Co-authored-by: Sierd <[email protected]> * bugfixes related to import and animattion functionality * updated structure for further refactoring * Refactor: Extract DomainVisualizer and rename gui_app_backup.py to application.py Co-authored-by: Sierd <[email protected]> * bugfix * bugfix on loading domain * Refactor: Extract WindVisualizer to modular architecture Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output2DVisualizer for 2D NetCDF visualization Co-authored-by: Sierd <[email protected]> * Refactor: Extract Output1DVisualizer - Complete modular architecture achieved! Co-authored-by: Sierd <[email protected]> * bugfixes loading files * removed netcdf check * bugfixes after refractoring * bugfixes with domain overview * Speeding up complex drawing * hold on functionality added * Tab to run code added. * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/application.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/domain.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/main.py Co-authored-by: Copilot <[email protected]> * Update aeolis/gui/visualizers/output_2d.py Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Rename visualizers folder to gui_tabs and update all imports Co-authored-by: Sierd <[email protected]> * bigfixes related to refactoring * reducing code lenght by omitting some redundancies * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> * Delete ADDITIONAL_IMPROVEMENTS.md * deleted md files --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Sierd <[email protected]> Co-authored-by: Copilot <[email protected]>
Refactored
gui.pyfor improved readability and maintainability while preserving identical functionality. Eliminated magic numbers, centralized repeated patterns, improved documentation, added comprehensive export capabilities, and completed full modular package structure with all 4 GUI tab modules extracted into dedicated files.Changes
Constants Extraction
VARIABLE_LABELSandVARIABLE_TITLESdictionaries for consistent variable naming across plotsUtility Functions
resolve_file_path()/make_relative_path()- Centralized file path resolution logic (used 10+ times)determine_time_unit()- Automatic time unit selection based on simulation durationextract_time_slice()- Unified data slicing for 3D/4D arraysExport Functionality (NEW)
Complete Modular Architecture (NEW)
gui_app_backup.py→application.py(main GUI coordinator)gui_tabs/folder (100% complete)gui_tabs/domain.py(323 lines) - Domain setup visualizationDomainVisualizerclass with plot_data(), plot_combined(), export_png()gui_tabs/wind.py(313 lines) - Wind input visualizationWindVisualizerclass with load_and_plot(), plot_windrose(), export functionsgui_tabs/output_2d.py(389 lines) - 2D NetCDF output visualizationOutput2DVisualizerclass with load_and_plot(), update_plot(), export functionsgui_tabs/output_1d.py(370 lines) - 1D transect output visualizationOutput1DVisualizerclass with load_and_plot(), update_plot(), export functionsgui_tabs/model_runner.py- Model execution managementgui/utils.py(259 lines) containing all constants and utility functionsapplication.pyreduced from 3,031 to 1,381 lines (-1,650 lines, -54.4%)Example
Before:
After:
Impact
gui_tabs/folder:Documentation
GUI_REFACTORING_ANALYSIS.md- Initial analysis with detailed recommendationsREFACTORING_SUMMARY.md- Summary of completed refactoring workADDITIONAL_IMPROVEMENTS.md- Prioritized proposals for 13 additional improvements including keyboard shortcuts, batch export, configuration validation, plot templates, and moreFinal Package Structure
Architecture Benefits
gui_tabs/foldergui_tabs/folder accurately reflects the GUI tab structureAll changes maintain 100% backward compatibility with the original
gui.pyinterface.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.