unimog


Nameunimog JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/eliias/unimog
SummaryElegant service objects for Python.
upload_time2024-03-22 13:17:41
maintainerNone
docs_urlNone
authorHannes Moser
requires_python<4.0,>=3.11
licenseMIT
keywords service object organize action business logic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # unimog

> Elegant service objects for Python.

A robust and flexible framework that facilitates composable business logic and
ensures uniform error handling for various business logic actions. The
fundamental concept revolves around the idea that a single action should
perform a specific task, and these actions can be seamlessly organized into
groups. Notably, these groups and actions can be intricately nested, forming
complex Directed Acyclic Graphs (DAGs).

To enhance readability and maintainability, we leverage the concept of service
objects to encapsulate intricate business logic in an easily understandable
format. Establishing a normalized interface for all service calls not only
streamlines the overall architecture but also enables the chaining of service
calls. This consistent approach to handling errors across the entire framework
ensures a standardized and predictable error-handling mechanism, contributing
to the reliability of the system.

## Usage

```bash
pip install unimog
```

### Action

```python
import gzip
from dataclasses import dataclass

from unimog import Action, Context


@dataclass
class Input(Context):
    text: str


@dataclass
class Output(Input):
    compressed_text: str


class CompressText(Action):
    def perform(self):
        compressed_text = gzip.compress(self.input.text)
        self.output.compressed_text = compressed_text

result = CompressText(Input, Output)(text="Hello, World!")
result.is_success # True
result.compressed_text # b'\x1f\x8b\x08\x00r\x92\xb7e…
```

### Organizer

```python
import gzip
from dataclasses import dataclass

from unimog import Action, Context, Organizer


@dataclass
class MyContext(Context):
    text: str = None
    compressed_text: str = None

    
class CompressText(Action):
    def perform(self):
        compressed_text = gzip.compress(self.input.text)
        self.output.compressed_text = compressed_text

    
class DecompressText(Action):
    def perform(self):
        text = gzip.decompress(self.input.compressed_text)
        self.output.text = text


CompressAndDecompressText = Organizer(
    CompressText(MyContext, MyContext),
    DecompressText(MyContext, MyContext)
)

result = CompressAndDecompressText(text="Hello, World!")
result.is_success # True
result.text # "Hello, World!"
```

## Contributing

### Tests

```bash
python -m pytest
```

### Release

Bump version number accordingly (semantic versioning).

```bash
poetry build
poetry publish
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/eliias/unimog",
    "name": "unimog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "service object, organize, action, business logic",
    "author": "Hannes Moser",
    "author_email": "box@hannesmoser.at",
    "download_url": "https://files.pythonhosted.org/packages/33/14/44fc6c2c5e504b401e58d7f0b5a39ebf03fe63e61d8aad60458cac424341/unimog-0.3.0.tar.gz",
    "platform": null,
    "description": "# unimog\n\n> Elegant service objects for Python.\n\nA robust and flexible framework that facilitates composable business logic and\nensures uniform error handling for various business logic actions. The\nfundamental concept revolves around the idea that a single action should\nperform a specific task, and these actions can be seamlessly organized into\ngroups. Notably, these groups and actions can be intricately nested, forming\ncomplex Directed Acyclic Graphs (DAGs).\n\nTo enhance readability and maintainability, we leverage the concept of service\nobjects to encapsulate intricate business logic in an easily understandable\nformat. Establishing a normalized interface for all service calls not only\nstreamlines the overall architecture but also enables the chaining of service\ncalls. This consistent approach to handling errors across the entire framework\nensures a standardized and predictable error-handling mechanism, contributing\nto the reliability of the system.\n\n## Usage\n\n```bash\npip install unimog\n```\n\n### Action\n\n```python\nimport gzip\nfrom dataclasses import dataclass\n\nfrom unimog import Action, Context\n\n\n@dataclass\nclass Input(Context):\n    text: str\n\n\n@dataclass\nclass Output(Input):\n    compressed_text: str\n\n\nclass CompressText(Action):\n    def perform(self):\n        compressed_text = gzip.compress(self.input.text)\n        self.output.compressed_text = compressed_text\n\nresult = CompressText(Input, Output)(text=\"Hello, World!\")\nresult.is_success # True\nresult.compressed_text # b'\\x1f\\x8b\\x08\\x00r\\x92\\xb7e\u2026\n```\n\n### Organizer\n\n```python\nimport gzip\nfrom dataclasses import dataclass\n\nfrom unimog import Action, Context, Organizer\n\n\n@dataclass\nclass MyContext(Context):\n    text: str = None\n    compressed_text: str = None\n\n    \nclass CompressText(Action):\n    def perform(self):\n        compressed_text = gzip.compress(self.input.text)\n        self.output.compressed_text = compressed_text\n\n    \nclass DecompressText(Action):\n    def perform(self):\n        text = gzip.decompress(self.input.compressed_text)\n        self.output.text = text\n\n\nCompressAndDecompressText = Organizer(\n    CompressText(MyContext, MyContext),\n    DecompressText(MyContext, MyContext)\n)\n\nresult = CompressAndDecompressText(text=\"Hello, World!\")\nresult.is_success # True\nresult.text # \"Hello, World!\"\n```\n\n## Contributing\n\n### Tests\n\n```bash\npython -m pytest\n```\n\n### Release\n\nBump version number accordingly (semantic versioning).\n\n```bash\npoetry build\npoetry publish\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Elegant service objects for Python.",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/eliias/unimog",
        "Repository": "https://github.com/eliias/unimog"
    },
    "split_keywords": [
        "service object",
        " organize",
        " action",
        " business logic"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df8e7412dce6b0e2227db46a80d504e7af7f877e9c71e09e08470b28ace57059",
                "md5": "764f86109dfcb586ff51f655d5fd94e0",
                "sha256": "59116f9a68b7b4f395e106f67e68415f9cba4d040b12bc1f79e3ba7eeb796276"
            },
            "downloads": -1,
            "filename": "unimog-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "764f86109dfcb586ff51f655d5fd94e0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 4402,
            "upload_time": "2024-03-22T13:17:39",
            "upload_time_iso_8601": "2024-03-22T13:17:39.427143Z",
            "url": "https://files.pythonhosted.org/packages/df/8e/7412dce6b0e2227db46a80d504e7af7f877e9c71e09e08470b28ace57059/unimog-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "331444fc6c2c5e504b401e58d7f0b5a39ebf03fe63e61d8aad60458cac424341",
                "md5": "3deb64310f919c72d3e2db7f8faccc4a",
                "sha256": "a06afb82a2160dd82d0a8b37a2834760538a643d77007f68173928fd5cf16b57"
            },
            "downloads": -1,
            "filename": "unimog-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3deb64310f919c72d3e2db7f8faccc4a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 3503,
            "upload_time": "2024-03-22T13:17:41",
            "upload_time_iso_8601": "2024-03-22T13:17:41.105302Z",
            "url": "https://files.pythonhosted.org/packages/33/14/44fc6c2c5e504b401e58d7f0b5a39ebf03fe63e61d8aad60458cac424341/unimog-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-22 13:17:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "eliias",
    "github_project": "unimog",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "unimog"
}
        
Elapsed time: 0.20020s