PyWorkflowApp / visual-programming

A Python Visual Programming Workspace for Data Science
MIT License
31 stars 12 forks source link

UI: Adding custom Nodes #71

Closed reelmatt closed 4 years ago

reelmatt commented 4 years ago

Many of these comments reference decisions made in #70. Depending on feedback, some of this information is subject-to-change.

Back-end

The back-end provides two key endpoints that are helpful for adding custom Nodes on the front-end. 1) workflow/upload: Accepts a file upload via FormData. The existing front-end API wrapper for uploadDataFile can be used, just without the nodeId attribute added in NodeConfig. 2) workflow/nodes: Returns a list of available Nodes to the workflow. This returns the same response the /nodes/ endpoint used to, except now there is an additional 'Custom Nodes' category. If all packages are installed, this should proceed as normal. If not, the node information will be structured as such:

{
    "filename": "my_custom_node",
    "missing_packages": [
        "torch",
        "scipy"
    ]
}

Front-end

Custom Nodes work like any of the other Pyworkflow Nodes, so there is no additional work needed to add a Node to the Workspace, update Node info, execution, etc. The two new pieces needed for the front-end correspond to the two pieces mentioned above in the back-end. 1) Adding a new Node. This can probably use the same/similar code as the Node's FileUpload element does, just triggered from a different area in the workspace. One idea might look like this wireframe

Custom Nodes

where a + or Add custom node button is added at the bottom of the Node listing. This would pop-up the file picker, and trigger the workflow/upload endpoint. On success, a call to workflow/nodes would be made to refresh the list to include the newly-added custom Node.

2) Handling missing packages for custom Nodes. If the custom Node does not required any new packages to be installed, it should be ready to drag-and-drop like other Nodes. If there is a missing package though, it cannot be dragged and the name will either be the filename (instead of the class name attribute — my_custom_node vs. My Custom Node) or not appear at all.

A few solutions/ideas:

Some combination of the first two bullets is probably most feasible and reasonable.