Skip to content
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

Need help for deploying Dtale in production #731

Open
sourav9599 opened this issue Feb 22, 2023 · 3 comments
Open

Need help for deploying Dtale in production #731

sourav9599 opened this issue Feb 22, 2023 · 3 comments

Comments

@sourav9599
Copy link

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?

@aschonfeld
Copy link
Collaborator

aschonfeld commented Feb 22, 2023

@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.

@jakob1379
Copy link

jakob1379 commented Jul 7, 2023

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

@sourav9599
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants