Extract Context Properties - Absolute Path not valid

Hello,

when using the “Extract Context Properties” the context.workflow.absolute-path value is not a valid path.

As per the attached screenshot the path provided is not valid can be used in downstream nodes.

In my use case i am using the absolute-path value to derive the path of file for a downstream python node. The workflow executes successfully when running locally however when execute on Knime Business hub, the python node fails as the path is not found/valid.

Any suggestions for a workaround or fix?

Hi,
I just tried it on my Hub and my file path looks like this: /tmp/*oaDafsLpf7wjNDR_11335252890352028965/AbsolutePathTest. I passed that to a Python Script with this code:

import knime.scripting.io as knio
import os
import pandas as pd

# specify the directory you want to list files from
directory = knio.flow_variables["context.workflow.absolute-path"] + '/data'

# use os.listdir to get the list of files
files = os.listdir(directory)

# convert the list of files to a pandas DataFrame
df = pd.DataFrame(files, columns=['File Names'])

# output the DataFrame as a KNIME table
knio.output_tables[0] = knio.Table.from_pandas(df)

And that script correctly listed the files in the data directory of my workflow.
Kind regards,
Alexander

Hey @AlexanderFillbrunn,

Thanks for the follow up on this one.

You are correct sir. Not sure what error i was seeing previously but this is now working as expected. Apologies for the false alarm.

Please consider this one solved and a non-issue

Thanks
Andrew

1 Like

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