ddeutil-model


Nameddeutil-model JSON
Version 0.0.3 PyPI version JSON
download
home_pageNone
SummaryData Developer & Engineer Model Utility Objects
upload_time2024-05-18 12:25:08
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9.13
licenseMIT
keywords data model utility pipeline
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Data Utility Package: *Model*

[![test](https://github.com/ddeutils/ddeutil-model/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/ddeutils/ddeutil-model/actions/workflows/tests.yml)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ddeutil-model?logo=pypi)](https://pypi.org/project/ddeutil-model/)
[![size](https://img.shields.io/github/languages/code-size/ddeutils/ddeutil-model)](https://github.com/ddeutils/ddeutil-model)

**Table of Contents**:

- [Installation](#installation)
- [Models](#models)
  - [Data Types](#data-types)
  - [Constraints](#constraints)
  - [Datasets](#datasets)
- [Usecase](#usecase)

This is **Model Utility**, implements any model objects for **Data Pipeline**
or **Data Platform**. The Model objects was implemented from the [Pydantic V2](https://docs.pydantic.dev/latest/).

The model able to handle common logic validations and able to adjust by custom code
for your specific requirements (Yeah, it just inherits Sub-Class from `BaseModel`).

## Installation

```shell
pip install -U ddeutil-model
```

## Models

### Data Types

```python
from ddeutil.model.dtype import StringType

dtype = StringType()
assert dtype.type == "string"
assert dtype.max_length == -1
```

### Constraints

```python
from ddeutil.model.const import Pk

const = Pk(of="foo", cols=["bar", "baz"])
assert const.name == "foo_bar_baz_pk"
assert const.cols == ["bar", "baz"]
```

### Datasets

```python
from ddeutil.model.datasets import Col, Tbl

tbl = Tbl(
  name="table_foo",
  features=[
    Col(name="id", dtype="integer primary key"),
    Col(name="foo", dtype="varchar( 10 )"),
  ],
)
assert tbl.name == "table_foo"
assert tbl.features[0].name == "id"
assert tbl.features[0].dtype.type == "integer"
```

## Usecase

If I have some catalog config, it easy to pass this config to model object.

```python
import yaml
from ddeutil.model.datasets import Scm


config = yaml.safe_load("""
name: "warehouse"
tables:
  - name: "customer_master"
    features:
      - name: "id"
        dtype: "integer"
        pk: true
      - name: "name"
        dtype: "varchar( 256 )"
        nullable: false
""")
schema = Scm.model_validate(config)
assert len(schema.tables) == 1
assert schema.tables[0].name == 'customer_master'
```

## License

This project was licensed under the terms of the [MIT license](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ddeutil-model",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9.13",
    "maintainer_email": null,
    "keywords": "data, model, utility, pipeline",
    "author": null,
    "author_email": "ddeutils <korawich.anu@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/3b/9b/941b18b47514844585208802fa9d2458afb5790da19d86c599a6f451f47b/ddeutil_model-0.0.3.tar.gz",
    "platform": null,
    "description": "# Data Utility Package: *Model*\n\n[![test](https://github.com/ddeutils/ddeutil-model/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/ddeutils/ddeutil-model/actions/workflows/tests.yml)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ddeutil-model?logo=pypi)](https://pypi.org/project/ddeutil-model/)\n[![size](https://img.shields.io/github/languages/code-size/ddeutils/ddeutil-model)](https://github.com/ddeutils/ddeutil-model)\n\n**Table of Contents**:\n\n- [Installation](#installation)\n- [Models](#models)\n  - [Data Types](#data-types)\n  - [Constraints](#constraints)\n  - [Datasets](#datasets)\n- [Usecase](#usecase)\n\nThis is **Model Utility**, implements any model objects for **Data Pipeline**\nor **Data Platform**. The Model objects was implemented from the [Pydantic V2](https://docs.pydantic.dev/latest/).\n\nThe model able to handle common logic validations and able to adjust by custom code\nfor your specific requirements (Yeah, it just inherits Sub-Class from `BaseModel`).\n\n## Installation\n\n```shell\npip install -U ddeutil-model\n```\n\n## Models\n\n### Data Types\n\n```python\nfrom ddeutil.model.dtype import StringType\n\ndtype = StringType()\nassert dtype.type == \"string\"\nassert dtype.max_length == -1\n```\n\n### Constraints\n\n```python\nfrom ddeutil.model.const import Pk\n\nconst = Pk(of=\"foo\", cols=[\"bar\", \"baz\"])\nassert const.name == \"foo_bar_baz_pk\"\nassert const.cols == [\"bar\", \"baz\"]\n```\n\n### Datasets\n\n```python\nfrom ddeutil.model.datasets import Col, Tbl\n\ntbl = Tbl(\n  name=\"table_foo\",\n  features=[\n    Col(name=\"id\", dtype=\"integer primary key\"),\n    Col(name=\"foo\", dtype=\"varchar( 10 )\"),\n  ],\n)\nassert tbl.name == \"table_foo\"\nassert tbl.features[0].name == \"id\"\nassert tbl.features[0].dtype.type == \"integer\"\n```\n\n## Usecase\n\nIf I have some catalog config, it easy to pass this config to model object.\n\n```python\nimport yaml\nfrom ddeutil.model.datasets import Scm\n\n\nconfig = yaml.safe_load(\"\"\"\nname: \"warehouse\"\ntables:\n  - name: \"customer_master\"\n    features:\n      - name: \"id\"\n        dtype: \"integer\"\n        pk: true\n      - name: \"name\"\n        dtype: \"varchar( 256 )\"\n        nullable: false\n\"\"\")\nschema = Scm.model_validate(config)\nassert len(schema.tables) == 1\nassert schema.tables[0].name == 'customer_master'\n```\n\n## License\n\nThis project was licensed under the terms of the [MIT license](LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Data Developer & Engineer Model Utility Objects",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/ddeutils/ddeutil-model/",
        "Source Code": "https://github.com/ddeutils/ddeutil-model/"
    },
    "split_keywords": [
        "data",
        " model",
        " utility",
        " pipeline"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6fb757bc5ad2237ba7ca86a8775c43b29ce9934dffadb5496f8fac2ad3591861",
                "md5": "1d8c02ce7e9c61d1a59b581c09e3d038",
                "sha256": "0f1638c987ea98d23a7e60fd81360df3ff36e6c9ee758fff02fe3fc6d1b45b82"
            },
            "downloads": -1,
            "filename": "ddeutil_model-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1d8c02ce7e9c61d1a59b581c09e3d038",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.13",
            "size": 17992,
            "upload_time": "2024-05-18T12:25:06",
            "upload_time_iso_8601": "2024-05-18T12:25:06.832601Z",
            "url": "https://files.pythonhosted.org/packages/6f/b7/57bc5ad2237ba7ca86a8775c43b29ce9934dffadb5496f8fac2ad3591861/ddeutil_model-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b9b941b18b47514844585208802fa9d2458afb5790da19d86c599a6f451f47b",
                "md5": "aa8278ca3b0db9457d281c51801eaf22",
                "sha256": "c74dbfae28896173790422a923eaa5ba011a5bf1fd7cc9331a88e4b0f0d33ea3"
            },
            "downloads": -1,
            "filename": "ddeutil_model-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "aa8278ca3b0db9457d281c51801eaf22",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.13",
            "size": 17953,
            "upload_time": "2024-05-18T12:25:08",
            "upload_time_iso_8601": "2024-05-18T12:25:08.468861Z",
            "url": "https://files.pythonhosted.org/packages/3b/9b/941b18b47514844585208802fa9d2458afb5790da19d86c599a6f451f47b/ddeutil_model-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-18 12:25:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ddeutils",
    "github_project": "ddeutil-model",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ddeutil-model"
}
        
Elapsed time: 0.26101s