patito 0.4.3__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {patito-0.4.3 → patito-0.5.0}/LICENSE +1 -0
- {patito-0.4.3 → patito-0.5.0}/PKG-INFO +18 -17
- {patito-0.4.3 → patito-0.5.0}/README.md +3 -3
- {patito-0.4.3 → patito-0.5.0}/pyproject.toml +35 -10
- {patito-0.4.3 → patito-0.5.0}/src/patito/__init__.py +12 -6
- patito-0.5.0/src/patito/database.py +658 -0
- {patito-0.4.3 → patito-0.5.0}/src/patito/duckdb.py +153 -186
- {patito-0.4.3 → patito-0.5.0}/src/patito/polars.py +52 -45
- {patito-0.4.3 → patito-0.5.0}/src/patito/pydantic.py +99 -88
- {patito-0.4.3 → patito-0.5.0}/src/patito/sql.py +2 -3
- {patito-0.4.3 → patito-0.5.0}/src/patito/validators.py +87 -1
- patito-0.5.0/src/patito/xdg.py +22 -0
- patito-0.4.3/setup.py +0 -46
- {patito-0.4.3 → patito-0.5.0}/src/patito/_docs.py +0 -0
- {patito-0.4.3 → patito-0.5.0}/src/patito/exceptions.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2022 Oda Group Holding AS
|
|
4
|
+
Copyright (c) 2023 Jakob Gerhard Martinussen and contributors
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: patito
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: A dataframe modelling library built on top of polars and pydantic.
|
|
5
5
|
Home-page: https://github.com/kolonialno/patito
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: validation,dataframe
|
|
8
8
|
Author: Jakob Gerhard Martinussen
|
|
9
9
|
Author-email: jakobgm@gmail.com
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.8,<4.0
|
|
11
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
15
13
|
Classifier: Programming Language :: Python :: 3.8
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Provides-Extra: caching
|
|
17
18
|
Provides-Extra: docs
|
|
18
19
|
Provides-Extra: duckdb
|
|
19
20
|
Provides-Extra: pandas
|
|
20
|
-
Requires-Dist: Sphinx; extra == "docs"
|
|
21
|
-
Requires-Dist: duckdb (>=0.
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist:
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist: pyarrow (>=5.0.0); (python_version >= "3.8" and python_version < "4.0") and (extra == "duckdb")
|
|
21
|
+
Requires-Dist: Sphinx (<7) ; extra == "docs"
|
|
22
|
+
Requires-Dist: duckdb (>=0.6.0) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "duckdb")
|
|
23
|
+
Requires-Dist: pandas ; (python_version >= "3.8" and python_version < "4.0") and (extra == "pandas")
|
|
24
|
+
Requires-Dist: polars (>=0.18.3)
|
|
25
|
+
Requires-Dist: pyarrow (>=5.0.0) ; (python_version >= "3.8" and python_version < "4.0") and (extra == "caching" or extra == "duckdb")
|
|
26
26
|
Requires-Dist: pydantic (>=1.7.0)
|
|
27
|
-
Requires-Dist: sphinx-autobuild; extra == "docs"
|
|
28
|
-
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
|
29
|
-
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
30
|
-
Requires-Dist:
|
|
27
|
+
Requires-Dist: sphinx-autobuild ; extra == "docs"
|
|
28
|
+
Requires-Dist: sphinx-autodoc-typehints ; extra == "docs"
|
|
29
|
+
Requires-Dist: sphinx-rtd-theme ; extra == "docs"
|
|
30
|
+
Requires-Dist: sphinx-toolbox ; extra == "docs"
|
|
31
|
+
Requires-Dist: sphinxcontrib-mermaid ; extra == "docs"
|
|
31
32
|
Requires-Dist: typing-extensions
|
|
32
33
|
Project-URL: Documentation, https://patito.readthedocs.io
|
|
33
34
|
Project-URL: Repository, https://github.com/kolonialno/patito
|
|
@@ -284,7 +285,7 @@ class Product(pt.Model):
|
|
|
284
285
|
@property
|
|
285
286
|
def url(self) -> str:
|
|
286
287
|
return (
|
|
287
|
-
"https://
|
|
288
|
+
"https://example.com/no/products/"
|
|
288
289
|
f"{self.product_id}-"
|
|
289
290
|
f"{self.name.lower().replace(' ', '-')}"
|
|
290
291
|
)
|
|
@@ -302,7 +303,7 @@ products = pl.DataFrame(
|
|
|
302
303
|
milk_row = products.filter(pl.col("product_id" == 1))
|
|
303
304
|
milk = Product.from_row(milk_row)
|
|
304
305
|
print(milk.url)
|
|
305
|
-
# https://
|
|
306
|
+
# https://example.com/no/products/1-skimmed-milk
|
|
306
307
|
```
|
|
307
308
|
|
|
308
309
|
If you "connect" the `Product` model with the `DataFrame` by the use of `patito.DataFrame.set_model()`, or alternatively by using `Product.DataFrame` directly, you can use the `.get()` method in order to filter the data frame down to a single row _and_ cast it to the respective model class:
|
|
@@ -317,6 +318,6 @@ products = Product.DataFrame(
|
|
|
317
318
|
)
|
|
318
319
|
milk = products.get(pl.col("product_id") == 1)
|
|
319
320
|
print(milk.url)
|
|
320
|
-
# https://
|
|
321
|
+
# https://example.com/no/products/1-skimmed-milk
|
|
321
322
|
```
|
|
322
323
|
|
|
@@ -249,7 +249,7 @@ class Product(pt.Model):
|
|
|
249
249
|
@property
|
|
250
250
|
def url(self) -> str:
|
|
251
251
|
return (
|
|
252
|
-
"https://
|
|
252
|
+
"https://example.com/no/products/"
|
|
253
253
|
f"{self.product_id}-"
|
|
254
254
|
f"{self.name.lower().replace(' ', '-')}"
|
|
255
255
|
)
|
|
@@ -267,7 +267,7 @@ products = pl.DataFrame(
|
|
|
267
267
|
milk_row = products.filter(pl.col("product_id" == 1))
|
|
268
268
|
milk = Product.from_row(milk_row)
|
|
269
269
|
print(milk.url)
|
|
270
|
-
# https://
|
|
270
|
+
# https://example.com/no/products/1-skimmed-milk
|
|
271
271
|
```
|
|
272
272
|
|
|
273
273
|
If you "connect" the `Product` model with the `DataFrame` by the use of `patito.DataFrame.set_model()`, or alternatively by using `Product.DataFrame` directly, you can use the `.get()` method in order to filter the data frame down to a single row _and_ cast it to the respective model class:
|
|
@@ -282,5 +282,5 @@ products = Product.DataFrame(
|
|
|
282
282
|
)
|
|
283
283
|
milk = products.get(pl.col("product_id") == 1)
|
|
284
284
|
print(milk.url)
|
|
285
|
-
# https://
|
|
285
|
+
# https://example.com/no/products/1-skimmed-milk
|
|
286
286
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "patito"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.0"
|
|
4
4
|
description = "A dataframe modelling library built on top of polars and pydantic."
|
|
5
5
|
authors = ["Jakob Gerhard Martinussen <jakobgm@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -11,28 +11,37 @@ documentation = "https://patito.readthedocs.io"
|
|
|
11
11
|
keywords = ["validation", "dataframe"]
|
|
12
12
|
|
|
13
13
|
[tool.poetry.dependencies]
|
|
14
|
-
python = "^3.
|
|
14
|
+
python = "^3.8"
|
|
15
15
|
pydantic = ">=1.7.0"
|
|
16
|
-
polars = ">=0.
|
|
16
|
+
polars = ">=0.18.3"
|
|
17
17
|
# Required for typing.Literal in python3.7
|
|
18
18
|
typing-extensions = "*"
|
|
19
19
|
pandas = {version = "*", optional = true, python = "^3.8"}
|
|
20
|
-
duckdb = {version = ">=0.
|
|
20
|
+
duckdb = {version = ">=0.6.0", optional = true, python = "^3.8"}
|
|
21
21
|
pyarrow = {version = ">=5.0.0", optional = true, python = "^3.8"}
|
|
22
|
-
importlib-metadata = {version = "*", python = "<3.8"}
|
|
23
22
|
# Optional docs dependencies
|
|
24
|
-
Sphinx = {version = "
|
|
23
|
+
Sphinx = {version = "<7", optional = true}
|
|
25
24
|
sphinx-rtd-theme = {version = "*", optional = true}
|
|
26
25
|
sphinx-autobuild = {version = "*", optional = true}
|
|
27
26
|
sphinx-autodoc-typehints = {version = "*", optional = true}
|
|
27
|
+
sphinx-toolbox = {version = "*", optional = true}
|
|
28
28
|
sphinxcontrib-mermaid = {version = "*", optional = true}
|
|
29
29
|
|
|
30
30
|
[tool.poetry.extras]
|
|
31
|
+
# The pyarrow.parquet module is required for writing parquet caches to disk
|
|
32
|
+
caching = ["pyarrow"]
|
|
31
33
|
duckdb = ["duckdb", "pyarrow"]
|
|
32
34
|
pandas = ["pandas"]
|
|
33
|
-
docs = [
|
|
35
|
+
docs = [
|
|
36
|
+
"Sphinx",
|
|
37
|
+
"sphinx-autobuild",
|
|
38
|
+
"sphinx-autodoc-typehints",
|
|
39
|
+
"sphinx-rtd-theme",
|
|
40
|
+
"sphinx-toolbox",
|
|
41
|
+
"sphinxcontrib-mermaid",
|
|
42
|
+
]
|
|
34
43
|
|
|
35
|
-
[tool.poetry.dev
|
|
44
|
+
[tool.poetry.group.dev.dependencies]
|
|
36
45
|
black = ">=22.3.0"
|
|
37
46
|
coverage = {version = "*", extras = ["toml"]}
|
|
38
47
|
flake8 = "3.9.2"
|
|
@@ -80,7 +89,7 @@ exclude_lines = [
|
|
|
80
89
|
"if not _PANDAS_AVAILABLE:",
|
|
81
90
|
"except ImportError:",
|
|
82
91
|
]
|
|
83
|
-
fail_under =
|
|
92
|
+
fail_under = 99.64
|
|
84
93
|
show_missing = true
|
|
85
94
|
|
|
86
95
|
[tool.isort]
|
|
@@ -107,5 +116,21 @@ exclude = [
|
|
|
107
116
|
|
|
108
117
|
[[tool.mypy.overrides]]
|
|
109
118
|
module = ["tests.*", "noxfile"]
|
|
110
|
-
|
|
119
|
+
allow_untyped_defs = true
|
|
120
|
+
check_untyped_defs = true
|
|
111
121
|
disallow_incomplete_defs = false
|
|
122
|
+
# TODO: Go through and remove those we want to check in tests
|
|
123
|
+
disable_error_code = [
|
|
124
|
+
"var-annotated",
|
|
125
|
+
"override",
|
|
126
|
+
"attr-defined",
|
|
127
|
+
"call-arg",
|
|
128
|
+
"type-var",
|
|
129
|
+
"misc",
|
|
130
|
+
"arg-type",
|
|
131
|
+
"assignment",
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
[[tool.mypy.overrides]]
|
|
135
|
+
module = ["tests.test_validators"]
|
|
136
|
+
warn_unused_ignores = false
|
|
@@ -6,6 +6,7 @@ from patito.exceptions import ValidationError
|
|
|
6
6
|
from patito.polars import DataFrame, LazyFrame
|
|
7
7
|
from patito.pydantic import Field, Model
|
|
8
8
|
|
|
9
|
+
_CACHING_AVAILABLE = False
|
|
9
10
|
_DUCKDB_AVAILABLE = False
|
|
10
11
|
field = col("_")
|
|
11
12
|
__all__ = [
|
|
@@ -16,6 +17,7 @@ __all__ = [
|
|
|
16
17
|
"Model",
|
|
17
18
|
"Series",
|
|
18
19
|
"ValidationError",
|
|
20
|
+
"_CACHING_AVAILABLE",
|
|
19
21
|
"_DUCKDB_AVAILABLE",
|
|
20
22
|
"col",
|
|
21
23
|
"exceptions",
|
|
@@ -24,17 +26,21 @@ __all__ = [
|
|
|
24
26
|
]
|
|
25
27
|
|
|
26
28
|
try:
|
|
27
|
-
from patito
|
|
29
|
+
from patito import duckdb
|
|
28
30
|
|
|
29
31
|
_DUCKDB_AVAILABLE = True
|
|
30
|
-
__all__ += [
|
|
31
|
-
"Database",
|
|
32
|
-
"Relation",
|
|
33
|
-
"RelationSource",
|
|
34
|
-
]
|
|
32
|
+
__all__ += ["duckdb"]
|
|
35
33
|
except ImportError: # pragma: no cover
|
|
36
34
|
pass
|
|
37
35
|
|
|
36
|
+
try:
|
|
37
|
+
from patito.database import Database
|
|
38
|
+
|
|
39
|
+
_CACHING_AVAILABLE = True
|
|
40
|
+
__all__ += ["Database"]
|
|
41
|
+
except ImportError:
|
|
42
|
+
pass
|
|
43
|
+
|
|
38
44
|
|
|
39
45
|
try:
|
|
40
46
|
from importlib.metadata import PackageNotFoundError, version
|