Warning in "Create a New Python based KNIME Extension"

Hii everyone,
I am following KNIME"s documentation article : “Create a New Python based KNIME Extension”. I am following through the steps and when I execute the tutorial_extension/my_extension.py file inside PyCharm, I get the following warning:
knime_gateway not available. KNIME Views will not work, however for autocompletion the source is still available
This warning is being produced from a failure to import knime_gateway package inside knime_views.py module. I have made sure that I installed the meta package “knime-python-base” and “knime-extension” inside my virtual environment. Secondly, I am using Knime Analytics Platform Version 4.6.2. For clarity, I have also attached a screenshot of the issue

Hi @saad_munir,
Welcome to the KNIME Forum!
You can safely ignore this message. Python-based KNIME Extensions are not meant to be executable outside of KNIME Analytics Platform. The import failed because it requires an active connection to KNIME Analytics Platform. Using and debugging your nodes from KNIME AP should work.

1 Like

Hi @bwilhelm ,
I am really struggling in debugging my Python implementation inside PyCharm IDE. Whenever I make a change or have to print some variables, I have to use a Logger inside my code and restart KNIME Analytics Platform manually. This is very annoying. I noticed your last line that “Using and debugging your nodes from KNIME AP should work”. Could you please guide me how can I directly debug my implementation and directly print variables/dataframes inside KNIME AP?

Hi @saad_munir,

Restarting KNIME AP to see changes should not be necessary. If you use the debug_mode: true flag in your config.yml the node will be slower but it will start a new Python process with the current version of the file on each execution (or configure). Therefore, changes to the execute or configure methods will take effect immediately. You only need to restart KNIME AP if you want to change how the node is set up (node name, input ports and output ports, parameters, etc).

Using a real debugger with debugpy is also possible but not yet documented. Also, I didn’t try it with PyCharm before but only with VSCode. You can add the following snippet to the location where you want to have the breakpoint:

    import debugpy
    debugpy.listen(5678)
    print("Waiting for debugger attach")
    debugpy.wait_for_client()
    debugpy.breakpoint()

Your Python process will stop when running this code and you will be able to attach to it with a remote debugger (I think this is the appropriate guide for PyCharm: Attach to process | PyCharm – I didn’t try it).

1 Like

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