Data Developer & Engineer Model Utility Objects
Project description
Data Utility Package: Model
Table of Contents:
This is Model Utility, implements any model objects for Data Pipeline or Data Platform. The Model objects was implemented from the Pydantic V2.
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
pip install -U ddeutil-model
Models
Data Types
from ddeutil.model.dtype import StringType
dtype = StringType()
assert dtype.type == "string"
assert dtype.max_length == -1
Constraints
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
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.
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ddeutil_model-0.0.3.tar.gz
(18.0 kB
view hashes)
Built Distribution
Close
Hashes for ddeutil_model-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f1638c987ea98d23a7e60fd81360df3ff36e6c9ee758fff02fe3fc6d1b45b82 |
|
MD5 | 1d8c02ce7e9c61d1a59b581c09e3d038 |
|
BLAKE2b-256 | 6fb757bc5ad2237ba7ca86a8775c43b29ce9934dffadb5496f8fac2ad3591861 |