Hi knime community,
I am a novice at knime and am currently facing some issues.
I would like to request your assistance in resolving my issues with running knime inside my python notebook. I am currently trying 2 approaches, both of which are not working so far. Seeking help from experts please.
I am trying to use this workflow that I downloaded: GitHub - kmansouri/QSAR-ready: Standardization workflow for QSAR-ready chemical structures pre-treatment. See "release" tab for the latest version and sample files!. It works when I run it inside knime itself, but I am trying to see if I can run it inside python notebooks.
I would like to seek your assistance in solving these errors. Thank you in advance!
I have detailed the 2 methods below.
Best,
Marcus
- In the first approach, I ran pip install for knime and I am trying to run the workflow in this way, however I am not sure how to run the command.
df_ld50.head()
df_ld50 = pd.read_csv(r"C:\Users\TechD\Documents\Marcus\screening\src\data\raw\knime\knime_input_rat_oral_ld50.csv")
# Initialize workflow
with knime.Workflow(knime_workflow_path) as wf:
wf.data_table_inputs[0] = df_ld50[]
wf.execute()
if len(wf.data_table_outputs) == 0:
raise ValueError("The workflow does not have any output ports. Please add an output port to the workflow.")
# Retrieve output data from the first output port
output_table = wf.data_table_outputs[0]
print(output_table)
Here is what the dataframe looks like and here are the errors I encountered:
In the second approach, I tried running the subprocess. However it appears that no matter what I try, the input file path is not the file I specify. Please see the highlighted part in the screenshot below
command = [
executable_path,
"-reset",
"-nosplash",
"-nosave",
"-application", "org.knime.product.KNIME_BATCH_APPLICATION",
f"-workflowDir={knime_workflow_path}",
f'-workflow.variable=cmd_input,{input_file_path},String'
]
result = subprocess.run(command, capture_output=True, text=True)
# Check for errors
if result.returncode != 0:
print("KNIME workflow execution failed.")
print("STDOUT:", result.stdout)
print("STDERR:", result.stderr)
else:
print("KNIME workflow executed successfully.")
print("Output:", result.stdout)