Summary
Applies a python script on input data. Additional input data nodes may be specified.
Example:
Situation | |
---|---|
Settings | |
Result | |
Project-File |
Simple Main
The simple_main method is available starting from version 6.0 of TIS. In older versions you need to provide a wrapper class. Write your code into the simple_main method.
simplemain.py
class
SimpleMain:
# Wrapper for simple_main(params, sponge_list, types, columns).
types
=
{}
columns
=
{}
def
__init__(
self
, user_script, params, inp):
self
.user_script
=
user_script
self
.params
=
params
self
.inp
=
inp
async
def
sponge(
self
):
# Async generator that yields results from user_script.
for
res
in
self
.user_script(
self
.params,
[row async
for
row
in
self
.inp],
self
.types,
self
.columns):
yield
res
def
get_types_columns(
self
):
# Return pair of types and columns.
return
self
.types,
self
.columns
def
simple_main(params, mylist, types, columns):
#
# do something
#
return
mylist
def
main(params, inputs, outputs):
inp, out
=
inputs[
0
], outputs[
0
]
simple
=
SimpleMain(simple_main, params, inp)
return
[(simple.sponge(), out)], {
inp: simple.get_types_columns,
out: simple.get_types_columns
}
Want to learn more?
Related topics
- Starting to work with python for consultants