panel icon indicating copy to clipboard operation
panel copied to clipboard

None returned to FileInput

Open pgierz opened this issue 4 years ago • 3 comments

Hello,

I am trying to include large files via the FileInput widget. Effectively, this is something like this:

import panel as pn
import xarray as xr

pn.extension()

uploader = pn.widgets.FileInput()
uploader.save(uploader.filename) # Assume filename is a NetCDF file
ds = xr.open_dataset(uploader.filename)

This works fine as long as the files are small (I tested with a few kbytes). However, if they get large, I get back:

AttributeError: 'NoneType' object has no attribute 'write'

I guess because the file hasn't uploaded all the way yet. If that's the case, would it be possible to block the program and display some sort of progress bar?

pgierz avatar Mar 22 '21 23:03 pgierz

@pgierz is the code you shared exactly what you were executing? Was it in a notebook?

maximlt avatar Dec 26 '21 20:12 maximlt

I had some old code that watched the 'value' param, but then this triggered accessing the widgets filename .

This code worked for a long time, but updating to the following versions, I had the same issue.

panel                     0.12.6            
bokeh                     2.4.2

Have updated the code to watch the filename and its working again. I wonder if it's a similar issue..

   --     _watcher = self.upload.param.watch(self.on_hdf_import, parameter_names=['value'])
   ++   _watcher = self.upload.param.watch(self.on_hdf_import, parameter_names=['filename'])

okz avatar Jan 07 '22 20:01 okz

Seems likely that it's syncing the data first and then the filename and the larger the file the more likely the callback gets called before the filename is updated.

philippjfr avatar Feb 17 '23 19:02 philippjfr