-
Notifications
You must be signed in to change notification settings - Fork 255
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
Update to File widget for uploading multiple files #387
base: main
Are you sure you want to change the base?
Conversation
…orks in Jupyter, help still needed on React side of UI.
Hi @rmkolany, thanks for PR. I believe that there are needed changes in the frontend code, to make it work. The File widget in the frontend (React code) should use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it working for you? do you have some screenshots with multiple file upload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can't import package from local paths, because it will not work for other folks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to repackage the repo from local to see if my attempt at changes to the react code would work. On my deployed version hosted on a VM I was able to edit one frontend file to allow multiple files to upload in addition to the changes made to file.py. I edited this file: .\mercury\frontend-dist\static\js\2.206848a5.chunk to change allowMultuple:[!1,Ue.BOOLEAN]
to allowMultuple:[!0,Ue.BOOLEAN]
. Changing this and clearing the browser cache allowed the widget to accept multiple files at once either via drag & drop or selecting multiple via the file browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a few different methods including running pip install for my branch and just cloning the repo and running setup.py to build the package. The latter method seems to have worked better but when I go to run mercury I get the 'TemplateDoesNotExist' error in the browser due to the templates and frontend-dist folders not being created. My attempt at changing the React code is within commit 7d78406 by adding the multiple
parameter to the file widget. I have never worked in React and will likely need help to get this to work for others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry! I should explain it earlier ... You need to build the frontend and copy all html, js, css files into Django directory, here are steps:
# run from main directory
# 1. remove previous frontend static files
rm -rf mercury/frontend-dist
# 2. go to fronted directory
cd frontend
# 3. install required packages
yarn install
# 4. build fronted files and copy them (copy is done in the local-build command)
yarn local-build
After above steps you should see changes in frontend when running mercury locally with command (mercury run
).
Link to Issue #347
To help move this issue along I updated the
File
widget to accept multiple files. I added an argumentmultiple
to allow the user to specify if they would like to allow multiple files to be uploaded.multiple=False
by default and should have no impact on users who are using this widget for one file now.filename
,filepath
, andvalue
output lists ifmultiple=True
. I considered using a different method but wanted to retain the current functionality as much as possible.File
Widget Use with Multiple FilesInput
myFile = mercury.File(label="Upload File Here", multiple=True)
Handling Files After Upload
myFile.filename
myFile.filepath
myFile.value
myFile.temp_dir
I was able to get this to work in my environment without any issues in Jupyter Lab but the file uploader would not accept multiple files in the Mercury UI. It looks like some updates may be needed on the React side of things but I am not familiar with React to make the necessary changes.