Conflagrate

Latest version: v0.1.2

Safety actively analyzes 623035 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.1.2

Developers can now use the optional keyword-only argument `start_node_args` to the `run()` and `run_graph()` functions to pass input arguments to the first node in the graph. Also, the `run_graph()` coroutine will return the return value (or thrown exception) of the last branch to terminate in the executed graph. This provides better ergonomics for passing data into subgraphs and retrieving products.

The new `subgraph` example in the `examples` directory shows how it can be used:
python
nodetype("run_subgraph")
async def run_subgraph(name: str) -> str:
return await run_graph(Subgraph(), "sub_start", start_node_args=(name,))

0.1.1

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")

0.0.2

A few bug fixes:
* Branches now properly tracked as terminated when a matcher node doesn't find a match and exits.
* Branches now properly tracked as terminated when a node throws an exception.
* Node types parsed from GraphViz now have double quotes (`"`) stripped to better support types with special characters.
Now also including (some) unit tests!

0.0.1

================
Initial release.

See the `examples` source directory for sample usages of `conflagrate` 0.0.1!

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.