Function main
Legacy. Use run instead.
The main
function is one of two functions executed by the Python scripting - with input table operator (the other being simple_main
).
Other than simple_main
, this function does not return a result table, but rather a list of workflows, each containing a sequence of asynchronous generators.
To understand the workings of this, it helps to be familiar with generators, asynchronous generators and coroutines.
The function takes the following arguments
params
: parameters of the current project as dictionary mapping parameter name → parameter valueinputs
: list of generators that yield a current result table row-by-row, whereinputs[0]
yields the current result table andinputs[i]
for i>0 the result tables tables of data nodes referenced in the operator settings.outputs
: list of generators that yield the new result table(s) row-by-row whereoutputs[0]
yields the updated result table. In the current version, only this table can be used.**kwargs
: dictionary of additional arguments. Among these are:filereaders
: list of asyncio.StreamReader objects for reading TIS files asynchronously. Refer to TIS File I/O for more details. Available starting from TIS v6.2.filewriters
: list ofBufferedStreamWriter
objects for writing TIS files asynchronously. Refer to TIS File I/O for more details. Available starting from TIS v6.2.sessionUrl, sessionToken
: current session's token and URL for pytisapi use. e.g.wi
th Editor.from_token(baseurl
=
kwargs[
'sessionUrl'
], token
=
kwargs[
'sessionToken'
]) as tiseditor:
v6.2
The function returns
- a list of workflows, and
- a dictionary mapping table → function where
- table is an input or output table contained in
inputs
oroutputs,
and - function is a function returning references to two dictionaries
types
andcolumns
for each table. These dictionaries are declared at the beginning of the main function and contain the tables' schema information as follows>types
: data types of columns in result table as dictionary mapping column index → type, andcolumns
: column names of result table as dictionary mapping column name → column index.
- table is an input or output table contained in
The python operator links the schema information of each table referenced in the second return value to the respective function and then builds an event loop to process the workflow.