Some major changes to the library:
* Added support for defining graphs in native Python
* Added support for running graphs within nodes of currently running graphs
And one breaking change to the existing API:
* Changed usage of collections returned from `matcher` nodetypes
Define Graphs in Native Python
By leveraging operator and call overloading, `conflagrate` now supports defining graphs using native Python syntax. The snippet below is part of the new `native_python` example in the `examples` directory:
python
from conflagrate import Graph, Node
class NativePythonGraph(Graph):
start = Node(label="Get Name", type="salutation")
welcome = Node(label="Greeting", type="greeting")
start > welcome
Graphs defined in Python can then be instantiated and passed directly to the `run` or `run_graph` functions:
python
run(NativePythonGraph(), "start")
They can also be exported to Graphviz `dot` files or directly to PNG (requires Graphviz to be installed):
python
NativePythonGraph.to_graphviz("NativePythonGraph.dot")
NativePythonGraph.to_png("NativePythonGraph.png")
Run Other Graphs within Running Graphs (Run Subgraphs)
The new `run_graph()` coroutine function allows graphs to be executed within applications already using `asyncio`. This includes within nodetypes defined using `async def`. Coupled with native Python graphs, this allows the following example nodetype:
python
nodetype("run_subgraph")
async def run_subgraph() -> None:
await run_graph(Subgraph(), "start")