-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support multiple Dash or Flask apps for "du.configure_upload". #39
base: dev
Are you sure you want to change the base?
Conversation
The user configurations are moved to a dict. It is designed for supporting multiple du.configure_upload.
1. Change the format of du.settings. 2. Move update_upload_api from du.upload to du.configure_upload. 3. Add an option "upload_component_ids" to du.configure_upload. This enables users to set different configurations for different components. 4. Support for flask app for du.configure_upload.
Thanks for the detailed PR! I'm happy to see this progressing. One thing that I'm considered that there might be some side effects that I cannot foresee, and the complexity of the things this package can do is increasing. This can lead into difficulties in maintaining the dash-uploader in the future. What I would suggest, is that there will be some automatic tests added to all the new features. This way we can see that nothing will break when something is changed. |
I have to admit that this PR is large even though the API changes are very small. At least, I could confirm that the two examples I provide (as well as the For the automatic tests stuff, should it be related to the other issue #34? I am guessing that you want to use I know that |
I would be delighted to see a PR for some basic testing! :) No need to add GitHub Actions etc. at this stage, just bare minimum to get testing started. This is exactly what issue #34 is about. One thing what I'm now thinking that the One thing I'm thinking is that what is the motivation behind supporting multiple calls to |
Please do not try to merge it now. We may need to change the API according to the previous discussion. If we discard the implementation based on multiple calls to If you think the implementation of multiple calls to du.configure_remote_upload(app, remote_addr, upload_component_ids) because an uploader directed to the remote server only needs to handle the callback. The uploading folder, API, and requests are handled by the remote side. I have realized that in my case, I do not need to use du.configure_upload(app, ...)
du.configure_remote_upload(app, remote_addr_1, upload_component_ids=...)
du.configure_remote_upload(app, remote_addr_2, upload_component_ids=...)
... For the remote side, I only need to configure something like this du.configure_upload(flask_app, ...) So serving multiple calls of How do you think of that? If the multiple calls to |
This clearly needs some more thinking with better good night's sleep. Here are some fast notes. These are not necessarily answering to anything, but they can help us later when designing the future API & functionality of dash-uploader. DashThe
There values are read from the dash du.configure_uploadsaves some settings
opens routes
du.Upload
HttpRequestHandler
|
Thank you for replying to me. Currently, I tend to drop the implementation of this PR, because I think we may not need the multiple calls for AuthenticationFirst, let me explain my view about authentication. Currently, I have to acknowledge that I have not considered this problem. To my knowledge, the authentication could be maintained in a very complicated (but also very safe) way or a very simple way.
But an important problem is that the authentication is an optional feature for dash. We could not expect that each dash app is equipped with authentication, and we may not know how do the users apply the authentication. For the Flask case, we may have a similar situation. If we want to make the authentication a built-in feature of
Because I am not a professional web developer, I am not sure whether these steps are widely acceptable. I know that there are some plugins like For this PRBefore the next step, I think we may need to determine the one thing:
For the remote service case, we may also need to determine the functionalities. But I think we could discuss it in the next PR about multi-services. |
Hello! I am back for this project now. First, please let me explain my understanding of your thoughts:
|
Hi @cainmagi , If I understood this correctly, this
..says that you were also about to pipe all the AJAX calls (from browser) through the Dash app to your Flask app (and not sending from browser directly to Flask)? Thank you for the question! I would really much like to simplify the user experience by using
|
What I am basically saying is that one needs to have one call to
|
About request forwardingNot really. Because
I think I should draw a figure in the next PR (about the cross-domain implementation) to make this workflow clearer. About
|
Thanks for the explanations! A diagram would surely help to understand the working principle much faster! If we would use
Do you think it would work just just configure_upload(app, folder=None, use_upload_id=False, upload_api=None, http_request_handler=None) But what if you have two |
About FlaskYes, there some dash-special configurations like # If this is a dash app
du.configure_upload(app, folder=None, upload_api=None, use_upload_id=None, http_request_handler=None)
# If this is a flask app
du.configure_upload(app, folder=None, upload_api=None, use_upload_id=None, http_request_handler=None) All of the arguments would be used for configuring the app in both cases. To reduce the repeats of the codes, we could add a check in the implementation of About cross-domain serviceYes. I am quite sure that To make Let me use your example to make a simple explanation:
The only problem is that, in some cases, we do not need the first component, i.e. we may only have remote uploading components. Then we actually do not need to configure a local upload API. But I think we should still force users to call |
Introduction
This PR preserves all existed APIs. In other words, the modifications are compatible with previous APIs.
This PR is designed for providing the following new API:
where we have:
du.configure_upload
could be used several times.app
could be adash.Dash
instance or aflask.Flask
instance. The argument type would be checked during the configuration.upload_component_ids
is provided, it could beNone
: This is the default value. It means that thisdu.configure_upload
is designed for default configurations.str
: This is the same as(str, )
tuple
orlist
: A sequence ofstr
. Eachstr
is a component id. The component with the provided id would be configured by the provided configurations.upload_component_ids
. If it is notNone
, each item requires to be a non-emptystr
. And each item should be unique, i.e. repeating configurations for the same component is not allowed.Example
For dash
Users could change the
upload_component_ids
in the seconddu.configure_upload
and check what happens.For Flask
In this case, actually, we do not need to configure
upload_component_ids
, because a Flask app does not have components. It should be only used for managing APIs.For the next step
du.callback
. If the component is not configured for a dash app (not configured or configured for a flask app), thedu.callback
would be forbidden. However, it is possible to implement a "Flask callback". We could invoke the callback by using the request handler after the final chunk uploaded. I am wondering whether we need to implement this feature (maybe this feature should be split into another PR).component ids
, we may have two options for the implementation: (1) Add the component id in the arguments of the request. Then theupload_component_ids
should be preserved because the Flask app could identify the component id. (2) Each "Flask callback" is designed for an API. In this case, we only need to add a check fordu.configure_upload
and forbid users to setupload_component_ids
whenapp
is a Flask app.Update report
du.settings
.update_upload_api
fromdu.upload
todu.configure_upload
.upload_component_ids
todu.configure_upload
. This enables users to set different configurations for different components.du.configure_upload
.