Open
Conversation
zhan4329
reviewed
Apr 3, 2026
Contributor
zhan4329
left a comment
There was a problem hiding this comment.
Hi. Can I ask why we are deleting those comments and docstrings? I think we'd better keep them for better code readability, while docstrings are also required by the CONTRIBUTING.md?
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.
Features:
Global cancel buttons using async plot rendering with thread. Generated Plots can have the image download in PNG format.
Overview
Decouples all visualization computations from the Shiny reactive loop by running them in background workers and adding a unified cancellation system across every panel. Button added to Plotly plots to allow users to save the plot on their computer.
Changes
utils/plot_manager.py:
New PlotManager class manages the full worker lifecycle (spawn, poll, cancel, download buttons). Each instance registers in shared['plot_registry'] so app.py has a single control point over all active renders.
app.py:
Cancel_plot() and STOP_BUTTON_MAP replace per-module cancellation logic. Every stop button delegates to one handler; adding cancellation to a new visualization requires no changes here.
Server modules:
All ten files follow a consistent start/poll/render pattern that utilizes the utils/plot_manager.py file. Matplotlib plots run in multiprocessing. Process workers (hard-killable, return PNG bytes); Plotly plots run in threading. Thread workers (Plotly objects can't be pickled across a process boundary).
UI modules:
Every panel gains a stop button (visible only during computation) and PNG/CSV download buttons where applicable (visible only after plot is generated). Matplotlib output slots changed from output_plot to output_image to match the PNG bytes return path.
Testing
The plot download functionality works across all supported visualizations, and the cancel render button successfully allows a new graph to be generated for every plot type once pressed. Cancelation/Downloading of a plot stays distinct to the current tab plot and does not accidentally stop previously built plots or interact with other plots. Docker logs appear stable, with no noticeable bugs or errors.
Notes
Thread cancellation is UI-only due to the global nature of this feature. Plotly threads can’t be killed from outside, so the background thread runs to completion before discarding its result. A Plotly-specific implementation can be included in future updates.
Currently Plot downloading is only in a distinct button for plotly build plots. Generated Plots that uses Shiny Widgets (Boxplots, anno vs anno, scatterplot) have a pre built button so that the plot can be downloaded, however, users are not guided/informed on how to access this feature by the website itself in a direct manner (No text/button indication).