How to call set_progress correctly

I am using KNIME version 5.2.1 which runs on Mac OS. I am trying to add a progress indicator to a Python node with a long runtime. After some tinkering, I managed to set up a Conda environment that allows me to import Knime.extension.

However, I was not able to use the “set_progress” function correctly.
Here are my attempts:

import knime.extension as knext
# Convert the input table to a pandas DataFrame
input_table: DataFrame = knio.input_tables[0].to_pandas()
# Iterate over rows and make API calls
for i, (index, row) in enumerate(input_table.iterrows(), 1):
    # Update progress
    # knext.set_progress(i / len(input_table)) ??? even tried
    # knext.ExecutionContext.set_progress(1.0) ???

I would be grateful for any advice on how to solve this seemingly simple problem.

Hi @ekadagami,

I’m glad you play around!

What do you mean with ‘some tinkering’ to set up a Conda environment?

I think, generally, the tutorial to write a Python node (for this part, step 4) should explain that. If that tutorial needs improvement, I’ll gladly take suggestions :slight_smile:

Have you looked at the methods’ docstring?
It can be found in the ReadTheDocs.
Or in your editor, if it is set up to use the autocompletion, it also gives access to the docstring (see the tutorial).
Or in the forum, where I linked examples: Progress bar - #2 by steffen_KNIME

Does that help? Happy coding!

Thank you very much for your prompt reply. Of course I consulted google before I posted the question in the forum and stumbled across the examples.

Maybe I didn’t understand something fundamental. I don’t want to develop a new node type, I just want to extend the script of an existing Python node.

On the subject of Conda: Setting up the Conda environment is easy. Unfortunately, I was too stupid to select exactly this environment in the settings in KNIME. This happens to me all the time.

So: unfortunately I haven’t really made any progress and the problem still exists.

Dear @ekadagami,

my apologies, I think I misunderstood.
Are you saying, that you want to use a Python Script node?

I assumed that you wanted to create a new pure-Python node:

So, for a Python Script node it is not possible to use a set_progress bar I am afraid. I opened a ticket (internal: AP-22050, and I found AP-15961), but I can not promise anything here.

I am sorry for the inconvenience.

About the Conda environment selection, what exactly could there improved? :slight_smile:

Best regards


Ah, that was my mistake, because I didn’t express myself precisely enough. I’m just a KNIME novice. Yes, I use the Python Script Node. I think that some people would like to see the progress bar in Python Script. The terminal / debug output is only a makeshift.

It’s really amazing how quickly you can get really good results (I only used R and Orange before).

Your documentation is excellent, its structure is clear and understandable.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.