Closed stuaxo closed 4 years ago
Output format is implemented as a function in notebook.
Updated implementation to use function to transform output.
Closing as json output implemented.
transformations as node based thing will probably come later.
There's something in this that doesn't seem quite right:
With this, we get newline delimited json, which is format in itself, but not as standard as say outputting the whole Graph as json.
To output the whole graph as json we could do this:
print(graph.as_json())
or if we want streaming, something like this:
There are two concepts in here - output target "console" and output format "json".
We could create the concept of a Transform that takes a node and outputs another node or some other data format.
node->transform->node
ornode->transform->data
as_json
would be a transform that accepts some nodes and output json.ConsoleRenderer
by default would haveas_json
as it's output transform, to output standard python objects the user could specify this in the constructor:ConsoleRender(outputtransformer=None)
.This abstraction should work well for format variants (e.g. newline delimited json) as we have a place to put this.
Being able to transform objects in a graph into other things should be quite powerful, the
hair
examples innodebox1
/shoebot
work by iterating paths and replacing them with new generated paths, maybe this concept can be used for the same sort of thing, by having transformer ofpath->path
.This should fit well with the graph analogy of components we can clip together.