Using KNIME Workflows in Jupyter Notebooks

Hi @duydu

Regarding your question about the order of the outputs in data_table_outputs: there is no convenient way of knowing what the order of the output tables will be in the current implementation. To describe in more detail, the knime.Workflow class’s code currently determines the order of the output tables (the order observed in wf.data_table_outputs in your example) based upon the order pathlib.Path.glob discovers settings.xml files for each node in the workflow. (I am ultimately referring to the current implementation of knime.find_service_table_node_dirnames().)

A couple of things occur to me:

  • I definitely agree that it would be convenient to know which output is which beforehand when accessing wf.data_table_outputs on workflows containing more than out Container Table (Output) node. I have added this as an enhancement request to the knimepy project on GitHub (see https://github.com/knime/knimepy/issues/17).
  • It is perhaps worth pointing out that a user can currently take full control of the order of the input and output tables by using the functional apis (e.g. use run_workflow_using_multiple_service_tables()) instead of the object-oriented api that knime.Workflow conveniently provides.
  • Though not a universal solution, if it is possible and appropriate to combine the output from both portions of a workflow into input for a single Container Table (Output) node, then you can effectively control exactly how this data will be passed back from KNIME into your Python code.

Also, regarding the similar question asked on github, the question asked by mbezy at that link you provided is about inputs, not outputs. Identification of which input is which is already possible via the knime.Workflow.data_table_inputs_names and knime.Workflow.data_table_inputs_parameter_names attributes. Of those two, the data_table_inputs_parameter_names is probably the far more helpful one to use because that label can be easily changed in the node’s configuration dialog in KNIME.

Davin

4 Likes