TTCompile
Note
@SQify-ed functions should be created at top level (non-indented) and must only contain legitimate SQ bodies per TickTalk rules.
The TTPython Graph Compiler takes a TTPython source file, reads it, creates an abstract syntax tree, walks the tree, and translates it into a TTPython graph. Here’s the compilation process, in a nutshell:
- Read the file 
- Find all - @SQify-ed functions (and any others with valid TTPython decorators), including those that might be found via- import. Instructions.py contains several examples.
- Build a table of them, indexed by their name, and attach to each the function body 
- Find the - @GRAPHify-ed function
- Extract and record the arguments as graph inputs 
- Walk the abstract syntax tree of the body, translating function calls into - SQinstances and interconnect these with- TTArcinstances to represent the flow of values from- SQoutputs to- SQinputs. There will be one- TTArcinstance per- SQoutput, and the- TTArcwill record the- SQinstances to which it delivers values (fan-out).
- Once complete, write out a representation of the graph ( - SQinstances and- TTArcinstances)
- ticktalkpython.Compiler.TTCompile(ttpython_path, library_path=None)
- Read a TTPython file and convert it to a - TTGraph. Save the graph in one or several output formats.- Parameters:
- ttpython_path (string) – the TTPython source file. 
- Returns:
- Returns the compiled graph 
- Return type:
 
- ticktalkpython.Compiler.add_topological_labels(graph, node_name_list)
- Adds topological labels to graph 
- ticktalkpython.Compiler.dump_json(graph, json_path)
- Dumps a TTGrph out as JSON 
- ticktalkpython.Compiler.dump_pickle(graph, pickle_path)
- Dumps a TTGraph out as Pickle 
- ticktalkpython.Compiler.label_dfs(graph, curr_node, curr_level, visited: set)
- Visit and label nodes in a bfs fashion from input to output direction. will (re)label the max path to a node. visited prevents infinite recursion caused by loops - Returns:
- Returns the max level in the graph 
- Return type:
- int 
 
- ticktalkpython.Compiler.safe_open(path, args)
- Open “path” for writing, creating any parent directories as needed.