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 SQ instances and interconnect these with TTArc instances to represent the flow of values from SQ outputs to SQ inputs. There will be one TTArc instance per SQ output, and the TTArc will record the SQ instances to which it delivers values (fan-out).

  • Once complete, write out a representation of the graph (SQ instances and TTArc instances)

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:

TTGraph

ticktalkpython.Compiler.add_topological_label(graph, node)

Adds topological label to graph

ticktalkpython.Compiler.add_topological_labels(graph, node_list)

Adds topological labels to graph

ticktalkpython.Compiler.draw_graph(ttgraph)

Create and display a TTGraph

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