grafo


Namegrafo JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/HappyLoop/grafo
SummaryA library for building runnable asynchronous trees
upload_time2024-06-12 17:02:15
maintainerNone
docs_urlNone
authorHappyLoop @paulomtts
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## What ##
A simple library for building runnable tree structures. Trees are built using Nodes, which
contain code to be run.

Use:

```
# Declare your nodes
root_node = Node(...)
child_node1 = Node(...)
child_node2 = Node(...)
grandchild_node1 = Node(...)

# Set the layout
nodes = {
    root_node: {
        child_node1: None,
        child_node2: [grandchild_node1],
    }
}

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

Powered by `asyncio` & `instructor`!

- `asyncio`: https://docs.python.org/3/library/asyncio.html
- `instructor`: https://python.useinstructor.com/

## How ##
- You have a tree of interconected `Nodes` and an `asyncio.Queue()`
- Upon each Node's execution, it queues its children up next
- Workers stop when they find a `None` in the queue
- ⚠️ Be careful with UnionNodes, they can cause invisible deadlocks. ⚠️

## Axioms ##
1) A tree can only have one root node.
2) Nodes can be run concurrently.
3) Dictionary outputs are passed as kwargs to children. All other types are passed as args.
4) UnionNodes can never be direct children of PickerNodes.

## 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.

## During Development ##
- `pip install -e .` to install on your environment
- `pytest` to run tests, add `-s` flag for tests to run `print` statements

## Extras ##
[![Pydantic is All You Need](https://i3.ytimg.com/vi/yj-wSRJwrrc/hqdefault.jpg)](https://www.youtube.com/embed/yj-wSRJwrrc)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/HappyLoop/grafo",
    "name": "grafo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "HappyLoop @paulomtts",
    "author_email": "dev@happyloop.com",
    "download_url": "https://files.pythonhosted.org/packages/22/20/ed3cd4fbbed994d5354d4d47ad57ed79c19bbe3aef3d206ddc5d4031da4f/grafo-0.1.5.tar.gz",
    "platform": null,
    "description": "## What ##\nA simple library for building runnable tree structures. Trees are built using Nodes, which\ncontain code to be run.\n\nUse:\n\n```\n# Declare your nodes\nroot_node = Node(...)\nchild_node1 = Node(...)\nchild_node2 = Node(...)\ngrandchild_node1 = Node(...)\n\n# Set the layout\nnodes = {\n    root_node: {\n        child_node1: None,\n        child_node2: [grandchild_node1],\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` & `instructor`!\n\n- `asyncio`: https://docs.python.org/3/library/asyncio.html\n- `instructor`: https://python.useinstructor.com/\n\n## How ##\n- You have a tree of interconected `Nodes` and an `asyncio.Queue()`\n- Upon each Node's execution, it queues its children up next\n- Workers stop when they find a `None` in the queue\n- \u26a0\ufe0f Be careful with UnionNodes, they can cause invisible deadlocks. \u26a0\ufe0f\n\n## Axioms ##\n1) A tree can only have one root node.\n2) Nodes can be run concurrently.\n3) Dictionary outputs are passed as kwargs to children. All other types are passed as args.\n4) UnionNodes can never be direct children of PickerNodes.\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\n## During Development ##\n- `pip install -e .` to install on your environment\n- `pytest` to run tests, add `-s` flag for tests to run `print` statements\n\n## Extras ##\n[![Pydantic is All You Need](https://i3.ytimg.com/vi/yj-wSRJwrrc/hqdefault.jpg)](https://www.youtube.com/embed/yj-wSRJwrrc)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A library for building runnable asynchronous trees",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/HappyLoop/grafo"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "032c1fe9c69298e8940bea550ff499f657886c00b53cc5dbe56acbc3c03d34ad",
                "md5": "7f2ad220014224ea1158e81240acddd1",
                "sha256": "f7348d1eac69b4d5b6b42d2f3edd7397fabd0280ac916776fb1a5d0afb92aed5"
            },
            "downloads": -1,
            "filename": "grafo-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7f2ad220014224ea1158e81240acddd1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10954,
            "upload_time": "2024-06-12T17:02:13",
            "upload_time_iso_8601": "2024-06-12T17:02:13.678000Z",
            "url": "https://files.pythonhosted.org/packages/03/2c/1fe9c69298e8940bea550ff499f657886c00b53cc5dbe56acbc3c03d34ad/grafo-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2220ed3cd4fbbed994d5354d4d47ad57ed79c19bbe3aef3d206ddc5d4031da4f",
                "md5": "c975377e9e5938c44234b261ba8eafaf",
                "sha256": "57a397656ced1a3b21ab798aec30e108111a7f742c822e1b8ca5283430d5c517"
            },
            "downloads": -1,
            "filename": "grafo-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "c975377e9e5938c44234b261ba8eafaf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 13597,
            "upload_time": "2024-06-12T17:02:15",
            "upload_time_iso_8601": "2024-06-12T17:02:15.593080Z",
            "url": "https://files.pythonhosted.org/packages/22/20/ed3cd4fbbed994d5354d4d47ad57ed79c19bbe3aef3d206ddc5d4031da4f/grafo-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-12 17:02:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "HappyLoop",
    "github_project": "grafo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "grafo"
}
        
Elapsed time: 0.23457s