statikk 0.0.10__tar.gz → 0.0.13__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.
- {statikk-0.0.10 → statikk-0.0.13}/PKG-INFO +6 -5
- {statikk-0.0.10 → statikk-0.0.13}/setup.cfg +4 -3
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk/engine.py +27 -12
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk.egg-info/PKG-INFO +6 -5
- statikk-0.0.13/src/statikk.egg-info/requires.txt +12 -0
- {statikk-0.0.10 → statikk-0.0.13}/tests/test_engine.py +7 -3
- statikk-0.0.10/src/statikk.egg-info/requires.txt +0 -11
- {statikk-0.0.10 → statikk-0.0.13}/.coveragerc +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/.gitignore +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/.readthedocs.yml +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/AUTHORS.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/CHANGELOG.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/CONTRIBUTING.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/LICENSE.txt +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/README.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/assets/favicon.png +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/assets/logo.png +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/Makefile +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/_static/.gitignore +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/authors.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/changelog.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/conf.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/contributing.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/index.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/license.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/readme.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/requirements.txt +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/docs/usage.rst +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/pyproject.toml +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/setup.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk/__init__.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk/conditions.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk/expressions.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk/models.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk.egg-info/SOURCES.txt +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk.egg-info/dependency_links.txt +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk.egg-info/not-zip-safe +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/src/statikk.egg-info/top_level.txt +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/tests/conftest.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/tests/test_expressions.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/tests/test_models.py +0 -0
- {statikk-0.0.10 → statikk-0.0.13}/tox.ini +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: statikk
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.13
|
4
4
|
Summary: statikk is a single table application (STA) library for DynamoDb.
|
5
5
|
Home-page: https://github.com/terinia/statikk
|
6
6
|
Author: Balint Biro
|
@@ -14,13 +14,14 @@ Requires-Python: >=3.8
|
|
14
14
|
Description-Content-Type: text/x-rst; charset=UTF-8
|
15
15
|
License-File: LICENSE.txt
|
16
16
|
Requires-Dist: importlib-metadata; python_version < "3.8"
|
17
|
-
Requires-Dist: pydantic
|
18
|
-
Requires-Dist: boto3
|
17
|
+
Requires-Dist: pydantic<3.0,>=2.7.4
|
18
|
+
Requires-Dist: boto3<2.0,>=1.28.43
|
19
|
+
Requires-Dist: aws-xray-sdk<3.0,>=2.14.0
|
19
20
|
Provides-Extra: testing
|
20
21
|
Requires-Dist: setuptools; extra == "testing"
|
21
22
|
Requires-Dist: pytest; extra == "testing"
|
22
23
|
Requires-Dist: pytest-cov; extra == "testing"
|
23
|
-
Requires-Dist: moto[dynamodb]; extra == "testing"
|
24
|
+
Requires-Dist: moto[dynamodb]==4.2.14; extra == "testing"
|
24
25
|
|
25
26
|
.. image:: ./assets/logo.png
|
26
27
|
:alt: Statikk
|
@@ -24,8 +24,9 @@ package_dir =
|
|
24
24
|
python_requires = >=3.8
|
25
25
|
install_requires =
|
26
26
|
importlib-metadata; python_version<"3.8"
|
27
|
-
pydantic
|
28
|
-
boto3
|
27
|
+
pydantic>=2.7.4,<3.0
|
28
|
+
boto3>=1.28.43,<2.0
|
29
|
+
aws-xray-sdk>=2.14.0,<3.0
|
29
30
|
|
30
31
|
[options.packages.find]
|
31
32
|
where = src
|
@@ -37,7 +38,7 @@ testing =
|
|
37
38
|
setuptools
|
38
39
|
pytest
|
39
40
|
pytest-cov
|
40
|
-
moto[dynamodb]
|
41
|
+
moto[dynamodb]==4.2.14
|
41
42
|
|
42
43
|
[options.entry_points]
|
43
44
|
|
@@ -19,6 +19,10 @@ from statikk.models import (
|
|
19
19
|
KeySchema,
|
20
20
|
)
|
21
21
|
|
22
|
+
from aws_xray_sdk.core import xray_recorder
|
23
|
+
from aws_xray_sdk.core import patch_all
|
24
|
+
|
25
|
+
patch_all()
|
22
26
|
|
23
27
|
class InvalidIndexNameError(Exception):
|
24
28
|
pass
|
@@ -54,19 +58,30 @@ class Table:
|
|
54
58
|
model.set_table_ref(self)
|
55
59
|
if "type" not in model.model_fields:
|
56
60
|
model.model_fields["type"] = FieldInfo(annotation=str, default=model.model_type(), required=False)
|
61
|
+
self._client = None
|
62
|
+
self._dynamodb_table = None
|
57
63
|
|
58
64
|
def _dynamodb_client(self):
|
59
|
-
|
65
|
+
if self._client:
|
66
|
+
return self._client
|
67
|
+
|
68
|
+
self._client = boto3.client(
|
60
69
|
"dynamodb",
|
61
70
|
config=Config(region_name=os.environ.get("AWS_DEFAULT_REGION", "eu-west-1")),
|
62
71
|
)
|
63
72
|
|
73
|
+
return self._client
|
74
|
+
|
64
75
|
def _get_dynamodb_table(self):
|
76
|
+
if self._dynamodb_table:
|
77
|
+
return self._dynamodb_table
|
78
|
+
|
65
79
|
dynamodb = boto3.resource(
|
66
80
|
"dynamodb",
|
67
81
|
config=Config(region_name=os.environ.get("AWS_DEFAULT_REGION", "eu-west-1")),
|
68
82
|
)
|
69
|
-
|
83
|
+
self._dynamodb_table = dynamodb.Table(self.name)
|
84
|
+
return self._dynamodb_table
|
70
85
|
|
71
86
|
def _to_dynamodb_type(self, type: Any):
|
72
87
|
if type is str:
|
@@ -149,14 +164,6 @@ class Table:
|
|
149
164
|
"""Deletes the DynamoDB table."""
|
150
165
|
self._dynamodb_client().delete_table(TableName=self.name)
|
151
166
|
|
152
|
-
def delete_item(self, id: str):
|
153
|
-
"""
|
154
|
-
Deletes an item from the database by id, using the partition key of the table.
|
155
|
-
:param id: The id of the item to delete.
|
156
|
-
"""
|
157
|
-
key = {self.key_schema.hash_key: id}
|
158
|
-
self._get_dynamodb_table().delete_item(Key=key)
|
159
|
-
|
160
167
|
def get_item(
|
161
168
|
self,
|
162
169
|
id: str,
|
@@ -181,6 +188,14 @@ class Table:
|
|
181
188
|
data[key] = self._deserialize_value(value, model_class.model_fields[key])
|
182
189
|
return model_class(**data)
|
183
190
|
|
191
|
+
def delete_item(self, id: str):
|
192
|
+
"""
|
193
|
+
Deletes an item from the database by id, using the partition key of the table.
|
194
|
+
:param id: The id of the item to delete.
|
195
|
+
"""
|
196
|
+
key = {self.key_schema.hash_key: id}
|
197
|
+
self._get_dynamodb_table().delete_item(Key=key)
|
198
|
+
|
184
199
|
def put_item(self, model: DatabaseModel) -> DatabaseModel:
|
185
200
|
"""
|
186
201
|
Puts an item into the database.
|
@@ -374,7 +389,7 @@ class Table:
|
|
374
389
|
else:
|
375
390
|
results.extend(
|
376
391
|
[
|
377
|
-
|
392
|
+
self._deserialize_item(self._convert_dynamodb_to_python(item), model_class)
|
378
393
|
for item in response["Responses"][self.name]
|
379
394
|
]
|
380
395
|
)
|
@@ -410,7 +425,7 @@ class Table:
|
|
410
425
|
return model_class(**item)
|
411
426
|
|
412
427
|
def _deserialize_value(self, value: Any, annotation: Any):
|
413
|
-
if annotation is datetime or "datetime" in str(annotation):
|
428
|
+
if annotation is datetime or "datetime" in str(annotation) and value is not None:
|
414
429
|
return datetime.fromtimestamp(int(value))
|
415
430
|
if annotation is float:
|
416
431
|
return float(value)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: statikk
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.13
|
4
4
|
Summary: statikk is a single table application (STA) library for DynamoDb.
|
5
5
|
Home-page: https://github.com/terinia/statikk
|
6
6
|
Author: Balint Biro
|
@@ -14,13 +14,14 @@ Requires-Python: >=3.8
|
|
14
14
|
Description-Content-Type: text/x-rst; charset=UTF-8
|
15
15
|
License-File: LICENSE.txt
|
16
16
|
Requires-Dist: importlib-metadata; python_version < "3.8"
|
17
|
-
Requires-Dist: pydantic
|
18
|
-
Requires-Dist: boto3
|
17
|
+
Requires-Dist: pydantic<3.0,>=2.7.4
|
18
|
+
Requires-Dist: boto3<2.0,>=1.28.43
|
19
|
+
Requires-Dist: aws-xray-sdk<3.0,>=2.14.0
|
19
20
|
Provides-Extra: testing
|
20
21
|
Requires-Dist: setuptools; extra == "testing"
|
21
22
|
Requires-Dist: pytest; extra == "testing"
|
22
23
|
Requires-Dist: pytest-cov; extra == "testing"
|
23
|
-
Requires-Dist: moto[dynamodb]; extra == "testing"
|
24
|
+
Requires-Dist: moto[dynamodb]==4.2.14; extra == "testing"
|
24
25
|
|
25
26
|
.. image:: ./assets/logo.png
|
26
27
|
:alt: Statikk
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from _decimal import Decimal
|
2
2
|
from datetime import datetime, timezone
|
3
|
-
from typing import List
|
3
|
+
from typing import List, Optional
|
4
4
|
from pydantic import BaseModel
|
5
5
|
import pytest
|
6
6
|
from boto3.dynamodb.conditions import Attr
|
@@ -30,7 +30,7 @@ class MyAwesomeModel(DatabaseModel):
|
|
30
30
|
values: set = {1, 2, 3, 4}
|
31
31
|
cost: int = 4
|
32
32
|
probability: float = 0.5
|
33
|
-
|
33
|
+
created_at: Optional[datetime] = None
|
34
34
|
|
35
35
|
class SimpleModel(DatabaseModel):
|
36
36
|
player_id: IndexPrimaryKeyField
|
@@ -92,6 +92,7 @@ def test_create_my_awesome_model():
|
|
92
92
|
"cost": 4,
|
93
93
|
"type": "MyAwesomeModel",
|
94
94
|
"probability": 0.5,
|
95
|
+
"created_at": None
|
95
96
|
}
|
96
97
|
model_2 = MyAwesomeModel(id="foo-2", player_id="123", tier="EPIC", name="FooFoo")
|
97
98
|
table.put_item(model_2)
|
@@ -106,6 +107,7 @@ def test_create_my_awesome_model():
|
|
106
107
|
"cost": 4,
|
107
108
|
"type": "MyAwesomeModel",
|
108
109
|
"probability": 0.5,
|
110
|
+
"created_at": None
|
109
111
|
}
|
110
112
|
mock_dynamodb().stop()
|
111
113
|
|
@@ -344,7 +346,7 @@ def test_batch_get_items():
|
|
344
346
|
models=[MyAwesomeModel],
|
345
347
|
)
|
346
348
|
_create_dynamodb_table(table)
|
347
|
-
model = MyAwesomeModel(id="foo", player_id="123", tier="LEGENDARY")
|
349
|
+
model = MyAwesomeModel(id="foo", player_id="123", tier="LEGENDARY", created_at=datetime(2024, 7, 9))
|
348
350
|
model_2 = MyAwesomeModel(id="foo-2", player_id="123", tier="LEGENDARY")
|
349
351
|
table.put_item(model)
|
350
352
|
table.put_item(model_2)
|
@@ -353,9 +355,11 @@ def test_batch_get_items():
|
|
353
355
|
assert models[0].id == model.id
|
354
356
|
assert models[0].model_type == model.model_type
|
355
357
|
assert models[0].tier == model.tier
|
358
|
+
assert models[0].created_at == datetime(2024, 7, 9)
|
356
359
|
assert models[1].id == model_2.id
|
357
360
|
assert models[1].model_type == model_2.model_type
|
358
361
|
assert models[1].tier == model_2.tier
|
362
|
+
assert models[1].created_at is None
|
359
363
|
mock_dynamodb().stop()
|
360
364
|
|
361
365
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|