This function is available in both the Python scripting - with input table and the Python scripting operators. It can read Result Tables of various data nodes, read and write Parameters and TIS Files, and write TIS Tables. It can further access some meta information like timeout or version.

The signature of the function is

async def run(params, in_tables, out_tables, in_files, out_files, misc)

The arguments are as follows.

Argument

Description

Examples

params

Dictionary with tracking function that contains all Parameters of the current project.

Most standard python dictionary methods are provided.

It is not possible to add a parameter.


Read parameter
param_value = params["Parameter name"]
param_value = params.get("Parameter name", "Default value")
Write parameter
params["Parameter name"] = "New value"

in_tables

List of objects representing result tables.

in_tables[0] refers to the current result table.

in_tables[i] with i>0 refers to the result tables of the input data nodes defined in the operator setting.

read column names as dictionary {column_name : column_index}:

types = in_tables[0].columns


read column types as dictionary {column_index : column_type}:

types = in_tables[0].types


read rows synchronously:

rows = await intables[0].rows()


read rows asynchronously:

async for row in intables[1].rows_async(): pass


out_tables

List of objects representing TIS Tables defined in the operator setting.

out_tables[0] refers to the result table of the operator.

out_tables[i] with i>0 refers to the specified table sset up in the operator settings.

Set column names and types as schema tuple:

table_schema = (('Col 1', str),
('Col 2', int),)
out_tables[0].set_schema(table_schema)


Set column names and types as dictionaries:

out_tables[0].columns = { 'Col 1': 0, 'Col 2': 1 }
out_tables[0].types = { 0: str, 1: int }


Write rows synchronously:

out_tables[0].rows = [ [ 'asdf', 3 ], [ 'opqw' , -1 ] ]


Write rows asynchronously:

for row in rows:
await outtables[1].send_row(row)

in_files

List of paths to TIS Files that can be read by the script.

Read file synchronously:

textreader = await in_files[0].textreader(encoding='UTF-8', errors='strict', newline='\r\n')
for line in textreader:
line.strip('\r\n')

Read file asynchronously:

textreader = in_files[1].textreader_async(encoding='UTF-8', errors='strict', newline='\r\n')
async for line in textreader:
line.strip('\r\n')

out_files

List of paths to TIS Files that can be written by the script.

Write file synchronously:

textwriter = out_files[0].textwriter(encoding='UTF-8', errors='strict')
lines = [ 'test output 0 line 1\n', 'test output 0 line 2\n' ]
textwriter.writelines(lines)


Write file asynchronously:

textwriter = out_files[1].textwriter_async(encoding='UTF-8', errors='strict')
lines = [ 'test output 0 line 1\n', 'test output 0 line 2\n' ]
for line in lines:
await textwriter.writelines_async(line)

misc

Access to various meta data

print('Session URL: %s' % misc.session_url)
print('Session token: %s' % misc.session_token)
print('Session token: %s' % misc.timeout)
print('Session token: %s' % misc.version)