TTSQExecute
The TTSQExecute encapsulates the portion of an SQ that is actually executed at
runtime after the input values have been gathered and synchronized to produce a
TTExecutionContext
. This portion of the SQ contains the code to execute,
keyword arguments to provide, and local state.
The TTSQExecute can be serialized/pickleized without copying other parts of the graph, making it easier to send through the network than a TTSQ would be, given that the input arcs connecting the graph would cause the entire graph to be serialized any time a TTSQ with valid arcs is.
- class ticktalkpython.SQExecute.TTSQExecute(sq_name, interpreter, code, function_name, pattern, num_inputs, execution_kwargs=None, is_sequential=False, is_conditional=False, is_persistent=False)
The execution portion of an SQ. Created at compile time and instantiated with runtime elements (like clocks) after being distributed to the ensembles.
- Parameters:
sq_name (string) – The name of the SQ
interpreter (TTInterpreter) – A enumeration for the interpretation environment type
code (string) – The code that composes the SQ’s execution portion. Obtained by unparsing the defined function’s abstract syntax tree
function_name (string) – The name of the function within the code, which is decorated with ‘SQify’ or ‘STREAMify’
pattern (TTSQPattern) – The input/output pattern of this SQ
num_inputs (int) – The number of inputs; used to check keyword and postitional arguments before executing the SQ
execution_kwargs (dict) – A set of keyword arguments that provide/overwrite default arguments to the SQ. Some may be used as specification for how to treat the SQ outside of the code. Defaults to an empty dictionary
is_sequential (bool) – A boolean indicator for whether this function should be executed sequentially (chronologically) or not. This is based on whether it is a streaming node and uses internal state between invocations. If True, it will enforce execution on sequential tokens by sending feedback to the synchronization portion of the SQ. Must be paired with a
SequentialRetrigger
firing rule
- static from_json(json_in)
Convert a JSON formatted SQ specification into a TTExecute object. Format follows
TTSQ.json_execute
- Parameters:
json (dict) – JSON dictionary containing the SQ (specifically, the Execute section (key ‘program’))
- inspect_function()
Inspect the actual function definition to look for any meta arguments in the definition, like
TTExecuteOnFullToken
- instantiate_at_runtime(clocks, simulated=False)
Prior to execution, instantiate the SQ’s execution environment.
This speeds up the runtime by not having to interpret the code as generically by pre-compiling the code and creating a private namespace to store internal state and imports.
This also looks at the set of keyword arguments and handles meta keywords like ‘TTClock’ or ‘TTDataValidityInterval’ that dictate how to time-label streaming sources (STREAMify)