we would like to refer to a file (a Pytorch model) within the Knime Mountpoint in a Python script. We tried this by using knime://LOCAL like this:
model_path = ‘knime://LOCAL/data/models/model.model’
This did not work. How can we refer to a file in the Knime workflow space in a Python script? Relative or absolute file paths did not work as well.
currently KNIME URLs cannot be resolved in Python, but there is a workaround that should help you. Can you use the List Files node with “knime://LOCAL/data/models/” as folder and “model.model” in the filter? The result is a table with the resolved path and you can turn that into a flow variable using Table Row to Variable. The variable can then be passed into the Python Snippet.
Thanks for your answers. Because we are working on the Knime Server, the LOCAL method is not working for us. I did not mention this before, sorry.
Currently, we are trying to load some pre-trained models which are saved on the server within the Knime mountpoint using Python.
We tried the following
- absolute file system path (srv/knime_server/workflows/…)
- relative paths starting from the workflow (/…/models/mode.model)
Is there anything else we could try? When I run the same script outside of Knime on the server it works without any problems. I think there is an issue when I run Python within Knime.
instead of local you can also just write
knime.mountpoint to reference the current mountpoint.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.