Skip to content

Performance Diagnostics #1128

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

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
Draft

Performance Diagnostics #1128

wants to merge 13 commits into from

Conversation

AdvancedImagingUTSW
Copy link
Collaborator

This pull request draft introduces a new diagnostics popup feature for performance monitoring, adds supporting infrastructure, and improves logging and documentation.


@annie-xd-wang - I wanted to see if there were particular points in the code that you were hoping to monitor. If so, we can add the appropriate regular expressions to pull out the time it takes to execute that section of code, and we can populate a histogram or line plot in this popup.

I also wanted to see if there was a better way to capture screenshots of our GUI. Our documentation is increasingly out of date, and I thought it would be nice to automate capturing screenshots. I added a new dependency to do this, but I then realized that PIL provides the basic functionality needed and that additional dependency may not be necessary.

So, don't merge, but I would love your feedback on what we should monitor. The time necessary to save the data is another area that could be valuable.


New Diagnostics Popup Feature:

  • Added the new DiagnosticsPopupController class, which manages a diagnostics popup window for visualizing performance metrics from log files. This includes methods for displaying, updating, and saving diagnostic plots, and is integrated with the application's logging system. (src/navigate/controller/sub_controllers/diagnostics_popup.py)
  • Registered DiagnosticsPopupController in the sub-controller initialization and imported the corresponding view class. (src/navigate/controller/sub_controllers/__init__.py, src/navigate/controller/sub_controllers/menus.py) [1] [2] [3]
  • Integrated the diagnostics popup into the application menu, adding a "Performance Diagnostics" menu item and the logic to open the popup, ensuring only one instance is active at a time. (src/navigate/controller/sub_controllers/menus.py) [1] [2]

Logging and Diagnostics Improvements:

  • Added info-level logging to the histogram population process, recording the time taken to populate histograms for performance diagnostics. (src/navigate/controller/sub_controllers/histogram.py) [1] [2] [3]
  • Improved log message clarity when receiving images in the controller. (src/navigate/controller/controller.py)

Documentation and Dependency Updates:

  • Added a new example script docs/capture_gui.py to automate capturing screenshots of various GUI windows and tabs. (docs/capture_gui.py)
  • Updated pyproject.toml to include the mss package (for screenshot functionality) and fixed formatting in the docs dependencies list. (pyproject.toml) [1] [2]

Minor Code Quality Improvements:

  • Minor formatting and style cleanups in controller initialization and thread pool usage. (src/navigate/controller/controller.py) [1] [2]
  • Removed unused inner function from log file management. (src/navigate/log_files/log_functions.py)

Introduced docs/capture_gui.py for automated screenshot capture of GUI components using mss and tkinter. Updated pyproject.toml to include 'mss' in the docs dependencies.
Introduces a new DiagnosticsPopupWindow class that displays six diagnostic plots (e.g., latency, FPS, memory usage) in a resizable popup using matplotlib and Tkinter. Also updates ChannelCreator's defocus spinboxes to set min, max, and increment values for improved input validation.
Introduces performance diagnostics, including histograms for image display, histogram update, stage move, and image acquisition times, parsed from log files. Adds a button to save a screenshot of the diagnostics popup.
Copy link

codecov bot commented Aug 19, 2025

Codecov Report

❌ Patch coverage is 34.23729% with 194 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.63%. Comparing base (5fb486e) to head (7f1a0b0).

Files with missing lines Patch % Lines
...te/controller/sub_controllers/diagnostics_popup.py 19.81% 89 Missing ⚠️
src/navigate/view/popups/diagnostics_popup.py 23.52% 39 Missing ⚠️
src/navigate/log_files/log_functions.py 44.68% 26 Missing ⚠️
src/navigate/tools/gui.py 0.00% 13 Missing ⚠️
src/navigate/model/features/common_features.py 56.52% 10 Missing ⚠️
src/navigate/model/devices/device_types.py 65.21% 8 Missing ⚠️
src/navigate/controller/sub_controllers/menus.py 25.00% 6 Missing ⚠️
src/navigate/model/device_startup_functions.py 33.33% 2 Missing ⚠️
...c/navigate/controller/sub_controllers/histogram.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1128      +/-   ##
===========================================
- Coverage    53.93%   53.63%   -0.30%     
===========================================
  Files          191      194       +3     
  Lines        21953    22198     +245     
===========================================
+ Hits         11840    11906      +66     
- Misses       10113    10292     +179     
Flag Coverage Δ
unittests 53.63% <34.23%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

annie-xd-wang and others added 8 commits August 19, 2025 14:22
Introduces a custom PERFORMANCE log level and handler, updates logging configuration to support performance logs, and refines the PerformanceFilter logic. Improves type annotations and docstrings in diagnostics_popup.py, adjusts screenshot capture to use the correct widget, and resizes diagnostic.
Added type annotations and expanded docstrings for DeviceBase and SerialDevice classes.
Now inherits from Serial library and overwrites readline and write methods to include logging. Need to test.
Different approach to logging serial communication.
Will test with ASI Tiger Controller next...

Also added the logic necessary to round the stage values before reporting them. I was getting floats with ~10 decimal places...
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.

2 participants