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

FileDownload widget: Allow callback to update filename #1246

Merged
merged 3 commits into from
Apr 16, 2020
Merged

FileDownload widget: Allow callback to update filename #1246

merged 3 commits into from
Apr 16, 2020

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented Apr 8, 2020

Hi!

I've started to work on fixing #1236, to try to better understand the code I started with adding some more tests and error handling.

As I found a way to update the filename parameter from the callback as side-effect (this is what I intended to do in #1236), I've decided to submit this first batch of work as a PR.

I plan to submit another PR in the next days, trying to fix completely #1236.

(I was also hindered by these Model 'panel.models.widgets.FileDownload' does not exist errors while trying to launch a Bokeh server, error that is probably related to the recent problems around that, I'll try to update my setup and see how it goes).

@philippjfr
Copy link
Member

(I was also hindered by these Model 'panel.models.widgets.FileDownload' does not exist errors while trying to launch a Bokeh server, error that is probably related to the recent problems around that, I'll try to update my setup and see how it goes).

Let me know how that goes, I've still not been able to reproduce any of those issues myself.

@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #1246 into master will increase coverage by 0.40%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1246      +/-   ##
==========================================
+ Coverage   87.30%   87.71%   +0.40%     
==========================================
  Files         106      124      +18     
  Lines       12662    13228     +566     
==========================================
+ Hits        11055    11603     +548     
- Misses       1607     1625      +18     
Impacted Files Coverage Δ
panel/tests/widgets/test_misc.py 97.72% <100.00%> (+1.36%) ⬆️
panel/widgets/misc.py 90.90% <100.00%> (+8.24%) ⬆️
panel/io/state.py 80.32% <0.00%> (-9.87%) ⬇️
panel/viewable.py 68.69% <0.00%> (-8.69%) ⬇️
panel/io/notebook.py 58.64% <0.00%> (-0.48%) ⬇️
panel/util.py 85.94% <0.00%> (-0.15%) ⬇️
panel/__init__.py 100.00% <0.00%> (ø)
panel/io/server.py 37.65% <0.00%> (ø)
panel/models/__init__.py 100.00% <0.00%> (ø)
panel/widgets/__init__.py 100.00% <0.00%> (ø)
... and 31 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3993d1...b126115. Read the comment docs.

@maximlt
Copy link
Member Author

maximlt commented Apr 8, 2020

(I was also hindered by these Model 'panel.models.widgets.FileDownload' does not exist errors while trying to launch a Bokeh server, error that is probably related to the recent problems around that, I'll try to update my setup and see how it goes).

Let me know how that goes, I've still not been able to reproduce any of those issues myself.

Ok I'll try to provide some more context.

I installed panel following the developer guide, the last command being doit develop_install -c pyviz/label/dev -c conda-forge -c bokeh -o build -o tests -o recommended.

When I open a notebook, before running any code, I see this error in the console:
[W 00:12:55.490 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20200409001232 (127.0.0.1) 22.94ms referer=http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=python3

Then if I try to run something like:

import panel as pn
pn.extension()
w = pn.pane.Markdown("# Hey")
w.show()

I see the following errors in the console:

WARNING:tornado.access:404 GET /static/extensions/panel/panel.min.js (127.0.0.1) 14.96ms
WARNING:tornado.access:404 GET /static/extensions/panel/panel.min.js (127.0.0.1) 1.00ms

In the opened browser tab, there's nothing displayed. The browser console shows:
image

And if that can be useful in some way, my full env spec:

# packages in environment at C:\Users\maxim\Miniconda3\envs\panel_dev:
#
# Name                    Version                   Build  Channel
asn1crypto                1.3.0                    py37_0
atomicwrites              1.3.0                      py_0    conda-forge
attrs                     19.3.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
beautifulsoup4            4.8.2                    py37_0
blas                      1.0                         mkl
bleach                    3.1.4              pyh9f0ad1d_0    conda-forge
bokeh                     2.0.1            py37hc8dfbb8_0    conda-forge
branca                    0.4.0                      py_0    conda-forge
bzip2                     1.0.8                he774522_0
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
certifi                   2020.4.5.1       py37hc8dfbb8_0    conda-forge
cffi                      1.14.0           py37h7a1dbc1_0
chardet                   3.0.4                 py37_1003
cloudpickle               1.3.0                      py_0
codecov                   2.0.15                     py_1    conda-forge
colorama                  0.4.3                      py_0    conda-forge
conda                     4.8.3            py37hc8dfbb8_1    conda-forge
conda-build               3.18.11                  py37_0
conda-package-handling    1.6.0            py37h62dcd97_0
coverage                  5.0.4            py37h8055547_0    conda-forge
cryptography              2.8              py37h7a1dbc1_0
cycler                    0.10.0                     py_2    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
doit                      0.31.1                   py37_0
entrypoints               0.3             py37hc8dfbb8_1001    conda-forge
filelock                  3.0.12                     py_0
flake8                    3.7.9            py37hc8dfbb8_1    conda-forge
folium                    0.10.1                     py_0    conda-forge
freetype                  2.10.1               ha9979f8_0    conda-forge
glob2                     0.7                        py_0
holoviews                 1.13.2                     py_0    pyviz/label/dev
icc_rt                    2019.0.0             h0cc432a_1
icu                       64.2                 he025d50_1    conda-forge
idna                      2.9                        py_1
importlib_metadata        1.5.0                    py37_0
intel-openmp              2020.0                      166
ipykernel                 5.2.0            py37h5ca1d4c_1    conda-forge
ipython                   7.13.0           py37hc8dfbb8_2    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
jedi                      0.16.0           py37hc8dfbb8_1    conda-forge
jinja2                    2.11.1                     py_0
jpeg                      9c                hfa6e2cd_1001    conda-forge
jsonschema                3.2.0            py37hc8dfbb8_1    conda-forge
jupyter_client            6.1.2                      py_0    conda-forge
jupyter_core              4.6.3            py37hc8dfbb8_1    conda-forge
kiwisolver                1.2.0            py37heaa310e_0    conda-forge
libarchive                3.3.3                h0643e63_5
libblas                   3.8.0                    15_mkl    conda-forge
libcblas                  3.8.0                    15_mkl    conda-forge
libclang                  9.0.1           default_hf44288c_0    conda-forge
libiconv                  1.15                 h1df5818_7
liblapack                 3.8.0                    15_mkl    conda-forge
liblief                   0.9.0                ha925a31_3
libpng                    1.6.37               hfe6a214_1    conda-forge
libsodium                 1.0.17               h2fa13f4_0    conda-forge
libtiff                   4.0.9             h36446d0_1002    conda-forge
libxml2                   2.9.9                h464c3ec_0
lz4-c                     1.8.1.2              h2fa13f4_0
lzo                       2.10                 h6df0209_2
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  3.2.1                      py_0    conda-forge
markupsafe                1.1.1            py37he774522_0
matplotlib                3.2.1                         0    conda-forge
matplotlib-base           3.2.1            py37h911224e_0    conda-forge
mccabe                    0.6.1                      py_1    conda-forge
menuinst                  1.4.16           py37he774522_0
mistune                   0.8.4           py37hfa6e2cd_1000    conda-forge
mkl                       2020.0                      166
mkl-service               2.3.0            py37hb782905_0
more-itertools            8.2.0                      py_0    conda-forge
msys2-conda-epoch         20160418                      1
nbconvert                 5.6.1                    py37_0    conda-forge
nbformat                  5.0.4                      py_0    conda-forge
nbsmoke                   0.4.1                      py_0    pyviz/label/dev
nodejs                    13.12.0                       0    conda-forge
notebook                  6.0.3                    py37_0    conda-forge
numpy                     1.18.1           py37h90d3380_1    conda-forge
olefile                   0.46                       py_0    conda-forge
openssl                   1.1.1f               hfa6e2cd_0    conda-forge
packaging                 20.1                       py_0    conda-forge
pandas                    1.0.3            py37h9b59f54_0    conda-forge
pandoc                    2.9.2                         0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
panel                     0.9.5.post4+gb7da1a2           dev_0    <develop>
param                     1.10.0a2                   py_0    pyviz/label/dev
parameterized             0.7.1                      py_0    conda-forge
parso                     0.6.2                      py_0    conda-forge
pickleshare               0.7.5           py37hc8dfbb8_1001    conda-forge
pillow                    5.4.1           py37h9a613e6_1000    conda-forge
pip                       20.0.2                     py_2    conda-forge
pkginfo                   1.5.0.1                  py37_0
plotly                    4.6.0              pyh9f0ad1d_0    conda-forge
pluggy                    0.13.1                   py37_0
prometheus_client         0.7.1                      py_0    conda-forge
prompt-toolkit            3.0.5                      py_0    conda-forge
psutil                    5.7.0            py37he774522_0
py                        1.8.1                      py_0
py-lief                   0.9.0            py37ha925a31_3
pycodestyle               2.5.0                      py_0    conda-forge
pycosat                   0.6.3            py37he774522_0
pycparser                 2.20                       py_0
pyct                      0.4.6                      py_0    pyviz/label/dev
pyct-core                 0.4.6                      py_0    pyviz/label/dev
pyctdev                   0.6.1                      py_0    pyviz
pyflakes                  2.1.1                      py_0    conda-forge
pygments                  2.6.1                      py_0    conda-forge
pyopenssl                 19.1.0                   py37_0
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyqt                      5.12.3           py37h6538335_1    conda-forge
pyqt5-sip                 4.19.18                  pypi_0    pypi
pyqtwebengine             5.12.1                   pypi_0    pypi
pyrsistent                0.16.0           py37h8055547_0    conda-forge
pysocks                   1.7.1                    py37_0
pytest                    5.4.1            py37hc8dfbb8_0    conda-forge
pytest-cov                2.8.1                      py_0    conda-forge
python                    3.7.6           h60c2a47_5_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python-libarchive-c       2.8                     py37_13
python_abi                3.7                     1_cp37m    conda-forge
pytz                      2019.3                     py_0
pyviz_comms               0.7.4                      py_0    pyviz/label/dev
pywin32                   227              py37he774522_1
pywinpty                  0.5.7                    py37_0    conda-forge
pyyaml                    5.3.1            py37he774522_0
pyzmq                     19.0.0           py37h8c16cda_1    conda-forge
qt                        5.12.5               h7ef1ec2_0    conda-forge
requests                  2.23.0                   py37_0
retrying                  1.3.3                      py_2    conda-forge
ruamel_yaml               0.15.87          py37he774522_0
scipy                     1.4.1            py37h9439919_0
send2trash                1.5.0                      py_0    conda-forge
setuptools                46.1.3           py37hc8dfbb8_0    conda-forge
six                       1.14.0                   py37_0
soupsieve                 2.0                        py_0
sqlite                    3.30.1               hfa6e2cd_0    conda-forge
terminado                 0.8.3            py37hc8dfbb8_1    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tk                        8.6.10               hfa6e2cd_0    conda-forge
tornado                   6.0.4            py37hfa6e2cd_0    conda-forge
tqdm                      4.45.0             pyh9f0ad1d_0    conda-forge
traitlets                 4.3.3            py37hc8dfbb8_1    conda-forge
typing_extensions         3.7.4.1          py37hc8dfbb8_3    conda-forge
urllib3                   1.25.8                   py37_0
vc                        14.1                 h869be7e_1    conda-forge
vincent                   0.4.4                      py_1    conda-forge
vs2015_runtime            14.16.27012          h30e32a0_1    conda-forge
wcwidth                   0.1.9              pyh9f0ad1d_0    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.34.2                     py_1    conda-forge
win_inet_pton             1.1.0                    py37_0
wincertstore              0.2                   py37_1003    conda-forge
winpty                    0.4.3                         4    conda-forge
xz                        5.2.4                h2fa13f4_4
yaml                      0.1.7                hc54c509_2
zeromq                    4.3.2                h6538335_2    conda-forge
zipp                      2.2.0                      py_0
zlib                      1.2.11               h62dcd97_3
zstd                      1.3.7                h508b16e_0

@philippjfr
Copy link
Member

Did you rebuild the panel.js bundle after you updated your env? Try running:

panel build panel

in the root of the repo.

@maximlt
Copy link
Member Author

maximlt commented Apr 8, 2020

I've just tried:
panel build panel

which gives:

(panel_dev) D:\Code\Contribs\panel>panel build panel
Working directory: D:\Code\Contribs\panel\panel
Using D:\Code\Contribs\panel\panel\tsconfig.json
Compiling TypeScript (28 files)
Linking modules
Output written to D:\Code\Contribs\panel\panel\dist
All done.

But the error was still there.

So I tried:
panel build panel --rebuild

which gave:

(panel_dev) D:\Code\Contribs\panel>panel build panel --rebuild
Working directory: D:\Code\Contribs\panel\panel
Running npm install.
audited 399 packages in 1.716s
found 0 vulnerabilities

Using D:\Code\Contribs\panel\panel\tsconfig.json
Compiling TypeScript (28 files)
Linking modules
Output written to D:\Code\Contribs\panel\panel\dist
All done.

Still the same error.

I've deleted the dist and the node_modules directories and run panel build panel. Same error.

Let me know if I can do some other tests for you (tomorrow!).

@philippjfr
Copy link
Member

Okay, well that's not good. I'll make a completely fresh env tomorrow and will try reproducing it again.

panel/widgets/misc.py Outdated Show resolved Hide resolved
@philippjfr
Copy link
Member

The PR looks good apart from one minor comment. I guess you can't continue until the bokeh issue is fixed?

Co-Authored-By: Philipp Rudiger <prudiger@anaconda.com>
@maximlt
Copy link
Member Author

maximlt commented Apr 15, 2020

Hi @philippjfr!

Thanks for spotting that typo!

I decided to submit that first PR as it solves the issue I had originally. I can now set the filename in a callback which is pretty handy. For instance, now one can append the current datetime to the output filename in a callback.

I've been working on a second PR whose aim is to fix some other issues with the widget. Since it deals with the Typescript side of the widget, it's a slower process for me as I know pretty much nothing about that. It's also quite slow as I have to build everything first and then run a python script, there's maybe a faster way.

I'd suggest that you merge this PR first. Hopefully in the next few days will come a second PR.

@philippjfr philippjfr merged commit c9e5e39 into holoviz:master Apr 16, 2020
@philippjfr
Copy link
Member

Okay, great. Thanks again!

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

Successfully merging this pull request may close these issues.

2 participants