Name | ddeutil-model JSON |
Version |
0.0.4
JSON |
| download |
home_page | None |
Summary | Data Developer & Engineer Model Utility Objects |
upload_time | 2024-05-20 04:45:13 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9.13 |
license | MIT |
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 **Utility Models**, it implements any models for **Data Pipeline**,
or **Data Platform** frameworks. The Model objects was implemented from the [Pydantic V2](https://docs.pydantic.dev/latest/)
which is the powerful parsing and serializing data model to the Python object.
> [!NOTE]
> So, I use this project to learn and implement a limit and trick of the Pydantic
> package.
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/9e/58/b0db36dd0e65e889b4e430e8c93045311c706b1f676c09858808ed9f551d/ddeutil_model-0.0.4.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 **Utility Models**, it implements any models for **Data Pipeline**,\nor **Data Platform** frameworks. The Model objects was implemented from the [Pydantic V2](https://docs.pydantic.dev/latest/)\nwhich is the powerful parsing and serializing data model to the Python object.\n\n> [!NOTE]\n> So, I use this project to learn and implement a limit and trick of the Pydantic\n> package.\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.4",
"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": "768396e431747b9d1e18a44df25f1c1bee761e451ab3e49253525714d4c59e14",
"md5": "364a737e854b7cb17c2ba03d019445f0",
"sha256": "ac88c916fdebabaaca20f04404fdf8cfb2e8a343b41bde9e77046dcbfd979037"
},
"downloads": -1,
"filename": "ddeutil_model-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "364a737e854b7cb17c2ba03d019445f0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9.13",
"size": 18909,
"upload_time": "2024-05-20T04:45:11",
"upload_time_iso_8601": "2024-05-20T04:45:11.447626Z",
"url": "https://files.pythonhosted.org/packages/76/83/96e431747b9d1e18a44df25f1c1bee761e451ab3e49253525714d4c59e14/ddeutil_model-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9e58b0db36dd0e65e889b4e430e8c93045311c706b1f676c09858808ed9f551d",
"md5": "d660e158a6e27a684917744ab0485d97",
"sha256": "52d41a33a507faeb445eab6d1104261d23879a1a35406b22066a7d5da83a0731"
},
"downloads": -1,
"filename": "ddeutil_model-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "d660e158a6e27a684917744ab0485d97",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9.13",
"size": 18976,
"upload_time": "2024-05-20T04:45:13",
"upload_time_iso_8601": "2024-05-20T04:45:13.095695Z",
"url": "https://files.pythonhosted.org/packages/9e/58/b0db36dd0e65e889b4e430e8c93045311c706b1f676c09858808ed9f551d/ddeutil_model-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-20 04:45:13",
"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"
}