workflow.svg file not found

I was trying to execute a sample workflow from python and I have mentioned path to my workspace and workflow but while executing knime.Workflow I get an error FileNotFoundError: No such file or directory. I could notice that there was no workflow.svg file in my workflow project.

How do I get this file. I have saved my workflow and executed in knime before doing so using python but I don’t have this file in my location.

Hi @yash

What version of KNIME AP are you using? In older versions you needed to have the SVG extension installed so that workflow svg files would be saved with the workflow:

Make sure you have that extension installed, then open, edit (moving around a node should be enough) and save that workflow. Then it should work.

best,
Gabriel

1 Like

Hi @gab1one,

I am using the latest version 4.3. But I don’t know why the file is missing. Do I need to install any extensions for this as well?

Can you check if the SVG extension is installed? Also do you have this problem with all workflows or just with that single one?

I have only 2 workflow created just to check how to execute in python and both don’t have .svg file. Also I don’t find the extension to install. Please find below.

You can install the extension directly from the KNIME Hub link I posted earlier, by dragging it into your workflow:


best,
Gabriel

@gab1one I have installed the extension but still I don’t see .svg file and I don’t know something is happening with my environment. When ever my server restarts I don’t see my workflows in my workspace. They disappear all of a sudden. Can you tell me what is happening.

Hi @yash,

I am looping in someone who is experienced with KNIME Server to help you with this. Stay tuned.

best,
Gabriel

1 Like

Hi @yash

In your original post, you wrote:

while executing knime.Workflow I get an error FileNotFoundError: No such file or directory

I would expect this sort of error to arise when either the path to the workflow on disk is incorrect or the path to the KNIME executable is incorrect for your local system.

If you have not set the location of the KNIME executable yourself, the default value is not always the right setting for everyone. Stolen from the first example at https://github.com/knime/knimepy :

# Change the executable_path to point at a particular KNIME install.
# May alternatively be set via OS Environment Variable, 'KNIME_EXEC'.
knime.executable_path = r"C:\Program Files\KNIME\knime.exe"

The rest of the error message should help you know whether it is the executable path or the workflow path that is the source of the problem. I thought I should share the above snippet about the executable path because it may help others who come along later and read this forum post.

The SVG file is only accessed through knimepy when either explicitly asked for or when a Jupyter notebook attempts to render a KNIME Workflow in the notebook. Because you described an error that occurs during execution of the workflow, I do not expect the existence/absence of a workflow.svg file to be relevant to the error you describe.

If you are convinced that you have both the executable path and the workflow path set correctly, I will need to see the complete trackback from Python to help further.

Davin

Hi @potts,

Thanks for your reply. I have not set the KNIME executable location myself but cross checked with the team and the location specified is indeed correct. Below is the my code and error traceback.

import knime
knime.executable_path = r"/mnt/C/Program Files/KNIME/knime.exe"
workspace = r"/mnt/C/Program Files/KNIME/workspace"

workflow = "iris"
knime.Workflow(workflow_path = workflow, workspace_path = workspace)

Error message

FileNotFoundError                         Traceback (most recent call last)
/opt/anaconda3/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj)
    343             method = get_real_method(obj, self.print_method)
    344             if method is not None:
--> 345                 return method()
    346             return None
    347         else:

/opt/anaconda3/lib/python3.8/site-packages/knime.py in _repr_svg_(self)
    481     def _repr_svg_(self):
    482         "Returns SVG of workflow for subsequent rendering in Jupyter notebook."
--> 483         return self._adjust_svg()
    484 
    485     def display_svg(self):

/opt/anaconda3/lib/python3.8/site-packages/knime.py in _adjust_svg(self)
    474         chrs = string.ascii_letters + string.digits
    475         prefix = "".join(random.choice(chrs) for i in range(10))
--> 476         svg_contents = self._get_workflow_svg()
    477         svg_contents = svg_contents.replace('id="clip', 'id="l%sclip' % prefix)
    478         svg_contents = svg_contents.replace('#clip', '#l%sclip' % prefix)

/opt/anaconda3/lib/python3.8/site-packages/knime.py in _get_workflow_svg(self)
    460 
    461     def _get_workflow_svg(self):
--> 462         with open(self.path_to_knime_workflow / "workflow.svg", 'r') as f:
    463             svg_contents = f.read()
    464         return svg_contents

FileNotFoundError: [Errno 2] No such file or directory: '/mnt/C/Program Files/KNIME/workspace/iris/workflow.svg'

<knime.LocalWorkflow at 0x7f5661c87f40>

BTW the server restart that I mentioned is not about KNIME server but my appstream server.

Hi,

Further to the above regarding location, I have changed my workspace location and I ran a workflow within KNIME and workflow.svg is created but I get the same error while executing it in python. Attached screenshot for your reference.

knime1

Regarding the workflows missing when my server restarts, I have sorted it with my team. But kindly help me to execute the flows in python.

Hi @yash

Thank you for sharing your code snippet and traceback – both are very helpful.

It appears you are triggering the latter – your traceback indicates that a call was made to _repr_svg_() which is reasonably explained by your line of code, knime.Workflow(workflow_path = workflow, workspace_path = workspace), being rendered for the screen. If you modify this line of your code snippet to instead store the Workflow in a variable, the attempt to render it with an SVG will be eliminated and the FileNotFoundError will no longer occur. That is, change that line of code to read:

wf = knime.Workflow(workflow_path=workflow, workspace_path=workspace)

The question remains: why did it not find the SVG file in that location? You mention moving the workflow on disk to a new location and now you find an SVG file is indeed appearing in the workflow’s new directory. I also notice that your Python code references locations that begin "/mnt/C/..." which suggests that you might be using Windows Subsystem for Linux (WSL) or possibly Cygwin on your Windows system at least when running your Python scripts. I wonder if there is any difficulty with resolving paths correctly on your system when bouncing between using WSL and the native OS – that is not WSL’s fault, per se, but is something that must be thoughtfully guarded against when using native programs and WSL-dependent programs together. As a diagnostic tool, you might try modifying this example code to verify that you indeed have the full paths to things exactly right for your system, starting with the path to the executable and then verify the paths to your workflows:

>>> import pathlib
>>> exec_location = r"/mnt/C/Program Files/KNIME/knime.exe"
>>> pathlib.Path(exec_location).exists()
False
>>> exec_location2 = r"C:\Program Files\KNIME\knime.exe"
>>> pathlib.Path(exec_location2).exists()
True

Keep in mind that the full path to the workflow may be provided as a single argument to the knime.Workflow class during instantiation. Separating into two arguments, workflow and workspace paths, is supported and fine but can sometimes cause unnecessary confusion.

I hope this helps,

Davin

Thanks @potts.

This one helped me.

import pathlib
exec_location = r"/mnt/C/Program Files/KNIME/knime.exe"
pathlib.Path(exec_location).exists()
False

exec_location2 = r"C:\Program Files\KNIME\knime.exe"
pathlib.Path(exec_location2).exists()
True

For some reason my code was not picking the location not through mount or absolute path. But thanks for your suggestion.

1 Like

Hi @potts I may need your help again though it may not be completely related. Still I have not found a way to access the location as mentioned earlier.

To give you a full context, I have 2 servers (aws linux and windows server). AWS linux server is used to install software like anaconda, python etc. Windows server is used to access applications (end user applications) like KNIME, google chrome etc.

Jupyter notebooks is running on linux server and I open it in chrome (using the ip on windows server). Now KNIME is installed in windows C:\Program Files\ and all my workflows will be saved in this server either C or D drive. I am trying to access these workflows from jupyter notebook. Tried several ways as below to access but in vain.

C:\Program Files\KNIME
\\\\myappserverip\\C:\\Program Files\\KNIME

Can you suggest a way to access workflows please. Thanks.

Hi @yash

Thus far, we have only discussed how to execute KNIME locally (that is, your Jupyter notebook and KNIME itself must be on the same system). Since your Jupyter notebook is running on the Linux server but KNIME AP is only installed on your Windows server, you should investigate the capability of knimepy to launch remote workflows via the KNIME Server. This example in the README for knimepy shows how to run remote workflows on a KNIME Server:
https://github.com/knime/knimepy#knime-server-example-execute-a-knime-workflow-on-a-remote-knime-server

It sounds like you have at least these two options:

  1. Get a KNIME Server (unless your organization already has one?), put your workflows on the KNIME Server, and then you can run those workflows remotely as in the example.
  2. Put your Jupyter notebook on the same system as the KNIME AP (Analytics Platform). This means either installing Anaconda (including Jupyter) on that Windows server or installing KNIME AP on that Linux server. Then you can run workflows locally (on the same system).

Ultimately, a Linux-based Jupyter notebook can run other Linux-based programs like KNIME AP installed on Linux or a Windows-based notebook can run the Windows version of KNIME AP but a program on Linux can not run something on a separate Windows system without help – that is where the KNIME Server comes in to help.

Thanks for sharing more about your setup – I hope these suggestions help,

Davin

1 Like

Hi @potts ,

Thanks for your reply. I will consider your suggestions.

But generally speaking, keeping knime aside, atleast python (jupyter notebooks) should be able to locate path of windows server right? Or am I talking something illogical because while working on Linux subsystem, windows location can be accessed by mount mnt. Same thing can be applied here if mounted right? Any thoughts on this?

Hi @yash

The Windows Subsystem for Linux (WSL) runs on a Windows system (your Windows server in particular) and thus can access files from most anywhere on your Windows system through paths that sometimes begin "/mnt/C/...". Just to make sure there is no confusion: your use of WSL on your Windows server and access to files there should not be confused with your use of your distinct Linux server and its files there – as separate machines, the one will not see the files of the other (Windows server versus Linux server).

Having data files, Jupyter notebooks, KNIME workflows, and other tools or supporting files scattered across multiple servers is a very common situation. Figuring out how an organization wants to manage these resources is an important discussion that has real impact for all involved. Sometimes organizations choose to adopt the use of a KNIME Server to create a shared space for all team members to store and share the workflows they create. I do not know if this will help your team in particular but it might help solve coordination headaches in the future for you or someone else.

Davin

Thanks @potts. I will try to install KNIME in linux machine.

BTW how do I install knime with linux commands? I tried wget knime.com/download-installer/6/64bit but didn’t work it seems. I suspect that is not the download link.

The video available in youtube shows installation from a GUI. Is it possible to do with commands?

Hello,

Are you trying to install KNIME Server, or KNIME AP in Linux?

Regards,
Nickolaus

Hi @NDekay I am trying to install KNIME AP in linux.