-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
support circular dependencies #889
Comments
This is an interesting idea; how would this look in practice? Would each callback’s props and their values optionally appear in the stack trace — just before the sequence of calls which follows them? |
Something like that - probably in an expandable section. I think we should be able to manage all this purely on the front end, without needing to send anything new (or make any code changes) to the back ends. |
👍 . There is also a case for using circular dependencies to sync up There's another use case around crossfiltering - with the right property design, syncing or providing the union of selected points could be a lot simpler. I wrote about some of these use cases in #844. |
Ah thanks @chriddyp - I forgot about #844, really nice collection of use cases. We could merge the two issues if you like, though TBH it might be easier to leave that one as a smörgåsbord to pick and choose from and have the discussion over here. I feel like
But also:
|
Just came across a use case for this - Actually, perhaps there's an easy solution at the component level: clear Seems like that approach would work for other imperative props, as long as there's a suitable noop value to assign it (could be |
@chriddyp "There is also a case for using circular dependencies to sync up dcc.Store with controls so that you can access the the control values (via dcc.Store) in separate tabs or pages. It'd be circular so that when you'd render the initial page, dcc.Store would sync the value back to the original component." Has there been any updates on circular dependencies and |
In order to allow cycles in the graph yet avoid infinite loops in the callbacks, could the following "marking" solution work ?
I haven't tested the logic but I could do it (in python with synthetic dependency graphs) if needed. |
I would also be very interested in a generic solution :). Until then, i have made a custom
The syntax is more involved than a native solution though, and only components in the |
+1. I am also interested in this. |
What about a much more limited approach:
For something like a linked slider and input, the paradigm would be to pass both values as Inputs and Outputs and use The advantages to this approach are:
|
I would be very interested in it as well. My use case is the following: I run python code in a container and, as a result, I get an iterator that gives standard output as it comes. I need to visualize this stream into the app. I am trying to do this via two callbacks that call each other with this iterator (not hashable) being a global variable. Maybe there is a better way to do this. UPDATE: I found the answer here: https://community.plotly.com/t/how-to-turn-off-interval-event/5565/7 |
Circular deps keep coming up. Most of the use cases I've seen are fairly simple, like 2 alternate ways to accomplish the same task, that you want to keep in sync. For example today on the community board someone asked the perfectly reasonable question of how to make the selected tab reflected in the url, and vice versa so you could load your app with the desired tab open. https://community.plot.ly/t/combining-dcc-tabs-and-dcc-location/27831
The code they tried seems like the natural way to do it, but fails as it requires a circular dependency between
Location.pathname
andTabs.value
. I don't see a simple alternative. We could make one using patterns we've used elsewhere (like adding a*_timestamp
prop to one of these components, or havingLocation.pathname
updatehref
and vice versa, which it should arguably do) but this feels hacky and fragile - it's making an explicit circular ref into an implicit one that may make infinite loops that are hard to debug and even harder to fix.My proposal: create a new
dash.dependencies
class, tentativelyCircularOutput
, by which users could specify that this particular output may be in a circular dependency chain. Then in the renderer we would:CircularOutput
Interval
components) to the output. This would be useful anyway to show with the stack trace when debugging errors.CircularOutput
is changed, look back at this chain; if the sameCircularOutput
is already in the chain (meaning this would be its second change in response to the same stimulus) consider this a possible infinite loop and throw an error.The text was updated successfully, but these errors were encountered: