-
Notifications
You must be signed in to change notification settings - Fork 147
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
Rerun Vizro Dashboard in Jupyter doesn't work #109
Comments
Hey @noklam, thanks so much for getting in touch :) I was able to reproduce this issue in parts (dashboard not rendering), and it is indeed a bug. We are working on a smoother Jupyter experience already (see #65), but it looks like that the short term solution described in this issue does not capture this case. So in the short term we would recommend going via the approach of restarting the kernel, this is as you say slower, but the most reliable method. We will get back once there is a more comprehensive solution. In the meantime, could I ask you whether you receive the above error message after resetting both managers, and rerunning the shown cell again? This is how I tried to reproduce it, and for me the dashboard does not render, but I also do not get an error message. You mentioned that "no error is raised", so just want to check whether I am seeing the same thing, or I should be seeing the error in the screenshot |
Reproducing this error works, although atm the error message does not show for me. Code can be found at: https://github.com/mckinsey/vizro/tree/bug/109 Observations:
|
I ran into this issue too. If you open up the browser dev tools, you'll see that the Dash renderer is throwing a duplicate callback issue. This is caused by some global state about registered callbacks that is shared across the entire As already mentioned, there's also some global state for Dash Page registry, and also for Page config. These should be reset too. I ran into this when adding tests for the Pages feature, where this global state was interfering with subsequent tests, so added this fixture to clear the global Pages state. Putting it all together, here's a recipe for clearing (hopefully) everything, and which allows the demo app to be re-run when you call the function at the top of the cell containing the app: import dash
from vizro.managers import data_manager, model_manager
def reset_state():
data_manager._reset()
model_manager._reset()
dash._callback.GLOBAL_CALLBACK_LIST = []
dash._callback.GLOBAL_CALLBACK_MAP = {}
dash._pages.PAGE_REGISTRY.clear()
dash._pages.CONFIG.clear()
dash._pages.CONFIG.__dict__.clear() |
Hello @ned2 and thank you very much for the tip! I've seen your name pop up a lot when I read the plotly forums and so it's amazing to see you here 😀 I'm just curious how you found out about vizro in the first place? As you can see we've been on a similar journey trying to reset the dash page registry in a test fixture but couldn't find a way to clear the whole thing. Given what you recommend above I presume there's no way to do it with Also in the @huong-li-nguyen looks like what @ned2 above is the right way to do this test fixture 🎉 @maxschulz-COL I think we should rename |
heya @antonymilne! I heard about vizro essentially by word of mouth. Someone shared it on the viz channel of a slack community I hangout in. Really love what y'all are working on here!! Unfortunately there's not an interface for clearing any of the global state in the Given that Dash is already implicitly making the assumption that users won' be creating multiple Dash instances within the same process, I think there's a strong argument to be made that Dash itself should lean into actively making the one instance-per-process assumption and remove this footgun by explicitly clearing all global state in the Oh yes, in that fixture in the Dash repo, the reason I cleared the state before and after the test contents are run. The tests I added were apparently the first tests sensitive to existing stale global Page state and I didn't want to assume that people would know to add this decorator to tests that mutated the registry. So essentially I was protecting my new tests from being impacted by other tests. The initial call could be removed if you new that every other text was required to use the same fixture. Again, this would all be a non-issue if the |
Thanks for all the comments @ned2 - it's super helpful. Given what you say I'd be tempted to add the code that resets the Dash globals to our own Just to add to the above: we'll also need to clear Great point about checking how
|
yeah that's a good question. I dug into this, and it looks like Dash itself clears the contents of So that seems to be how stale values in As for why it's not working in Vizro. I poked around using a funky tool I found to observe when When using Dash Pages, on app init, inside So TLDR it sounds like the root cause of the problem is that the |
Implemented a Thanks again @ned2 for your valuable insights. We will make sure to build upon this for a solution that eventually may not even require a code-snippet at the top of a cell. |
@ned9 That makes sense, thank you very much for digging into it! I hadn't seen watchpoints before and that looks like it will be very handy for this sort of thing. Do you think that the Dash class itself should be clearing the If we do move the
FYI @petar-qb what @ned9 says above about callback registration is very useful to know! |
Reopen for visibility |
Does anyone know anything about the error |
Description
'from vizro.managers import data_manager; data_manager._reset()`. After I follow the instruction and rerun the cell, I run into a new error.
After I run 'from vizro.managers import model_manager; model_manager._reset()`, no error is raised but it doesn't show the dashboard UI anymore.
Expected behavior
I expect the dashboard render properly. Workaround is restart the Kernel which work fine but is considerably slower.
vizro version
0.1.4
Python version
3.8.5
OS
MacOS
How to Reproduce
Follow the tutorial and run it in a notebook twice.
https://vizro.readthedocs.io/en/stable/pages/tutorials/first_dashboard/#4-explore-further
Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: