amsdal 0.3.6__cp312-cp312-macosx_10_13_universal2.whl → 0.4.1__cp312-cp312-macosx_10_13_universal2.whl
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.
Potentially problematic release.
This version of amsdal might be problematic. Click here for more details.
- amsdal/__about__.py +1 -1
- amsdal/__migrations__/0000_initial.py +34 -25
- amsdal/__migrations__/0001_datetime_type.py +4 -4
- amsdal/__migrations__/0002_fixture_order.py +7 -3
- amsdal/__migrations__/0003_schema_type_in_class_meta.py +3 -15
- amsdal/cloud/__init__.cpython-312-darwin.so +0 -0
- amsdal/cloud/client.cpython-312-darwin.so +0 -0
- amsdal/cloud/constants.cpython-312-darwin.so +0 -0
- amsdal/cloud/enums.cpython-312-darwin.so +0 -0
- amsdal/cloud/models/__init__.cpython-312-darwin.so +0 -0
- amsdal/cloud/models/base.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/__init__.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/__init__.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/add_allowlist_ip.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/add_basic_auth.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/add_dependency.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/add_secret.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/base.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/create_deploy.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/create_env.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/create_session.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_allowlist_ip.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_basic_auth.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_dependency.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_env.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/delete_secret.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/destroy_deploy.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/expose_db.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/get_basic_auth_credentials.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/get_monitoring_info.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/list_dependencies.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/list_deploys.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/list_envs.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/list_secrets.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/manager.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/signup_action.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/actions/update_deploy.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/auth/__init__.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/auth/base.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/auth/credentials.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/auth/credentials.pyi +0 -1
- amsdal/cloud/services/auth/manager.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/auth/signup_service.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/auth/token.cpython-312-darwin.so +0 -0
- amsdal/cloud/services/auth/token.pyi +0 -1
- amsdal/configs/main.py +23 -19
- amsdal/configs/main.pyi +12 -15
- amsdal/contrib/__init__.cpython-312-darwin.so +0 -0
- amsdal/contrib/auth/fixtures/basic_permissions.json +64 -0
- amsdal/contrib/auth/lifecycle/consumer.py +10 -10
- amsdal/contrib/auth/migrations/0000_initial.py +41 -7
- amsdal/contrib/auth/models/login_session.py +66 -0
- amsdal/contrib/auth/models/login_session.pyi +33 -0
- amsdal/contrib/auth/models/permission.py +23 -0
- amsdal/contrib/auth/models/permission.pyi +18 -0
- amsdal/contrib/auth/models/user.py +106 -0
- amsdal/contrib/auth/models/user.pyi +46 -0
- amsdal/contrib/frontend_configs/conversion/convert.py +47 -15
- amsdal/contrib/frontend_configs/conversion/convert.pyi +0 -1
- amsdal/contrib/frontend_configs/lifecycle/consumer.py +32 -13
- amsdal/contrib/frontend_configs/lifecycle/consumer.pyi +1 -1
- amsdal/contrib/frontend_configs/migrations/0000_initial.py +15 -14
- amsdal/contrib/frontend_configs/models/__init__.py +0 -0
- amsdal/contrib/frontend_configs/models/__init__.pyi +0 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config.py +22 -0
- amsdal/contrib/frontend_configs/models/frontend_activator_config.pyi +12 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator.py +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator.pyi +7 -0
- amsdal/contrib/frontend_configs/models/frontend_config_control_action.py +54 -0
- amsdal/contrib/frontend_configs/models/frontend_config_control_action.pyi +32 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator.py +21 -0
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator.pyi +11 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option.py +12 -0
- amsdal/contrib/frontend_configs/models/frontend_config_option.pyi +8 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.py +17 -0
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base.pyi +8 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option.py +13 -0
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option.pyi +9 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask.py +14 -0
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask.pyi +10 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator.py +28 -0
- amsdal/contrib/frontend_configs/models/frontend_config_validator.pyi +15 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config.py +87 -0
- amsdal/contrib/frontend_configs/models/frontend_control_config.pyi +35 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config.py +14 -0
- amsdal/contrib/frontend_configs/models/frontend_model_config.pyi +9 -0
- amsdal/errors.py +0 -3
- amsdal/errors.pyi +0 -1
- amsdal/fixtures/__init__.cpython-312-darwin.so +0 -0
- amsdal/fixtures/manager.cpython-312-darwin.so +0 -0
- amsdal/fixtures/manager.pyi +72 -123
- amsdal/fixtures/utils.cpython-312-darwin.so +0 -0
- amsdal/fixtures/utils.pyi +9 -0
- amsdal/manager.cpython-312-darwin.so +0 -0
- amsdal/manager.pyi +4 -96
- amsdal/mixins/__init__.cpython-312-darwin.so +0 -0
- amsdal/mixins/class_versions_mixin.cpython-312-darwin.so +0 -0
- amsdal/models/__init__.py +0 -0
- amsdal/models/__init__.pyi +0 -0
- amsdal/models/core/__init__.py +0 -0
- amsdal/models/core/__init__.pyi +0 -0
- amsdal/models/core/class_object.py +37 -0
- amsdal/models/core/class_object.pyi +24 -0
- amsdal/models/core/class_object_meta.py +26 -0
- amsdal/models/core/class_object_meta.pyi +15 -0
- amsdal/models/core/class_property.py +19 -0
- amsdal/models/core/class_property.pyi +10 -0
- amsdal/models/core/class_property_meta.py +15 -0
- amsdal/models/core/class_property_meta.pyi +10 -0
- amsdal/models/core/file.py +156 -0
- amsdal/models/core/file.pyi +104 -0
- amsdal/models/core/fixture.py +25 -0
- amsdal/models/core/fixture.pyi +14 -0
- amsdal/models/core/option.py +11 -0
- amsdal/models/core/option.pyi +8 -0
- amsdal/models/core/validator.py +12 -0
- amsdal/models/core/validator.pyi +8 -0
- amsdal/models/types/__init__.py +0 -0
- amsdal/models/types/__init__.pyi +0 -0
- amsdal/models/types/object.py +26 -0
- amsdal/models/types/object.pyi +16 -0
- amsdal/schemas/core/file/properties/validate_data.py +1 -1
- amsdal/schemas/interfaces.py +25 -0
- amsdal/schemas/interfaces.pyi +20 -0
- amsdal/schemas/manager.cpython-312-darwin.so +0 -0
- amsdal/schemas/manager.py +0 -116
- amsdal/schemas/manager.pyi +0 -65
- amsdal/schemas/mixins/__init__.py +0 -0
- amsdal/schemas/mixins/__init__.pyi +0 -0
- amsdal/schemas/mixins/check_dependencies_mixin.py +115 -0
- amsdal/schemas/mixins/check_dependencies_mixin.pyi +42 -0
- amsdal/schemas/mixins/verify_schemas_mixin.py +96 -0
- amsdal/schemas/mixins/verify_schemas_mixin.pyi +33 -0
- amsdal/schemas/repository.py +84 -0
- amsdal/schemas/repository.pyi +22 -0
- amsdal/schemas/utils.py +16 -0
- amsdal/schemas/utils.pyi +10 -0
- amsdal/services/__init__.cpython-312-darwin.so +0 -0
- amsdal/services/transaction_execution.cpython-312-darwin.so +0 -0
- amsdal/utils/rollback/__init__.py +99 -54
- amsdal/utils/tests/helpers.py +46 -37
- {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/METADATA +8 -8
- {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/RECORD +149 -140
- {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/WHEEL +1 -1
- amsdal/contrib/auth/models/login_session/hooks/pre_init.py +0 -68
- amsdal/contrib/auth/models/login_session/model.json +0 -23
- amsdal/contrib/auth/models/login_session/modifiers/display_name.py +0 -11
- amsdal/contrib/auth/models/permission/fixtures/basic_permissions.json +0 -62
- amsdal/contrib/auth/models/permission/model.json +0 -18
- amsdal/contrib/auth/models/permission/modifiers/display_name.py +0 -11
- amsdal/contrib/auth/models/user/hooks/post_init.py +0 -76
- amsdal/contrib/auth/models/user/hooks/pre_create.py +0 -8
- amsdal/contrib/auth/models/user/model.json +0 -25
- amsdal/contrib/auth/models/user/modifiers/display_name.py +0 -19
- amsdal/contrib/frontend_configs/models/frontend_activator_config/model.json +0 -11
- amsdal/contrib/frontend_configs/models/frontend_config_async_validator/model.json +0 -11
- amsdal/contrib/frontend_configs/models/frontend_config_group_validator/model.json +0 -52
- amsdal/contrib/frontend_configs/models/frontend_config_option/model.json +0 -15
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/model.json +0 -6
- amsdal/contrib/frontend_configs/models/frontend_config_skip_none_base/properties/model_dump.py +0 -13
- amsdal/contrib/frontend_configs/models/frontend_config_slider_option/model.json +0 -19
- amsdal/contrib/frontend_configs/models/frontend_config_text_mask/model.json +0 -26
- amsdal/contrib/frontend_configs/models/frontend_config_validator/model.json +0 -41
- amsdal/contrib/frontend_configs/models/frontend_control_config/model.json +0 -250
- amsdal/contrib/frontend_configs/models/frontend_model_config/fixtures/permissions.json +0 -24
- amsdal/contrib/frontend_configs/models/frontend_model_config/model.json +0 -17
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/model.json +0 -54
- amsdal/contrib/frontend_configs/models/frontent_config_control_action/properties/action_validate.py +0 -33
- amsdal/migration/__init__.cpython-312-darwin.so +0 -0
- amsdal/migration/base_migration_schemas.cpython-312-darwin.so +0 -0
- amsdal/migration/base_migration_schemas.pyi +0 -119
- amsdal/migration/data_classes.cpython-312-darwin.so +0 -0
- amsdal/migration/data_classes.pyi +0 -165
- amsdal/migration/executors/__init__.cpython-312-darwin.so +0 -0
- amsdal/migration/executors/base.cpython-312-darwin.so +0 -0
- amsdal/migration/executors/base.pyi +0 -117
- amsdal/migration/executors/default_executor.cpython-312-darwin.so +0 -0
- amsdal/migration/executors/default_executor.pyi +0 -184
- amsdal/migration/executors/state_executor.cpython-312-darwin.so +0 -0
- amsdal/migration/executors/state_executor.pyi +0 -151
- amsdal/migration/file_migration_executor.cpython-312-darwin.so +0 -0
- amsdal/migration/file_migration_executor.pyi +0 -122
- amsdal/migration/file_migration_generator.cpython-312-darwin.so +0 -0
- amsdal/migration/file_migration_generator.pyi +0 -229
- amsdal/migration/file_migration_store.cpython-312-darwin.so +0 -0
- amsdal/migration/file_migration_store.pyi +0 -114
- amsdal/migration/file_migration_writer.cpython-312-darwin.so +0 -0
- amsdal/migration/file_migration_writer.pyi +0 -73
- amsdal/migration/migrations.cpython-312-darwin.so +0 -0
- amsdal/migration/migrations.pyi +0 -166
- amsdal/migration/migrations_loader.cpython-312-darwin.so +0 -0
- amsdal/migration/migrations_loader.pyi +0 -32
- amsdal/migration/schemas_loaders.cpython-312-darwin.so +0 -0
- amsdal/migration/schemas_loaders.pyi +0 -37
- amsdal/migration/templates/data_migration.tmpl +0 -18
- amsdal/migration/templates/dict_validator.tmpl +0 -4
- amsdal/migration/templates/migration.tmpl +0 -6
- amsdal/migration/templates/model_class.tmpl +0 -8
- amsdal/migration/templates/model_class_layout.tmpl +0 -24
- amsdal/migration/templates/options_validator.tmpl +0 -4
- amsdal/migration/utils.cpython-312-darwin.so +0 -0
- amsdal/migration/utils.pyi +0 -58
- amsdal/mixins/build_mixin.cpython-312-darwin.so +0 -0
- amsdal/mixins/build_mixin.pyi +0 -78
- /amsdal/{migration/__init__.pyi → contrib/auth/models/__init__.py} +0 -0
- /amsdal/{migration/executors → contrib/auth/models}/__init__.pyi +0 -0
- {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/LICENSE.txt +0 -0
- {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/licenses/LICENSE.txt +0 -0
- {amsdal-0.3.6.dist-info → amsdal-0.4.1.dist-info}/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ from amsdal_data.application import DataApplication
|
|
|
4
4
|
from amsdal_data.transactions.decorators import async_transaction
|
|
5
5
|
from amsdal_data.transactions.decorators import transaction
|
|
6
6
|
from amsdal_data.transactions.errors import AmsdalTransactionError
|
|
7
|
-
from amsdal_models.classes.
|
|
7
|
+
from amsdal_models.classes.class_manager import ClassManager
|
|
8
8
|
from amsdal_models.querysets.executor import LAKEHOUSE_DB_ALIAS
|
|
9
9
|
|
|
10
10
|
|
|
@@ -28,14 +28,21 @@ def rollback_to_timestamp(timestamp: float) -> None:
|
|
|
28
28
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
29
29
|
where=glue.Conditions(
|
|
30
30
|
glue.Condition(
|
|
31
|
-
|
|
31
|
+
left=glue.FieldReferenceExpression(
|
|
32
|
+
field_reference=glue.FieldReference(field=glue.Field(name='updated_at'), table_name='Metadata'),
|
|
33
|
+
),
|
|
32
34
|
lookup=glue.FieldLookup.GT,
|
|
33
|
-
|
|
35
|
+
right=glue.Value(timestamp),
|
|
34
36
|
),
|
|
35
37
|
glue.Condition(
|
|
36
|
-
|
|
38
|
+
left=glue.FieldReferenceExpression(
|
|
39
|
+
field_reference=glue.FieldReference(
|
|
40
|
+
field=glue.Field(name='prior_version'),
|
|
41
|
+
table_name='Metadata',
|
|
42
|
+
),
|
|
43
|
+
),
|
|
37
44
|
lookup=glue.FieldLookup.ISNULL,
|
|
38
|
-
|
|
45
|
+
right=glue.Value(True),
|
|
39
46
|
),
|
|
40
47
|
),
|
|
41
48
|
)
|
|
@@ -48,14 +55,21 @@ def rollback_to_timestamp(timestamp: float) -> None:
|
|
|
48
55
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
49
56
|
where=glue.Conditions(
|
|
50
57
|
glue.Condition(
|
|
51
|
-
|
|
58
|
+
left=glue.FieldReferenceExpression(
|
|
59
|
+
field_reference=glue.FieldReference(field=glue.Field(name='updated_at'), table_name='Metadata'),
|
|
60
|
+
),
|
|
52
61
|
lookup=glue.FieldLookup.GT,
|
|
53
|
-
|
|
62
|
+
right=glue.Value(timestamp),
|
|
54
63
|
),
|
|
55
64
|
glue.Condition(
|
|
56
|
-
|
|
65
|
+
left=glue.FieldReferenceExpression(
|
|
66
|
+
field_reference=glue.FieldReference(
|
|
67
|
+
field=glue.Field(name='prior_version'),
|
|
68
|
+
table_name='Metadata',
|
|
69
|
+
),
|
|
70
|
+
),
|
|
57
71
|
lookup=glue.FieldLookup.ISNULL,
|
|
58
|
-
|
|
72
|
+
right=glue.Value(False),
|
|
59
73
|
),
|
|
60
74
|
),
|
|
61
75
|
)
|
|
@@ -83,9 +97,12 @@ def rollback_to_timestamp(timestamp: float) -> None:
|
|
|
83
97
|
_parent_field.child.child.parent = _parent_field.child # type: ignore[union-attr]
|
|
84
98
|
_conditions.append(
|
|
85
99
|
glue.Condition(
|
|
86
|
-
|
|
100
|
+
left=glue.FieldReferenceExpression(
|
|
101
|
+
field_reference=glue.FieldReference(field=_parent_field, table_name='Metadata'),
|
|
102
|
+
output_type=str,
|
|
103
|
+
),
|
|
87
104
|
lookup=glue.FieldLookup.EQ,
|
|
88
|
-
|
|
105
|
+
right=glue.Value(transaction_id, output_type=str),
|
|
89
106
|
)
|
|
90
107
|
)
|
|
91
108
|
|
|
@@ -94,9 +111,14 @@ def rollback_to_timestamp(timestamp: float) -> None:
|
|
|
94
111
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
95
112
|
where=glue.Conditions(
|
|
96
113
|
glue.Condition(
|
|
97
|
-
|
|
114
|
+
left=glue.FieldReferenceExpression(
|
|
115
|
+
field_reference=glue.FieldReference(
|
|
116
|
+
field=glue.Field(name='updated_at'),
|
|
117
|
+
table_name='Metadata',
|
|
118
|
+
),
|
|
119
|
+
),
|
|
98
120
|
lookup=glue.FieldLookup.LTE,
|
|
99
|
-
|
|
121
|
+
right=glue.Value(timestamp),
|
|
100
122
|
),
|
|
101
123
|
glue.Conditions(*_conditions, connector=glue.FilterConnector.OR),
|
|
102
124
|
),
|
|
@@ -108,9 +130,7 @@ def rollback_to_timestamp(timestamp: float) -> None:
|
|
|
108
130
|
|
|
109
131
|
for m in metadatas_to_delete:
|
|
110
132
|
class_name = m.data['class_schema_reference']['ref']['object_id']
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
model_class = class_manager.import_model_class(class_name, schema_type)
|
|
133
|
+
model_class = class_manager.import_class(class_name)
|
|
114
134
|
obj = (
|
|
115
135
|
model_class.objects.filter(_address__object_id=m.data['object_id'])
|
|
116
136
|
.using(LAKEHOUSE_DB_ALIAS)
|
|
@@ -123,8 +143,7 @@ def rollback_to_timestamp(timestamp: float) -> None:
|
|
|
123
143
|
obj.delete()
|
|
124
144
|
|
|
125
145
|
for object_id, class_name in ids_to_revert:
|
|
126
|
-
|
|
127
|
-
model_class = class_manager.import_model_class(class_name, schema_type)
|
|
146
|
+
model_class = class_manager.import_class(class_name)
|
|
128
147
|
|
|
129
148
|
obj = (
|
|
130
149
|
model_class.objects.filter(_address__object_id=object_id)
|
|
@@ -133,13 +152,14 @@ def rollback_to_timestamp(timestamp: float) -> None:
|
|
|
133
152
|
.first()
|
|
134
153
|
.execute()
|
|
135
154
|
)
|
|
136
|
-
old_obj = (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
)
|
|
155
|
+
old_obj = obj.previous_version() # type: ignore[union-attr]
|
|
156
|
+
# old_obj = (
|
|
157
|
+
# model_class.objects.filter(_address__object_id=object_id, _metadata__updated_at__lte=timestamp)
|
|
158
|
+
# .using(LAKEHOUSE_DB_ALIAS)
|
|
159
|
+
# .order_by('-_metadata__updated_at')
|
|
160
|
+
# .first()
|
|
161
|
+
# .execute()
|
|
162
|
+
# )
|
|
143
163
|
|
|
144
164
|
if obj and old_obj:
|
|
145
165
|
for field, value in old_obj.model_dump().items():
|
|
@@ -180,9 +200,12 @@ def rollback_transaction(transaction_id: str) -> None:
|
|
|
180
200
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
181
201
|
where=glue.Conditions(
|
|
182
202
|
glue.Condition(
|
|
183
|
-
|
|
203
|
+
left=glue.FieldReferenceExpression(
|
|
204
|
+
field_reference=glue.FieldReference(field=_parent_field, table_name='Metadata'),
|
|
205
|
+
output_type=str,
|
|
206
|
+
),
|
|
184
207
|
lookup=glue.FieldLookup.EQ,
|
|
185
|
-
|
|
208
|
+
right=glue.Value(transaction_id, output_type=str),
|
|
186
209
|
)
|
|
187
210
|
),
|
|
188
211
|
order_by=[
|
|
@@ -222,14 +245,21 @@ async def async_rollback_to_timestamp(timestamp: float) -> None:
|
|
|
222
245
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
223
246
|
where=glue.Conditions(
|
|
224
247
|
glue.Condition(
|
|
225
|
-
|
|
248
|
+
left=glue.FieldReferenceExpression(
|
|
249
|
+
field_reference=glue.FieldReference(field=glue.Field(name='updated_at'), table_name='Metadata'),
|
|
250
|
+
),
|
|
226
251
|
lookup=glue.FieldLookup.GT,
|
|
227
|
-
|
|
252
|
+
right=glue.Value(timestamp),
|
|
228
253
|
),
|
|
229
254
|
glue.Condition(
|
|
230
|
-
|
|
255
|
+
left=glue.FieldReferenceExpression(
|
|
256
|
+
field_reference=glue.FieldReference(
|
|
257
|
+
field=glue.Field(name='prior_version'),
|
|
258
|
+
table_name='Metadata',
|
|
259
|
+
),
|
|
260
|
+
),
|
|
231
261
|
lookup=glue.FieldLookup.ISNULL,
|
|
232
|
-
|
|
262
|
+
right=glue.Value(True),
|
|
233
263
|
),
|
|
234
264
|
),
|
|
235
265
|
)
|
|
@@ -242,14 +272,20 @@ async def async_rollback_to_timestamp(timestamp: float) -> None:
|
|
|
242
272
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
243
273
|
where=glue.Conditions(
|
|
244
274
|
glue.Condition(
|
|
245
|
-
|
|
275
|
+
left=glue.FieldReferenceExpression(
|
|
276
|
+
field_reference=glue.FieldReference(field=glue.Field(name='updated_at'), table_name='Metadata'),
|
|
277
|
+
),
|
|
246
278
|
lookup=glue.FieldLookup.GT,
|
|
247
|
-
|
|
279
|
+
right=glue.Value(timestamp),
|
|
248
280
|
),
|
|
249
281
|
glue.Condition(
|
|
250
|
-
|
|
282
|
+
left=glue.FieldReferenceExpression(
|
|
283
|
+
field_reference=glue.FieldReference(
|
|
284
|
+
field=glue.Field(name='prior_version'), table_name='Metadata'
|
|
285
|
+
),
|
|
286
|
+
),
|
|
251
287
|
lookup=glue.FieldLookup.ISNULL,
|
|
252
|
-
|
|
288
|
+
right=glue.Value(False),
|
|
253
289
|
),
|
|
254
290
|
),
|
|
255
291
|
)
|
|
@@ -277,9 +313,12 @@ async def async_rollback_to_timestamp(timestamp: float) -> None:
|
|
|
277
313
|
_parent_field.child.child.parent = _parent_field.child # type: ignore[union-attr]
|
|
278
314
|
_conditions.append(
|
|
279
315
|
glue.Condition(
|
|
280
|
-
|
|
316
|
+
left=glue.FieldReferenceExpression(
|
|
317
|
+
field_reference=glue.FieldReference(field=_parent_field, table_name='Metadata'),
|
|
318
|
+
output_type=str,
|
|
319
|
+
),
|
|
281
320
|
lookup=glue.FieldLookup.EQ,
|
|
282
|
-
|
|
321
|
+
right=glue.Value(transaction_id, output_type=str),
|
|
283
322
|
)
|
|
284
323
|
)
|
|
285
324
|
|
|
@@ -288,9 +327,14 @@ async def async_rollback_to_timestamp(timestamp: float) -> None:
|
|
|
288
327
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
289
328
|
where=glue.Conditions(
|
|
290
329
|
glue.Condition(
|
|
291
|
-
|
|
330
|
+
left=glue.FieldReferenceExpression(
|
|
331
|
+
field_reference=glue.FieldReference(
|
|
332
|
+
field=glue.Field(name='updated_at'),
|
|
333
|
+
table_name='Metadata',
|
|
334
|
+
),
|
|
335
|
+
),
|
|
292
336
|
lookup=glue.FieldLookup.LTE,
|
|
293
|
-
|
|
337
|
+
right=glue.Value(timestamp),
|
|
294
338
|
),
|
|
295
339
|
glue.Conditions(*_conditions, connector=glue.FilterConnector.OR),
|
|
296
340
|
),
|
|
@@ -302,9 +346,7 @@ async def async_rollback_to_timestamp(timestamp: float) -> None:
|
|
|
302
346
|
|
|
303
347
|
for m in metadatas_to_delete:
|
|
304
348
|
class_name = m.data['class_schema_reference']['ref']['object_id']
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
model_class = class_manager.import_model_class(class_name, schema_type)
|
|
349
|
+
model_class = class_manager.import_class(class_name)
|
|
308
350
|
obj = await (
|
|
309
351
|
model_class.objects.filter(_address__object_id=m.data['object_id'])
|
|
310
352
|
.using(LAKEHOUSE_DB_ALIAS)
|
|
@@ -317,8 +359,7 @@ async def async_rollback_to_timestamp(timestamp: float) -> None:
|
|
|
317
359
|
await obj.adelete()
|
|
318
360
|
|
|
319
361
|
for object_id, class_name in ids_to_revert:
|
|
320
|
-
|
|
321
|
-
model_class = class_manager.import_model_class(class_name, schema_type)
|
|
362
|
+
model_class = class_manager.import_class(class_name)
|
|
322
363
|
|
|
323
364
|
obj = await (
|
|
324
365
|
model_class.objects.filter(_address__object_id=object_id)
|
|
@@ -327,16 +368,17 @@ async def async_rollback_to_timestamp(timestamp: float) -> None:
|
|
|
327
368
|
.first()
|
|
328
369
|
.aexecute()
|
|
329
370
|
)
|
|
330
|
-
old_obj = await (
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
)
|
|
371
|
+
old_obj = await obj.aprevious_version() # type: ignore[union-attr]
|
|
372
|
+
# old_obj = await (
|
|
373
|
+
# model_class.objects.filter(_address__object_id=object_id, _metadata__updated_at__lte=timestamp)
|
|
374
|
+
# .using(LAKEHOUSE_DB_ALIAS)
|
|
375
|
+
# .order_by('-_metadata__updated_at')
|
|
376
|
+
# .first()
|
|
377
|
+
# .aexecute()
|
|
378
|
+
# )
|
|
337
379
|
|
|
338
380
|
if obj and old_obj:
|
|
339
|
-
for field, value in old_obj.
|
|
381
|
+
for field, value in (await old_obj.amodel_dump()).items():
|
|
340
382
|
setattr(obj, field, value)
|
|
341
383
|
|
|
342
384
|
await obj.asave()
|
|
@@ -373,9 +415,12 @@ async def async_rollback_transaction(transaction_id: str) -> None:
|
|
|
373
415
|
table=glue.SchemaReference(name='Metadata', version=glue.Version.LATEST),
|
|
374
416
|
where=glue.Conditions(
|
|
375
417
|
glue.Condition(
|
|
376
|
-
|
|
418
|
+
left=glue.FieldReferenceExpression(
|
|
419
|
+
field_reference=glue.FieldReference(field=_parent_field, table_name='Metadata'),
|
|
420
|
+
output_type=str,
|
|
421
|
+
),
|
|
377
422
|
lookup=glue.FieldLookup.EQ,
|
|
378
|
-
|
|
423
|
+
right=glue.Value(transaction_id, output_type=str),
|
|
379
424
|
)
|
|
380
425
|
),
|
|
381
426
|
order_by=[
|
amsdal/utils/tests/helpers.py
CHANGED
|
@@ -14,25 +14,24 @@ from typing import Any
|
|
|
14
14
|
|
|
15
15
|
import yaml
|
|
16
16
|
from amsdal_data.application import AsyncDataApplication
|
|
17
|
+
from amsdal_models.migration import MigrationsLoader
|
|
18
|
+
from amsdal_models.migration import migrations
|
|
19
|
+
from amsdal_models.migration.executors.default_executor import DefaultAsyncMigrationExecutor
|
|
20
|
+
from amsdal_models.migration.executors.default_executor import DefaultMigrationExecutor
|
|
21
|
+
from amsdal_models.migration.file_migration_executor import FileMigrationExecutorManager
|
|
22
|
+
from amsdal_models.migration.file_migration_generator import FileMigrationGenerator
|
|
23
|
+
from amsdal_models.migration.file_migration_writer import FileMigrationWriter
|
|
24
|
+
from amsdal_models.migration.migrations import MigrateData
|
|
25
|
+
from amsdal_models.migration.migrations import MigrationSchemas
|
|
26
|
+
from amsdal_models.migration.schemas_loaders import JsonClassSchemaLoader # type: ignore
|
|
27
|
+
from amsdal_models.migration.utils import contrib_to_module_root_path
|
|
17
28
|
from amsdal_utils.config.manager import AmsdalConfigManager
|
|
18
|
-
from amsdal_utils.models.enums import
|
|
29
|
+
from amsdal_utils.models.enums import ModuleType
|
|
19
30
|
|
|
20
31
|
from amsdal.configs.constants import CORE_MIGRATIONS_PATH
|
|
21
32
|
from amsdal.configs.main import settings
|
|
22
33
|
from amsdal.manager import AmsdalManager
|
|
23
34
|
from amsdal.manager import AsyncAmsdalManager
|
|
24
|
-
from amsdal.migration import migrations
|
|
25
|
-
from amsdal.migration.data_classes import ModuleTypes
|
|
26
|
-
from amsdal.migration.executors.default_executor import DefaultAsyncMigrationExecutor
|
|
27
|
-
from amsdal.migration.executors.default_executor import DefaultMigrationExecutor
|
|
28
|
-
from amsdal.migration.file_migration_executor import FileMigrationExecutorManager
|
|
29
|
-
from amsdal.migration.file_migration_generator import FileMigrationGenerator
|
|
30
|
-
from amsdal.migration.file_migration_writer import FileMigrationWriter
|
|
31
|
-
from amsdal.migration.migrations import MigrateData
|
|
32
|
-
from amsdal.migration.migrations import MigrationSchemas
|
|
33
|
-
from amsdal.migration.migrations_loader import MigrationsLoader
|
|
34
|
-
from amsdal.migration.schemas_loaders import JsonClassSchemaLoader
|
|
35
|
-
from amsdal.migration.utils import contrib_to_module_root_path
|
|
36
35
|
from amsdal.utils.tests.enums import DbExecutionType
|
|
37
36
|
from amsdal.utils.tests.enums import LakehouseOption
|
|
38
37
|
from amsdal.utils.tests.enums import StateOption
|
|
@@ -102,11 +101,21 @@ def _get_config_template(
|
|
|
102
101
|
'application_name': 'test_client_app',
|
|
103
102
|
'async_mode': is_async,
|
|
104
103
|
'connections': [
|
|
105
|
-
{
|
|
104
|
+
{
|
|
105
|
+
'name': 'lock',
|
|
106
|
+
'backend': 'amsdal_data.lock.implementations.thread_lock.ThreadLock',
|
|
107
|
+
},
|
|
106
108
|
],
|
|
107
|
-
'resources_config': {
|
|
109
|
+
'resources_config': {
|
|
110
|
+
'lakehouse': 'lakehouse',
|
|
111
|
+
'lock': 'lock',
|
|
112
|
+
'repository': {'default': 'state'},
|
|
113
|
+
},
|
|
108
114
|
}
|
|
109
|
-
if lakehouse_option in [
|
|
115
|
+
if lakehouse_option in [
|
|
116
|
+
LakehouseOption.postgres,
|
|
117
|
+
LakehouseOption.postgres_immutable,
|
|
118
|
+
]:
|
|
110
119
|
config_object['connections'].append(
|
|
111
120
|
{
|
|
112
121
|
'name': 'lakehouse',
|
|
@@ -182,7 +191,10 @@ def _init_manager(
|
|
|
182
191
|
state_database = ''.join(random.sample(string.ascii_letters, 16))
|
|
183
192
|
config_text = _get_config_template(db_execution_type, lakehouse_option, state_option, is_async=is_async)
|
|
184
193
|
|
|
185
|
-
if lakehouse_option in [
|
|
194
|
+
if lakehouse_option in [
|
|
195
|
+
LakehouseOption.postgres,
|
|
196
|
+
LakehouseOption.postgres_immutable,
|
|
197
|
+
]:
|
|
186
198
|
(
|
|
187
199
|
db_host,
|
|
188
200
|
db_port,
|
|
@@ -197,7 +209,10 @@ def _init_manager(
|
|
|
197
209
|
.replace('{{ db_password }}', db_password)
|
|
198
210
|
.replace('{{ lakehouse_postgres_db }}', lakehouse_database)
|
|
199
211
|
)
|
|
200
|
-
elif lakehouse_option in [
|
|
212
|
+
elif lakehouse_option in [
|
|
213
|
+
LakehouseOption.sqlite,
|
|
214
|
+
LakehouseOption.sqlite_immutable,
|
|
215
|
+
]:
|
|
201
216
|
config_text = config_text.replace('{{ db_dir }}', db_dir.absolute().as_posix())
|
|
202
217
|
|
|
203
218
|
if state_option == StateOption.postgres:
|
|
@@ -224,7 +239,10 @@ def init_manager(
|
|
|
224
239
|
lakehouse_option: LakehouseOption,
|
|
225
240
|
state_option: StateOption,
|
|
226
241
|
) -> Generator[AmsdalManager, Any, None]:
|
|
227
|
-
with _init_manager(db_execution_type, lakehouse_option, state_option) as (
|
|
242
|
+
with _init_manager(db_execution_type, lakehouse_option, state_option) as (
|
|
243
|
+
db_dir,
|
|
244
|
+
config_path,
|
|
245
|
+
):
|
|
228
246
|
with override_settings(APP_PATH=db_dir, CONFIG_PATH=config_path):
|
|
229
247
|
config_manager = AmsdalConfigManager()
|
|
230
248
|
config_manager.load_config(config_path)
|
|
@@ -274,7 +292,7 @@ def migrate(app_schemas_path: Path) -> None:
|
|
|
274
292
|
executor,
|
|
275
293
|
MigrationsLoader(
|
|
276
294
|
migrations_dir=CORE_MIGRATIONS_PATH,
|
|
277
|
-
module_type=
|
|
295
|
+
module_type=ModuleType.CORE,
|
|
278
296
|
),
|
|
279
297
|
)
|
|
280
298
|
|
|
@@ -284,7 +302,7 @@ def migrate(app_schemas_path: Path) -> None:
|
|
|
284
302
|
executor,
|
|
285
303
|
MigrationsLoader(
|
|
286
304
|
migrations_dir=contrib_root_path / settings.MIGRATIONS_DIRECTORY_NAME,
|
|
287
|
-
module_type=
|
|
305
|
+
module_type=ModuleType.CONTRIB,
|
|
288
306
|
module_name=contrib,
|
|
289
307
|
),
|
|
290
308
|
)
|
|
@@ -293,7 +311,7 @@ def migrate(app_schemas_path: Path) -> None:
|
|
|
293
311
|
|
|
294
312
|
for class_schema in schema_loader.iter_app_schemas():
|
|
295
313
|
for _operation_data in FileMigrationGenerator.build_operations(
|
|
296
|
-
|
|
314
|
+
ModuleType.USER,
|
|
297
315
|
class_schema.object_schema,
|
|
298
316
|
None,
|
|
299
317
|
):
|
|
@@ -307,7 +325,7 @@ def migrate(app_schemas_path: Path) -> None:
|
|
|
307
325
|
kwargs['new_schema'] = _operation_data.new_schema.model_dump()
|
|
308
326
|
|
|
309
327
|
_operation = getattr(migrations, _operation_name)(
|
|
310
|
-
schema_type=
|
|
328
|
+
schema_type=ModuleType.USER,
|
|
311
329
|
class_name=_operation_data.class_name,
|
|
312
330
|
**kwargs,
|
|
313
331
|
)
|
|
@@ -338,7 +356,7 @@ async def async_migrate(app_schemas_path: Path) -> None:
|
|
|
338
356
|
executor,
|
|
339
357
|
MigrationsLoader(
|
|
340
358
|
migrations_dir=CORE_MIGRATIONS_PATH,
|
|
341
|
-
module_type=
|
|
359
|
+
module_type=ModuleType.CORE,
|
|
342
360
|
),
|
|
343
361
|
)
|
|
344
362
|
|
|
@@ -348,7 +366,7 @@ async def async_migrate(app_schemas_path: Path) -> None:
|
|
|
348
366
|
executor,
|
|
349
367
|
MigrationsLoader(
|
|
350
368
|
migrations_dir=contrib_root_path / settings.MIGRATIONS_DIRECTORY_NAME,
|
|
351
|
-
module_type=
|
|
369
|
+
module_type=ModuleType.CONTRIB,
|
|
352
370
|
module_name=contrib,
|
|
353
371
|
),
|
|
354
372
|
)
|
|
@@ -357,7 +375,7 @@ async def async_migrate(app_schemas_path: Path) -> None:
|
|
|
357
375
|
|
|
358
376
|
for class_schema in schema_loader.iter_app_schemas():
|
|
359
377
|
for _operation_data in FileMigrationGenerator.build_operations(
|
|
360
|
-
|
|
378
|
+
ModuleType.USER,
|
|
361
379
|
class_schema.object_schema,
|
|
362
380
|
None,
|
|
363
381
|
):
|
|
@@ -371,7 +389,7 @@ async def async_migrate(app_schemas_path: Path) -> None:
|
|
|
371
389
|
kwargs['new_schema'] = _operation_data.new_schema.model_dump()
|
|
372
390
|
|
|
373
391
|
_operation = getattr(migrations, _operation_name)(
|
|
374
|
-
schema_type=
|
|
392
|
+
schema_type=ModuleType.USER,
|
|
375
393
|
class_name=_operation_data.class_name,
|
|
376
394
|
**kwargs,
|
|
377
395
|
)
|
|
@@ -406,17 +424,8 @@ def init_manager_and_migrate(
|
|
|
406
424
|
lakehouse_option=lakehouse_option,
|
|
407
425
|
state_option=state_option,
|
|
408
426
|
) as manager:
|
|
409
|
-
src_dir_path = TESTS_DIR / 'src'
|
|
410
|
-
app_schemas_path = src_dir_path / 'models'
|
|
411
|
-
manager.build(
|
|
412
|
-
source_models_path=app_schemas_path,
|
|
413
|
-
source_fixtures_path=app_schemas_path,
|
|
414
|
-
source_transactions_path=src_dir_path,
|
|
415
|
-
source_static_files_path=app_schemas_path,
|
|
416
|
-
source_migrations_path=app_schemas_path,
|
|
417
|
-
)
|
|
418
427
|
manager.authenticate()
|
|
419
|
-
migrate(
|
|
428
|
+
migrate()
|
|
420
429
|
manager.init_classes()
|
|
421
430
|
|
|
422
431
|
yield manager
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: amsdal
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: AMSDAL
|
|
5
5
|
License: AMSDAL End User License Agreement
|
|
6
6
|
|
|
@@ -115,11 +115,11 @@ Project-URL: Issues, https://pypi.org/project/amsdal/
|
|
|
115
115
|
Project-URL: Source, https://pypi.org/project/amsdal/
|
|
116
116
|
Classifier: Development Status :: 4 - Beta
|
|
117
117
|
Classifier: Programming Language :: Python
|
|
118
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
119
118
|
Classifier: Programming Language :: Python :: 3.11
|
|
119
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
120
120
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
121
121
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
122
|
-
Requires-Python: >=3.
|
|
122
|
+
Requires-Python: >=3.11
|
|
123
123
|
Description-Content-Type: text/markdown
|
|
124
124
|
License-File: LICENSE.txt
|
|
125
125
|
Requires-Dist: pydantic~=2.3
|
|
@@ -129,13 +129,13 @@ Requires-Dist: cryptography~=42.0
|
|
|
129
129
|
Requires-Dist: httpx~=0.25
|
|
130
130
|
Requires-Dist: bcrypt~=4.0
|
|
131
131
|
Requires-Dist: black>=24.3.0
|
|
132
|
-
Requires-Dist: amsdal_utils==0.
|
|
133
|
-
Requires-Dist: amsdal_data[postgres-binary]==0.
|
|
134
|
-
Requires-Dist: amsdal_models
|
|
132
|
+
Requires-Dist: amsdal_utils==0.4.*
|
|
133
|
+
Requires-Dist: amsdal_data[postgres-binary]==0.4.*
|
|
134
|
+
Requires-Dist: amsdal_models<0.5,>=0.4.1
|
|
135
135
|
Provides-Extra: cli
|
|
136
|
-
Requires-Dist: amsdal-cli==0.
|
|
136
|
+
Requires-Dist: amsdal-cli==0.4.*; extra == "cli"
|
|
137
137
|
Provides-Extra: server
|
|
138
|
-
Requires-Dist: amsdal-server==0.
|
|
138
|
+
Requires-Dist: amsdal-server==0.4.*; extra == "server"
|
|
139
139
|
Provides-Extra: factory
|
|
140
140
|
Requires-Dist: polyfactory==2.*; extra == "factory"
|
|
141
141
|
Provides-Extra: celery
|