Skip to content

Allow option overrides with global flow variables#78

Merged
reddigari merged 17 commits intomasterfrom
feature/flow-var-override
May 2, 2020
Merged

Allow option overrides with global flow variables#78
reddigari merged 17 commits intomasterfrom
feature/flow-var-override

Conversation

@reddigari
Copy link
Collaborator

@reddigari reddigari commented Apr 30, 2020

Any non-file parameters in the node configuration form have a checkbox indicating whether to override with a flow variable (if any exist). Checking the box disables the normal parameter input, and displays a dropdown to select the flow node to use as the override.

Currently no verification that the selected flow var has the same type as the option being overridden, but I think I'll handle that as I do local flow nodes tomorrow.

I've tested by overriding the sep option of ReadCsvNode to read a CSV where I swapped the commas for semicolons, and it works fine. There is a problem that @reelmatt is looking into where if you try to use a flow variable to override the WriteCsvNode output file, the server doesn't know how to construct the correct path.

Screen Shot 2020-04-29 at 9 37 14 PM

@reelmatt reelmatt linked an issue Apr 30, 2020 that may be closed by this pull request
Copy link
Member

@reelmatt reelmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few missing parens/brackets are causing a compile error, but otherwise looks great!

The other comment re: where flow options appear can wait for later, but something to think about.

disabled={props.disabled}
checked={value}
onChange={handleChange} />

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing some closing ) and } here. Causing a compile error when run.

return (<></>)
}

const hideFlow = props.node.options.node_type === "flow_control"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KNIME allows for you to override flow node values with other flow nodes, so the first part here is not entirely correct. As-is though, I think this could cause an infinite loop on the server should a global flow node overwrite it's own value (it would keep looking up its own node). This shouldn't be a problem for local flow nodes (since they could never be provided as an option to themselves), so maybe change the check to props.node.is_global?

@reddigari
Copy link
Collaborator Author

@reelmatt Great catch, both resolved by the last two commits.

Now, raw filenames/inputs are stored in the Node (removing the construction of a path on Node update - in `node/views.py`).

When a file is needed, the path is constructed at that time (either Node execution or file download).
@reddigari
Copy link
Collaborator Author

@reelmatt your commit got it to execute properly, but the downloaded file was named download.csv rather than the value in the global flow variable. Any ideas?

@reelmatt
Copy link
Member

reelmatt commented May 1, 2020

We had something like this earlier, adding the filename in the response like:
response['Content-Disposition'] = f"attachment; filename={f.name}"
I wasn't sure the best way to parse that on the front-end, so I just passed the filename in the header and used that directly.

That should work now, but feel free to tweak that as you see fit. In general, I think that's a lot cleaner/simpler than trying to re-derive the filename from the node.config info on the front-end.

@reddigari reddigari merged commit 44899f9 into master May 2, 2020
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

Successfully merging this pull request may close these issues.

UI: Handling global flow variables

4 participants