dtale icon indicating copy to clipboard operation
dtale copied to clipboard

Need help for deploying Dtale in production

Open sourav9599 opened this issue 2 years ago • 3 comments

I've created a Flask app with Dtale using build_app from dtale.app, which includes other routes. To isolate Dtale instances for different users from my frontend, I'm using sessions.

ISSUE: Clicking on the 'instances' button in the Dtale UI allows me to view and delete running instances from different user sessions, which is not ideal. What can I do to prevent this?

According to my research, creating a Docker container is recommended to isolate the backend for each user session. Are there any alternative approaches to address this issue?

sourav9599 avatar Feb 22 '23 12:02 sourav9599

@sourav9599 one thing I can think of would be to override the /dtale/processes endpoint (code here) where it would filter the data returned by the base endpoint based on the user contained within the session. If you create your own /dtale/processes endpoint then it should take precedence over the D-Tale route.

The way the filtering could work is that when you add a new piece of data to D-Tale within your app you can add the username to the name property and then filter them by any instances with that user's name in the name property. You can set the name like this:

import dtale.global_state as global_state
from dtale.views import startup

data_id = global_state.new_data_inst()
instance = startup(data=df, ignore_duplicate=True, data_id=data_id, name="{}{}".format(username, data_id))

I'm not really sure how the Docker container approach would work, but if you could come with something using kubernetes that would spin up a D-Tale process on demand for each user and kill it after some period of inactivity then that might solve your problem. That being said, I don't know how this would be accomplished.

aschonfeld avatar Feb 22 '23 19:02 aschonfeld

I have it running for my team in a docker swarm with traefik which makes it somewhat doable with sticky sessions and a limit of one user per replica. Only problem is how to properly clear Dtale when a user have left their session unvisited for prolonged time

jakob1379 avatar Jul 07 '23 20:07 jakob1379

@jakob1379 Thanks for the solution, I will definitely look into this!!

sourav9599 avatar Jul 09 '23 16:07 sourav9599