Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
10.94k stars 775 forks source link

Data node Viewer - Add file download/upload capability for file based data nodes #1196

Closed jrobinAV closed 1 month ago

jrobinAV commented 4 months ago

Description When a data node is stored as a file, it would be handy for the end user to add a way to download or upload the file from the data node viewer easily.

This should help the end user understand its data, particularly when data is corrupted or an unexpected behavior happens.

This capability could be enabled/disabled by the developer through a property. By default, it should be enabled.

Proposal

  1. The download could be accessible through a "Download" button (eventually, an icon when the element width is too small).
  2. The upload could be accessible through an "Upload" file selector (eventually, an icon when the element width is too small). When a file is passed to the Upload mechanism, Taipy should:
    • Check the file (a check property should let the developer provide a custom function).
    • Write the file at the data node path location. Eventually, overwrite it if a file already exists.
    • track the data node edition

Usage

def custom_check(state, file_path) -> bool:
    # Apply the check logic
    return True

<| {selected_datanode} | datanode | file_download=false | file_upload=true | upload_check=custom_check |>
FlorianJacta commented 4 months ago

Seems related to this https://github.com/Avaiga/taipy/issues/427

trgiangdo commented 3 months ago

There are a few use-cases I think we need to clarify before actually implement the feature. I will only mainly on the Core side of the problem here, and error handling on GUI as well.

  1. If the datanode is not file-based, what happens?

    • Raise an error on the GUI component directly? (not sure if it's possible), or
    • Notify an error from Core to GUI
  2. For most file-based datanodes, we can return the file or folder directly when downloading. But on ExcelDataNode, what if the DataNode can only access a few sheets of the file, we return the original file or a new file with only the defined sheets?

  3. For uploading data, how do we handle invalid data?

    • We can check for the data before writing,
    • Or better yet, we can try to write the data and catch any exception to raise an error.
    • However, most issues related to wrong data will only be raised when executing jobs, so it's hard to detect the problem at uploading step.
FlorianJacta commented 3 months ago
  1. Make the button inactive.
  2. I would guess the new file (not sure)
  3. I would say it is on the developer side, not ours. Make sure their tasks are compliant with invalid data or do the right transformation.
jrobinAV commented 3 months ago

These are good questions.

  1. I agree with @FlorianJacta. We simply deactivate the button.
  2. Good question. What I had in mind originally was just asking the data node path to Core, and then simply download the file, without any preprocessing. If we need to go through the read method to understand what should be exported, the functionality is not the same. In this case, I believe a table export feature to export the content of a table is more suitable and could apply to SQL data nodes as well.
  3. Here again I was originally thinking of a simple file replacement. That means the responsibility is on our users. The end-user: The end user should take the responsibility to ensure the validity of the data. We can imagine adding an info message (like a mouseover text or something else) to let him know that he is responsible for checking the file format (pickle, excel, csv) and eventually the data format (column names). This message could be specific to each data node type. The developer: We should expose a way for the developer to pass a checker method to the control. THe checker can validate the file content once uploaded. If the checker passes the file can be replaced.

@MariahLeone Any thoughts about that.