plotly / Dash.jl

Dash for Julia - A Julia interface to the Dash ecosystem for creating analytic web applications in Julia. No JavaScript required.
MIT License
486 stars 41 forks source link

Implement background callbacks #236

Open BeastyBlacksmith opened 5 months ago

BeastyBlacksmith commented 5 months ago

I am inclined to try adding support for long callbacks. But some guidance would be greatly appreciated, I think I can copy most of the logic and structure from the python version, but its not yet clear to me where I can find what the target structure needs to be and how exactly the julia <-> javascript communication works.

For the manging of a cache it would probably make sense to use some julia native caching or should we use the same python cache as in the docs?

etpinard commented 5 months ago

Would close https://github.com/plotly/Dash.jl/issues/213.

Cross-referencing https://github.com/plotly/Dash.jl/issues/200


Thanks very much @BeastyBlacksmith for looking into this!

I wrote down some basic info on the background callback implementation in python dash over in https://github.com/plotly/Dash.jl/issues/213 to help us get started.


To answer

but its not yet clear to me where I can find what the target structure needs to be and how exactly the julia <-> javascript communication works.

Yep, this is key. We'll need to study the callbacks.ts file and investigate how the response payload container gets filled in the callback function. I haven't dedicated much time on this yet.

One potential way to make progress would be to inspect the JSON payload from the examples in the python dash test suite. There are probably test helpers routines in the python dash repo to help you do that.

For the manging of a cache it would probably make sense to use some julia native caching or should we use the same python cache as in the docs?

Yep, I would start with trying to implement a cache manager around some Julia on-disk caching library. I'm not familiar with the Julia on-disk caching ecosystem, so first making survey of all the different options would be nice.

Once that's done, we could start looking into ways to replicate the dash+Celery+Redis experience in Dash.jl.


I hope this helps. I'm looking forward to your contributions :smile:

BeastyBlacksmith commented 4 months ago

For on-disk caching we could use https://github.com/JuliaCollections/LRUCache.jl or https://github.com/LarsWl/LFUDACache.jl

On the serverside I found that they use this type

On the clientside they send a dict with the following keys:

etpinard commented 4 months ago

For on-disk caching we could use https://github.com/JuliaCollections/LRUCache.jl

Yep, that sounds like a solid choice.

BeastyBlacksmith commented 4 months ago

As far as I can see, that is only in memory caching though. But that might do it for now. What I am currently am stuck at is, that in the python code they get some keys via a flask.request. https://github.com/plotly/dash/blob/15e97b85d24461dfce907d038b7788db75d1f005/dash/_callback.py#L358-L360

what I got so far, is, that this reads the arguments from a URL, but how do I get this URL in the julia version?