Replies: 1 comment
-
I created a diagram about how the internals of dash-uploader work, and put it here (also at docs/how-dash-uploader-works.svg). It seems that the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, dash-uploader callbacks can be added with the syntax which resembles dash callbacks:
As the current version of dash-uploader (0.6.0) really supports only one-file uploads, the
filenames
will always be a list of one string, where the string is the absolute filepath of the uploaded file on the server.Now, the work on the
flow-dev
branch aims to make it possible to upload multiple files. Then, a plan for the callback syntax should be made. The changes may be backward incompatible as the version is still in 0.x.x .Possible syntax
The possible new syntax should not be designed from the technical point of view, but instead made to be as simple and easy to use from the user's point of view as possible. There are two different events that might be interesting for the user
callback implementation details
How the dash callbacks really work is that:
this.props.isCompleted
of theUpload_ReactComponent
defined in thesrc\lib\components\Upload_ReactComponent.react.js
.this.props.setProps
(dash-specific special prop that is passed to every component of a Dash app), a HTTP request is used to trigger a change in the attribute/property of a dash python component.isCompleted
can be changed for example when the Javascript component finishes uploading. In reality, a JS component only knows when it sent the last chunk. Therefore, some logic must be made which assures that the file really has been uploaded and received and the chunks have been merged into a file succesfully. This is because callback logic might assume that there really is a file that can be accessed immediately with the python code in the dash app.this.props.isCompleted
there will bethis.props.uploadedFiles
andthis.props.allUploadsCompleted
or similar.In the python side, the callback for the user could look like this:
This would:
filenames
is changed; that is, whenever there is a new file that has finished uploadingfinished
changes (all files uploaded), as uploading filesa
,b
andc
would already trigger withfilenames
being["C:\path\a", "C:\path\b", "C:\path\c"]
, and user would just need to check if finished isTrue
orFalse
to know if this was the last file.dash_uploader.UploadStatus objects ?
I'm considering, if it would be wiser to start using
UploadStatus
objects in the callbacks instead. This would make it easier to make adjustments in the dash-uploader API later on, if needed. For example, if it would be needed to addn_files_total
(total number of files to be uploaded) andn_files_uploaded
(number of files uploaded so far), and perhapslast_uploaded
(last uploaded file). Then, the callback structure would need to be updated to be:and the list might get longer. This would potentially cause some breaking changes when users would update
dash-uploader
. A very long list of arguments makes the API ugly and cumbersome, and would be aesthetically unpleasing if a user just wants thefilenames
and does not care about the other parameters.Another possibility would be syntax like:
Or just
**kwargs
. This would ensure that there will be no backwards incompatible changes. But, then users would always need to refer to the documentation to accesskwargs['some_parameter']
, and the access syntax is uglier than simplestatus.some_parameter
.The
UploadStatus
object would then allow syntax like:If user uses python Type Annotations, then the syntax could be:
This might also make it possible that the IDE would suggest/tell the available attributes of the
status
object.Beta Was this translation helpful? Give feedback.
All reactions