As part of a workflow that will be deployed to a KNIME server I need to:
a) create a temp folder within the workflow directory - done!
b) get the path relative to the local workflow data area - done!
c) get the local file path for that new folder e.g. C:\KNIME\WorkFlows\CoolFlow\data\Process\6cfc7cf6-011d-4819-aee9-663019823951 - NOT done
I know I can hardcode strings to append and create a local file path, but, this part of the flow, is / will be a component which will be used by my colleagues and should work where ever its used.
Does the KNIME collective have the answer to this?
I have uploaded the flow that I have been playing with:
There is probably a KNIME node to get the current working directory. If not, then you can paste the following into a Python Script node. You will need to remove the input table and leave the output table on the node (three dots on node gives a menu to remove ports).
import knime.scripting.io as knio
import pandas as pd
import os
cwd = os.getcwd()
knio.output_tables[0] = knio.Table.from_pandas(
pd.DataFrame([{"cwd": cwd}])
)
If you run this node it will output a table with the root of the current workspace directory.
Hi @FrankColumbo , if the file you are creating is always relative to the workflow data area, you can find the workflow data folder absolute path from the Extract Context Properties node. This returns a set of contextual flow variables. One of these is the context.workflow.absolute-path which is a String containing the absolute path to your workflow. The data area will then be this plus “/data” and you can concatenate your random folder name on to that.
The attached shows two ways of returning this as a String (using Variable Expressions, or String Manipulation (Variable) nodes )