man-group / dtale

Visualizer for pandas data structures
http://alphatechadmin.pythonanywhere.com
GNU Lesser General Public License v2.1
4.78k stars 405 forks source link

Not able to run Dtale on root url #805

Closed go-kool closed 1 year ago

go-kool commented 1 year ago

Hi Team,

We have a requirement to run the multiple Dtale serives in one docker container. So we are planning to run each dtale service with a unique app-root and port. Below is my code looks like.

import dtale import pandas as pd d = dtale.show(pd.DataFrame([1,2,3,4,5]),host='localhost',app_root="/satya",port="40000") d._main_url

d1 = dtale.show(pd.DataFrame([1,2,3,4,5]),host='localhost',app_root="/test",port="40001") d1._main_url

Below is the error we are getting when accessing the dtale url. image

we are not sure if this is an issue or not. Please suggest us if we need to make any changes.

aschonfeld commented 1 year ago

So app_root is something that is meant to be used when serving D-Tale up within jupyerhub. There is a server proxy that opens up all flask routes using a different URL path.

I can try seeing if I can make use of Flask's url_prefix parameter, but honestly your best bet is to do something like using different ports (i think you just need to open both ports in your docker configuration):

import dtale
import pandas as pd
d = dtale.show(pd.DataFrame([1,2,3,4,5]),host='localhost', port="40000")
d._main_url

d1 = dtale.show(pd.DataFrame([1,2,3,4,5]),host='localhost', port="40001")
d1._main_url

Or you can apply names to your data:

import dtale
import pandas as pd
d = dtale.show(pd.DataFrame([1,2,3,4,5]),host='localhost', name="satya")
d._main_url  # http://localhost:40000/dtale/main/satya

d1 = dtale.show(pd.DataFrame([1,2,3,4,5]),host='localhost', name="test", ignore_duplicate=True)
d1._main_url  # http://localhost:40000/dtale/main/test
go-kool commented 1 year ago

Thanks for the suggestion @aschonfeld its really helpfull, I tried giving names to data and its working good. But i getting some Bad request errors in my jupyter notebook continuously, however I am able to access the Dtale with the urls below. http://localhost:40000/dtale/main/satya http://localhost:40000/dtale/main/test

Is there any way we can do this without errors ? image

aschonfeld commented 1 year ago

Are you hitting the D-Tale URLs from https? I've never seen that error and the only thing I can find about it is when someone tries to hit a flask endpoint from https that is only setup for http: https://stackoverflow.com/questions/58902838/python-flask-error-code-400-message-bad-request-version

go-kool commented 1 year ago

@aschonfeld I getting the error as soon as I run the second cell attached in the above screenshot. I am accessing it on http.

aschonfeld commented 1 year ago

So I was able to run your code in a jupyter notebook with no issue. Is your notebook running under HTTPS?

go-kool commented 1 year ago

@aschonfeld Yes, Its running inside Kubenertes clusters and exposed using ingress on Https

aschonfeld commented 1 year ago

ok then thats the problem. Do you have to use HTTPS?

nandinibalusu978 commented 1 year ago

@aschonfeld Yes, We need to run our service on https only

aschonfeld commented 1 year ago

So what I plan on doing is exposing the ability to specify an ssl_context when starting up the flask process invoked by dtale.show. This way you can call something like dtale.show(..., ssl_context="adhoc") and it should allow you to use HTTPS.

I'll keep you posted about when this change gets released

aschonfeld commented 1 year ago

@go-kool @nandinibalusu978 just released v3.6.0 to pypi (should be on conda-forge soon) with this fix included.

Also, if you haven't already, please put your ⭐ on the repo when you get a sec. Thanks! 🙏