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

dev branch 0.7.0 598d05d not passing filenames #85

Open
bpl-coding opened this issue Mar 30, 2022 · 2 comments
Open

dev branch 0.7.0 598d05d not passing filenames #85

bpl-coding opened this issue Mar 30, 2022 · 2 comments

Comments

@bpl-coding
Copy link

I am trying to use the 0.7.0 dev branch for its multi-file uploading enhancements.

The files are successfully uploaded, however, it does not appear that any filenames are being passed via callback. This is true even when only 1 file is uploaded.

I have switched to using the "uploadedFileNames" prop as it seems "isCompleted" and "filenames" are deprecated.

Am I doing something wrong?

@app.callback(
        Output("loaded-data", "data"),
        [
            Input("upload-data", "uploadedFileNames"),
            Input("confirm_clear_button", "n_clicks"),
        ],
        [
            State("upload-data", "upload_id"),
            State("loaded-data", "data"),
        ]
    )
    def update_data(filenames, confirm_clicks, upload_id, stored_results):
        UPLOAD_FOLDER_ROOT = r"du_files"

        trigger_id = dash.callback_context.triggered[0]["prop_id"].split(".")[0]
        if trigger_id == "confirm_clear_button":
            if confirm_clicks:
                return pd.DataFrame()
            else:
                raise PreventUpdate
        if trigger_id == "upload-data":
            print(filenames)
            #print(iscompleted)
            print(len(filenames))
            # if not iscompleted:
            #     return
            if filenames is not None and len(filenames) > 0:
                ###process files here####

[2022-03-29 20:56:33,279] DEBUG in httprequesthandler: File saved to: du_files\d8e79e88-3f60-4ae1-8312-e5f99dba5f11\Server_Results_20201221.log
[]
[2022-03-29 20:56:33,648] DEBUG in httprequesthandler: File saved to: du_files\d8e79e88-3f60-4ae1-8312-e5f99dba5f11\Server_Results_20201107.log
[2022-03-29 20:56:34,011] DEBUG in httprequesthandler: File saved to: du_files\d8e79e88-3f60-4ae1-8312-e5f99dba5f11\Server_Results_20201208.log
[2022-03-29 21:02:22,034] DEBUG in httprequesthandler: File saved to: du_files\5eabaf90-b53a-4782-9925-855bcde438e2\Server_Results_20201221.log
[]
[2022-03-29 21:02:22,750] DEBUG in httprequesthandler: File saved to: du_files\5eabaf90-b53a-4782-9925-855bcde438e2\Server_Results_20201208.log
[]

@fohrloop
Copy link
Owner

Oh yeah, there has been a lot of changes in the 0.7.0 development branch which will unfortunately also have backwards-incompatible changes. I will have to document the things well when the release happens. I assume that you have built the JS yourself, which also might not been easy. As more people are trying the 0.7.0 I might as well go and make a pre-release available in PyPI so people can try it out without the NodeJS hassle.

Anyway, most probably the problem is with your callback structure. In the dev repo, the usage.py has a callback like this:

import dash_html_components as html
import dash_uploader as du


@du.callback(
    output=Output("callback-output", "children"),
    id="dash-uploader",
)
def callback_on_completion(status: du.UploadStatus):

    if status.n_uploaded == 0:
        return  # no files uploaded yet.

    print(status)

    out = []
    if status.uploaded_files is not None:
        return html.Ul([html.Li(str(x)) for x in status.uploaded_files])

    return html.Div("No Files Uploaded Yet!")

I should update the docs for the changes needed for the callbacks. The du.UploadStatus object is best described in Issue 68.

@fohrloop
Copy link
Owner

I uploaded a pre-release version (0.7.0a1) to PyPi. You can install it with:

python -m pip install dash-uploader --pre

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

No branches or pull requests

2 participants