grafo


Namegrafo JSON
Version 0.2.4 PyPI version JSON
download
home_pageNone
SummaryA library for building runnable asynchronous trees
upload_time2025-02-19 01:07:37
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseMIT
keywords asynchronous trees library
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## What ##
A simple library for building runnable async trees. Trees are a web of interconnected Nodes, which contain code to be run. The number of workers is automatically managed (optional).

Use:

```
# Declare your nodes
root_node = Node(...)
child1 = Node(...)
child2 = Node(...)
grandchild = Node(...)

# Set the layout
nodes = {
    root_node: {
        child1: [grandchild],
        child2: [grandchild], # grandchild_node will wait for child1 and child2 to complete before running
    }
}

# Use the '|' operator to connect the nodes
executor = AsyncTreeExecutor(logger=logger)
tree = executor | nodes
result = await tree.run()
```

Powered by `asyncio` (https://docs.python.org/3/library/asyncio.html)

## How ##
- You have a tree of interconected `Nodes` and an `asyncio.Queue()`
- Upon each Node's execution, it removes itself from the queue and enqueues its children up next

## Axioms ##
1) A tree must include a designated root node, and there can be only one unique root.
2) Children start running as soon as all their parent's are finished.
3) There's no passing of state between nodes - you can handle that however you see fit

## Important ##
- Node properties are generally accessible, but are immutable during a node's runtime (do not confuse with the tree's runtime).
- Coroutines and callbacks will always receive the `node` as their first (positional) argument. Everything else if a `keyword argument`.
- `on_before_run` and `on_after_run` callbacks must be asynchronous

## Installation ##
- `pip install grafo` to install on your environment
- `pytest` to run tests, add `-s` flag for tests to run `print` statements

## Zen ##
1. Follow established names: a Node is a Node, not a "Leaf".
2. Syntax sugar is sweet in moderation.
3. Give the programmer granular control.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "grafo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "asynchronous, trees, library",
    "author": null,
    "author_email": "\"@paulomtts\" <paulomtts@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/75/c7/96722c3cba4c54d3915b64fe7e658d80efedd949918b453910b6614eac97/grafo-0.2.4.tar.gz",
    "platform": null,
    "description": "## What ##\nA simple library for building runnable async trees. Trees are a web of interconnected Nodes, which contain code to be run. The number of workers is automatically managed (optional).\n\nUse:\n\n```\n# Declare your nodes\nroot_node = Node(...)\nchild1 = Node(...)\nchild2 = Node(...)\ngrandchild = Node(...)\n\n# Set the layout\nnodes = {\n    root_node: {\n        child1: [grandchild],\n        child2: [grandchild], # grandchild_node will wait for child1 and child2 to complete before running\n    }\n}\n\n# Use the '|' operator to connect the nodes\nexecutor = AsyncTreeExecutor(logger=logger)\ntree = executor | nodes\nresult = await tree.run()\n```\n\nPowered by `asyncio` (https://docs.python.org/3/library/asyncio.html)\n\n## How ##\n- You have a tree of interconected `Nodes` and an `asyncio.Queue()`\n- Upon each Node's execution, it removes itself from the queue and enqueues its children up next\n\n## Axioms ##\n1) A tree must include a designated root node, and there can be only one unique root.\n2) Children start running as soon as all their parent's are finished.\n3) There's no passing of state between nodes - you can handle that however you see fit\n\n## Important ##\n- Node properties are generally accessible, but are immutable during a node's runtime (do not confuse with the tree's runtime).\n- Coroutines and callbacks will always receive the `node` as their first (positional) argument. Everything else if a `keyword argument`.\n- `on_before_run` and `on_after_run` callbacks must be asynchronous\n\n## Installation ##\n- `pip install grafo` to install on your environment\n- `pytest` to run tests, add `-s` flag for tests to run `print` statements\n\n## Zen ##\n1. Follow established names: a Node is a Node, not a \"Leaf\".\n2. Syntax sugar is sweet in moderation.\n3. Give the programmer granular control.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library for building runnable asynchronous trees",
    "version": "0.2.4",
    "project_urls": {
        "Homepage": "https://github.com/HappyLoop/grafo"
    },
    "split_keywords": [
        "asynchronous",
        " trees",
        " library"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "048817e5faee8f5fa66d3c92c626869a73560a2a1ef7da629ec7a12fc92cf8c7",
                "md5": "709633856ceec00976f4485bc8e959fa",
                "sha256": "829d8a0d2e8c3aac9d7bf78d0565d4fe842044652e7cc9afa974aeb37693ebf4"
            },
            "downloads": -1,
            "filename": "grafo-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "709633856ceec00976f4485bc8e959fa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8325,
            "upload_time": "2025-02-19T01:07:35",
            "upload_time_iso_8601": "2025-02-19T01:07:35.656805Z",
            "url": "https://files.pythonhosted.org/packages/04/88/17e5faee8f5fa66d3c92c626869a73560a2a1ef7da629ec7a12fc92cf8c7/grafo-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "75c796722c3cba4c54d3915b64fe7e658d80efedd949918b453910b6614eac97",
                "md5": "0d2f6c8c4fc4f868080c017ddf33b248",
                "sha256": "3cac9a65005509907d18a6517d81cf62e4094edb368d7addb7ae473422ab4422"
            },
            "downloads": -1,
            "filename": "grafo-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "0d2f6c8c4fc4f868080c017ddf33b248",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9409,
            "upload_time": "2025-02-19T01:07:37",
            "upload_time_iso_8601": "2025-02-19T01:07:37.935595Z",
            "url": "https://files.pythonhosted.org/packages/75/c7/96722c3cba4c54d3915b64fe7e658d80efedd949918b453910b6614eac97/grafo-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-19 01:07:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "HappyLoop",
    "github_project": "grafo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "grafo"
}
        
Elapsed time: 0.43110s