man-group / dtale

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

Dtale flask in pythonanywhere #650

Closed eriksdev1 closed 1 year ago

eriksdev1 commented 2 years ago

Please forgive me if I'm requesting help here also, as this the project's home. How can I load data into a flask-dtale app (csv file)

Hello I have seen the site working with the dtale library: http://alphatechadmin.pythonanywhere.com/dtale/main/1

and I even tried the example (taken from reddit) image But I had no success by the way I got this error while using the embedded example: bs4.FeatureNotFound in server:8080/load-players image

I'm unable to replicate how it works, I can't load a csv file I uploaded to pythonanywhere, I found a forum post saying you need to use the full path in pythonanywhere: /home/USER/mysite/data/ for example

But still I'm unable to figure this out with the documentation example code:

@app.route("/dtale") def dtalepage(): mytitle = "Analysis with dtale library" df = pd.read_csv('/home/erikssawa/mysite/data/engine_metadata.csv') instance = startup(data=df, ignore_duplicate=True) return redirect(f"/dtale/main/{instance._data_id}", code=302)

I get the error The requested URL was not found on the server.

My file structure is:

├── flask_app.py

├── static

│---------├── bootstrapfiles, javascript, images dir

├── templates

│---------├──index.html, about.html, dtalepage.html

├── data

│-------├── csv files

full flask_app.py code to copypaste https://pastebin.com/8AL0rR7n

Any hints onto how to configure the routes, redirecting or whatever is necessary would be great

Any help is much appreciated

aschonfeld commented 2 years ago

@eriksdev1 so looks like there may have been packages updates as well as updates to the website my app was parsing. I have updated the app.py code to handle the changes baseball-reference has made to their website and you can view them here.

In addition to pulling down the latest code you'll have to do a pip install lxml on the virtual environment you're running your code. That should solve the bs4.FeatureNotFound error.

Let me know if you're still having issues after those updates.

eriksdev1 commented 2 years ago

Hello @aschonfeld many thanks for replying and updating code, I was able to reproduce the example as the reddit gif but unable to use the data, any hits are welcome (when I try to manipulate the data nothing happens, is like the data is just visible but can't be accessed) I attach a gif. I also have a question, can the hiding main menu bar be made not to hide ? Many thanks. DataNotLoading

aschonfeld commented 2 years ago

@eriksdev1 which browser are you using? I'm using chrome and everything seems to work as expected. Thanks

eriksdev1 commented 2 years ago

Hello, many thanks for replying, yes I'm also using chrome, for some reason the data is just seen in the grid but is not letting be manipulated by dtale I'm using Version 99.0.4844.82 (Official Build) (64-bit)

aschonfeld commented 2 years ago

Would you be willing to send me your console output from the developer toolbar? Without it I'm kind of at a loss since everything works for me. So you can do that by doing the following:

The console looks like this area at the bottom:

image
eriksdev1 commented 2 years ago

I was able to save the log to this, many many thanks for looking into this 192.168.0.9-1648135939206.log some are: image

aschonfeld commented 2 years ago

Thanks for the extra detail. So those errors make no sense to me at all. Those network calls work fine for me. On thing I noticed is that in your original post you had the following code snippet:

@app.route("/dtale")
def dtalepage():
    mytitle = "Analysis with dtale library"
    df = pd.read_csv('/home/erikssawa/mysite/data/engine_metadata.csv')
    instance = startup(data=df, ignore_duplicate=True)
    return redirect(f"/dtale/main/{instance._data_id}", code=302)

Do you still have something like this in your code? Because if so re-using the "dtale" (@app.route("/dtale")) route will definitely cause problems. I'd change it to something like @app.route("/dtale-loader")

eriksdev1 commented 2 years ago

Oh ok, I will try running the app changing the route to @app.route("/dtale-loader") Also, I was running the example from the insde the whole downloade repo folder, I have also installed several packages with the normal pip install, ... (not using a venv), I will try using a venv and report shortly and using this folders image

eriksdev1 commented 2 years ago

Hi, well maybe versions are the problem, just a hunch, I still get errors: image image Can I ask for a requirements.txt file, I'm new to this and maybe using the same versions you are using could help, sadly I have been unable to make this run, really appreciate the help

aschonfeld commented 2 years ago

So those errors you're getting in to console are expected. I get the same ones, they're just side-effect with how plotly dash handles hidden elements. When I run my version of this app I'm using a python 3.8 environment (created using pyenv) and here's all the packages I have installed:

aiohttp==3.7.4.post0
alembic==1.6.5
altair==4.1.0
anyio==3.3.0
appdirs==1.4.4
appnope==0.1.2
argon2-cffi==20.1.0
astor==0.8.1
asttokens==2.0.5
async-generator==1.10
async-timeout==3.0.1
attrs==21.2.0
backcall==0.2.0
base58==2.1.0
beautifulsoup4==4.9.3
black==20.8b1
bleach==3.3.0
blinker==1.4
bokeh==2.4.0
bqplot==0.12.31
Brotli==1.0.9
bs4==0.0.1
cachetools==4.2.2
certifi==2021.5.30
certipy==0.1.3
cffi==1.14.5
chardet==4.0.0
click==7.1.2
colorama==0.4.4
contextlib2==21.6.0
coverage==5.5
cryptography==3.4.7
cycler==0.10.0
dash==2.0.0
dash-bio==0.7.1
dash-bootstrap-components==0.13.1
dash-colorscales==0.0.4
dash-core-components==2.0.0
dash-daq==0.5.0
dash-html-components==2.0.0
dash-renderer==1.9.1
dash-table==5.0.0
debugpy==1.3.0
decorator==5.0.9
defusedxml==0.7.1
docutils==0.17.1
dtale==2.2.0
entrypoints==0.3
et-xmlfile==1.1.0
execnet==1.9.0
executing==0.8.2
flake8==3.9.2
Flask==2.0.1
Flask-Compress==1.10.1
flask-ngrok==0.0.25
future==0.18.2
gitdb==4.0.7
GitPython==3.1.18
greenlet==1.1.0
htmlmin==0.1.12
idna==2.10
ImageHash==4.2.1
importlib-metadata==4.6.1
iniconfig==1.1.1
ipykernel==6.0.2
ipython==7.31.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
itsdangerous==2.0.1
jedi==0.18.0
Jinja2==3.0.1
joblib==1.0.1
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.12
jupyter-console==6.4.0
jupyter-core==4.7.1
jupyter-server==1.10.1
jupyter-server-proxy==3.1.0
jupyter-telemetry==0.1.0
jupyterhub==1.4.2
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
kaleido==0.2.1
keyring==23.0.1
kiwisolver==1.3.1
lxml==4.8.0
lz4==3.1.3
Mako==1.1.4
Markdown==3.3.4
MarkupSafe==2.0.1
matplotlib==3.4.2
matplotlib-inline==0.1.2
mccabe==0.6.1
missingno==0.4.2
mistune==0.8.4
mock==4.0.3
multidict==5.1.0
multimethod==1.6
mypy-extensions==0.4.3
nbclient==0.5.3
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
networkx==2.6rc2
notebook==6.4.0
numpy==1.21.0
oauthlib==3.1.1
openpyxl==3.0.7
packaging==21.0
pamela==1.0.0
pandas==1.3.2
pandas-profiling==3.1.0
pandocfilters==1.4.3
panel==0.12.2
param==1.11.1
parso==0.8.2
path==16.0.0
path.py==12.5.0
pathspec==0.8.1
patsy==0.5.1
pexpect==4.8.0
phik==0.12.0
pickleshare==0.7.5
Pillow==8.3.0
pkginfo==1.7.1
plotly==5.1.0
pluggy==0.13.1
ppscore==1.2.0
prometheus-client==0.11.0
prompt-toolkit==3.0.19
protobuf==3.17.3
psutil==5.8.0
ptyprocess==0.7.0
pure-eval==0.2.1
py==1.10.0
pyarrow==5.0.0
pycodestyle==2.7.0
pycparser==2.20
pyct==0.4.8
pydantic==1.8.2
pydeck==0.7.0
pyflakes==2.3.1
Pygments==2.9.0
pyOpenSSL==20.0.1
pyparsing==3.0.0b2
pyrsistent==0.18.0
pytest==6.2.4
pytest-cov==2.12.1
pytest-fixture-config==1.7.0
pytest-server-fixtures==1.7.0
pytest-shutil==1.7.0
python-dateutil==2.8.1
python-editor==1.0.4
python-json-logger==2.0.1
pytz==2021.1
pyviz-comms==2.1.0
PyWavelets==1.2.0
PyYAML==5.4.1
pyzmq==22.1.0
qtconsole==5.1.1
QtPy==1.9.0
readme-renderer==29.0
redis==3.5.3
redislite==6.0.674960
regex==2021.7.5
requests==2.25.1
requests-toolbelt==0.9.1
requests-unixsocket==0.2.0
retry==0.9.2
rfc3986==1.5.0
rpy2==3.4.5
ruamel.yaml==0.17.10
ruamel.yaml.clib==0.2.6
scikit-learn==0.24.2
scipy==1.7.0
seaborn==0.11.1
Send2Trash==1.7.1
simpervisor==0.4
six==1.16.0
smmap==4.0.0
sniffio==1.2.0
soupsieve==2.2.1
SQLAlchemy==1.4.21
squarify==0.4.3
stack-data==0.1.3
statsmodels==0.12.2
streamlit==0.87.0
strsimpy==0.2.0
tangled-up-in-unicode==0.1.0
tenacity==7.0.0
termcolor==1.1.0
terminado==0.10.1
testpath==0.5.0
threadpoolctl==2.1.0
toml==0.10.2
toolz==0.11.1
tornado==6.1
tqdm==4.61.2
traitlets==5.0.5
traittypes==0.2.1
twine==3.4.1
typed-ast==1.4.3
typing-extensions==3.10.0.0
tzlocal==2.1
urllib3==1.26.6
validators==0.18.2
visions==0.7.4
voila==0.2.16
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.1.0
Werkzeug==2.0.1
widgetsnbextension==3.5.1
xarray==0.18.2
xlrd==2.0.1
yarl==1.6.3
zipp==3.5.0

Hope this helps

aschonfeld commented 1 year ago

@eriksdev1 i just fixed a bug with the charts where they weren’t rendering because of how google colab’s proxy was handling requests #692. If you update your doe to have the following it may solve your issue:

import dtale.app as dtale_app

dtale_app.USE_COLAB = True

Let me know if this helps and I can try and update that solution to be a little more widely available. Thanks

aschonfeld commented 1 year ago

Closing due to lack of activity