arpakitlib 1.7.11__py3-none-any.whl → 1.7.14__py3-none-any.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.
- arpakitlib/_arpakit_project_template/AUTHOR.md +1 -3
- arpakitlib/_arpakit_project_template/src/api/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/api/asgi.py +3 -0
- arpakitlib/_arpakit_project_template/src/api/create_api_app.py +5 -0
- arpakitlib/_arpakit_project_template/src/api/event.py +24 -0
- arpakitlib/_arpakit_project_template/src/api/start_api_for_dev.py +15 -0
- arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +9 -0
- arpakitlib/_arpakit_project_template/src/core/operation_executor.py +12 -0
- arpakitlib/_arpakit_project_template/src/core/scheduled_operations.py +12 -0
- arpakitlib/_arpakit_project_template/src/db/sqlalchemy_model.py +0 -1
- arpakitlib/_arpakit_project_template/src/db/util.py +0 -0
- arpakitlib/ar_operation_execution_util.py +25 -25
- {arpakitlib-1.7.11.dist-info → arpakitlib-1.7.14.dist-info}/METADATA +2 -1
- {arpakitlib-1.7.11.dist-info → arpakitlib-1.7.14.dist-info}/RECORD +18 -9
- {arpakitlib-1.7.11.dist-info → arpakitlib-1.7.14.dist-info}/LICENSE +0 -0
- {arpakitlib-1.7.11.dist-info → arpakitlib-1.7.14.dist-info}/NOTICE +0 -0
- {arpakitlib-1.7.11.dist-info → arpakitlib-1.7.14.dist-info}/WHEEL +0 -0
- {arpakitlib-1.7.11.dist-info → arpakitlib-1.7.14.dist-info}/entry_points.txt +0 -0
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from arpakitlib.ar_fastapi_util import BaseStartupAPIEvent, BaseShutdownAPIEvent
|
4
|
+
from src.api.transmitted_api_data import TransmittedAPIData
|
5
|
+
|
6
|
+
_logger = logging.getLogger(__name__)
|
7
|
+
|
8
|
+
|
9
|
+
class StartupAPIEvent(BaseStartupAPIEvent):
|
10
|
+
def __init__(self, transmitted_api_data: TransmittedAPIData):
|
11
|
+
super().__init__()
|
12
|
+
self.transmitted_api_data = transmitted_api_data
|
13
|
+
|
14
|
+
async def async_on_startup(self, *args, **kwargs):
|
15
|
+
pass
|
16
|
+
|
17
|
+
|
18
|
+
class ShutdownAPIEvent(BaseShutdownAPIEvent):
|
19
|
+
def __init__(self, transmitted_api_data: TransmittedAPIData):
|
20
|
+
super().__init__()
|
21
|
+
self.transmitted_api_data = transmitted_api_data
|
22
|
+
|
23
|
+
async def async_on_shutdown(self, *args, **kwargs):
|
24
|
+
pass
|
@@ -0,0 +1,9 @@
|
|
1
|
+
from arpakitlib.ar_fastapi_util import BaseTransmittedAPIData
|
2
|
+
from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
|
3
|
+
|
4
|
+
from src.core.settings import Settings
|
5
|
+
|
6
|
+
|
7
|
+
class TransmittedAPIData(BaseTransmittedAPIData):
|
8
|
+
settings: Settings
|
9
|
+
sqlalchemy_db: SQLAlchemyDB | None = None
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from arpakitlib.ar_operation_execution_util import BaseOperationExecutor
|
2
|
+
from arpakitlib.ar_sqlalchemy_model_util import OperationDBM
|
3
|
+
|
4
|
+
|
5
|
+
class OperationExecutor(BaseOperationExecutor):
|
6
|
+
def sync_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
7
|
+
operation_dbm = super().sync_execute_operation(operation_dbm=operation_dbm)
|
8
|
+
return operation_dbm
|
9
|
+
|
10
|
+
async def async_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
11
|
+
operation_dbm = await super().async_execute_operation(operation_dbm=operation_dbm)
|
12
|
+
return operation_dbm
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from arpakitlib.ar_operation_execution_util import ScheduledOperation
|
2
|
+
|
3
|
+
from arpakitlib.ar_sqlalchemy_model_util import OperationDBM
|
4
|
+
|
5
|
+
SCHEDULED_OPERATIONS = []
|
6
|
+
|
7
|
+
operation = ScheduledOperation(
|
8
|
+
type=OperationDBM.Types.healthcheck_,
|
9
|
+
input_data={},
|
10
|
+
is_time_func=lambda: True
|
11
|
+
)
|
12
|
+
SCHEDULED_OPERATIONS.append(operation)
|
@@ -1 +0,0 @@
|
|
1
|
-
# ...
|
File without changes
|
@@ -64,7 +64,7 @@ class BaseOperationExecutor:
|
|
64
64
|
self._logger = logging.getLogger(self.__class__.__name__)
|
65
65
|
self.sql_alchemy_db = sqlalchemy_db
|
66
66
|
|
67
|
-
|
67
|
+
def sync_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
68
68
|
if operation_dbm.type == OperationDBM.Types.healthcheck_:
|
69
69
|
self._logger.info("healthcheck")
|
70
70
|
elif operation_dbm.type == OperationDBM.Types.raise_fake_exception_:
|
@@ -72,9 +72,9 @@ class BaseOperationExecutor:
|
|
72
72
|
raise Exception("raise_fake_exception")
|
73
73
|
return operation_dbm
|
74
74
|
|
75
|
-
|
75
|
+
def sync_safe_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
76
76
|
self._logger.info(
|
77
|
-
f"start
|
77
|
+
f"start sync_safe_execute_operation"
|
78
78
|
f", operation_dbm.id={operation_dbm.id}"
|
79
79
|
f", operation_dbm.type={operation_dbm.type}"
|
80
80
|
)
|
@@ -92,7 +92,7 @@ class BaseOperationExecutor:
|
|
92
92
|
traceback_str: str | None = None
|
93
93
|
|
94
94
|
try:
|
95
|
-
|
95
|
+
self.sync_execute_operation(operation_dbm=operation_dbm)
|
96
96
|
except BaseException as exception_:
|
97
97
|
self._logger.exception(exception_)
|
98
98
|
exception = exception_
|
@@ -116,7 +116,7 @@ class BaseOperationExecutor:
|
|
116
116
|
|
117
117
|
story_log_dbm = StoryLogDBM(
|
118
118
|
level=StoryLogDBM.Levels.error,
|
119
|
-
title="Error in
|
119
|
+
title="Error in sync_execute_operation",
|
120
120
|
data={
|
121
121
|
"operation_id": operation_dbm.id,
|
122
122
|
"exception_str": str(exception),
|
@@ -130,14 +130,15 @@ class BaseOperationExecutor:
|
|
130
130
|
session.refresh(story_log_dbm)
|
131
131
|
|
132
132
|
self._logger.info(
|
133
|
-
f"finish
|
133
|
+
f"finish sync_safe_execute_operation"
|
134
134
|
f", operation_dbm.id={operation_dbm.id}"
|
135
135
|
f", operation_dbm.type={operation_dbm.type}"
|
136
|
+
f", operation_dbm.duration={operation_dbm.duration}"
|
136
137
|
)
|
137
138
|
|
138
139
|
return operation_dbm
|
139
140
|
|
140
|
-
def
|
141
|
+
async def async_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
141
142
|
if operation_dbm.type == OperationDBM.Types.healthcheck_:
|
142
143
|
self._logger.info("healthcheck")
|
143
144
|
elif operation_dbm.type == OperationDBM.Types.raise_fake_exception_:
|
@@ -145,9 +146,9 @@ class BaseOperationExecutor:
|
|
145
146
|
raise Exception("raise_fake_exception")
|
146
147
|
return operation_dbm
|
147
148
|
|
148
|
-
def
|
149
|
+
async def async_safe_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
149
150
|
self._logger.info(
|
150
|
-
f"start
|
151
|
+
f"start async_safe_execute_operation"
|
151
152
|
f", operation_dbm.id={operation_dbm.id}"
|
152
153
|
f", operation_dbm.type={operation_dbm.type}"
|
153
154
|
)
|
@@ -165,7 +166,7 @@ class BaseOperationExecutor:
|
|
165
166
|
traceback_str: str | None = None
|
166
167
|
|
167
168
|
try:
|
168
|
-
self.
|
169
|
+
await self.async_execute_operation(operation_dbm=operation_dbm)
|
169
170
|
except BaseException as exception_:
|
170
171
|
self._logger.exception(exception_)
|
171
172
|
exception = exception_
|
@@ -189,7 +190,7 @@ class BaseOperationExecutor:
|
|
189
190
|
|
190
191
|
story_log_dbm = StoryLogDBM(
|
191
192
|
level=StoryLogDBM.Levels.error,
|
192
|
-
title="Error in
|
193
|
+
title="Error in async_execute_operation",
|
193
194
|
data={
|
194
195
|
"operation_id": operation_dbm.id,
|
195
196
|
"exception_str": str(exception),
|
@@ -203,10 +204,9 @@ class BaseOperationExecutor:
|
|
203
204
|
session.refresh(story_log_dbm)
|
204
205
|
|
205
206
|
self._logger.info(
|
206
|
-
f"finish
|
207
|
+
f"finish async_safe_execute_operation"
|
207
208
|
f", operation_dbm.id={operation_dbm.id}"
|
208
209
|
f", operation_dbm.type={operation_dbm.type}"
|
209
|
-
f", operation_dbm.duration={operation_dbm.duration}"
|
210
210
|
)
|
211
211
|
|
212
212
|
return operation_dbm
|
@@ -232,13 +232,13 @@ class ExecuteOperationWorker(BaseWorker):
|
|
232
232
|
self.operation_executor = operation_executor
|
233
233
|
self.filter_operation_type = filter_operation_type
|
234
234
|
|
235
|
-
|
235
|
+
def sync_on_startup(self):
|
236
236
|
self.sqlalchemy_db.init()
|
237
237
|
|
238
|
-
|
239
|
-
return
|
238
|
+
def sync_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
239
|
+
return self.operation_executor.sync_safe_execute_operation(operation_dbm=operation_dbm)
|
240
240
|
|
241
|
-
|
241
|
+
def sync_run(self):
|
242
242
|
operation_dbm: OperationDBM | None = get_operation_for_execution(
|
243
243
|
sqlalchemy_db=self.sqlalchemy_db,
|
244
244
|
filter_operation_type=self.filter_operation_type
|
@@ -247,18 +247,18 @@ class ExecuteOperationWorker(BaseWorker):
|
|
247
247
|
if not operation_dbm:
|
248
248
|
return
|
249
249
|
|
250
|
-
|
250
|
+
self.sync_execute_operation(operation_dbm=operation_dbm)
|
251
251
|
|
252
|
-
|
252
|
+
def sync_run_on_error(self, exception: BaseException, **kwargs):
|
253
253
|
self._logger.exception(exception)
|
254
254
|
|
255
|
-
def
|
255
|
+
async def async_on_startup(self):
|
256
256
|
self.sqlalchemy_db.init()
|
257
257
|
|
258
|
-
def
|
259
|
-
return self.operation_executor.
|
258
|
+
async def async_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
259
|
+
return await self.operation_executor.async_safe_execute_operation(operation_dbm=operation_dbm)
|
260
260
|
|
261
|
-
def
|
261
|
+
async def async_run(self):
|
262
262
|
operation_dbm: OperationDBM | None = get_operation_for_execution(
|
263
263
|
sqlalchemy_db=self.sqlalchemy_db,
|
264
264
|
filter_operation_type=self.filter_operation_type
|
@@ -267,9 +267,9 @@ class ExecuteOperationWorker(BaseWorker):
|
|
267
267
|
if not operation_dbm:
|
268
268
|
return
|
269
269
|
|
270
|
-
self.
|
270
|
+
await self.async_execute_operation(operation_dbm=operation_dbm)
|
271
271
|
|
272
|
-
def
|
272
|
+
async def async_run_on_error(self, exception: BaseException, **kwargs):
|
273
273
|
self._logger.exception(exception)
|
274
274
|
|
275
275
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: arpakitlib
|
3
|
-
Version: 1.7.
|
3
|
+
Version: 1.7.14
|
4
4
|
Summary: arpakitlib
|
5
5
|
Home-page: https://github.com/ARPAKIT-Company/arpakitlib
|
6
6
|
License: Apache-2.0
|
@@ -37,6 +37,7 @@ Requires-Dist: openai (>=1.55.3,<2.0.0)
|
|
37
37
|
Requires-Dist: openpyxl (>=3.1.5,<4.0.0)
|
38
38
|
Requires-Dist: pandas (>=2.2.3,<3.0.0)
|
39
39
|
Requires-Dist: paramiko (>=3.5.0,<4.0.0)
|
40
|
+
Requires-Dist: poetry (>=1.8.5,<2.0.0)
|
40
41
|
Requires-Dist: psycopg2-binary (>=2.9.10,<3.0.0)
|
41
42
|
Requires-Dist: pydantic-settings (>=2.6.1,<3.0.0)
|
42
43
|
Requires-Dist: pyjwt (>=2.10.1,<3.0.0)
|
@@ -2,7 +2,7 @@ arpakitlib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
arpakitlib/_arpakit_project_template/.gitignore,sha256=VdBkYniyHE4ALbEeuh6kzLMFu1M2iPy7U2x7qs2KeKQ,420
|
3
3
|
arpakitlib/_arpakit_project_template/.python-version,sha256=XMd40XBnlTFfBSmMldd-7VdqXNyFCy6wtxhw5e1mnhc,7
|
4
4
|
arpakitlib/_arpakit_project_template/ARPAKITLIB,sha256=3-iAkMXtesLzJXHw_IIv2k2M0oH8cTjHzW22Vvbi0IE,4
|
5
|
-
arpakitlib/_arpakit_project_template/AUTHOR.md,sha256=
|
5
|
+
arpakitlib/_arpakit_project_template/AUTHOR.md,sha256=d5QAx-1vbHfYYABpNQ0Yfjaxsw8UnfXhcLVirz6lMyo,45
|
6
6
|
arpakitlib/_arpakit_project_template/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
7
7
|
arpakitlib/_arpakit_project_template/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
|
8
8
|
arpakitlib/_arpakit_project_template/README.md,sha256=aR1tz5-7YOpCcs3Jc0C5UkAlYUzMw-x9Wqq4EGcj12A,22
|
@@ -66,13 +66,22 @@ arpakitlib/_arpakit_project_template/resource/static/__init__.py,sha256=47DEQpj8
|
|
66
66
|
arpakitlib/_arpakit_project_template/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
67
67
|
arpakitlib/_arpakit_project_template/src/additional_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
68
68
|
arpakitlib/_arpakit_project_template/src/additional_model/additional_model.py,sha256=4KCOvto9Hj5eMYpvfaJChghhR9bkCvKluGGPWrTezoY,134
|
69
|
+
arpakitlib/_arpakit_project_template/src/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
70
|
+
arpakitlib/_arpakit_project_template/src/api/asgi.py,sha256=a5UBxOyNC8NG3E0ayhiDo3t5tPoB3WtOf2gbZJFWBAA,74
|
71
|
+
arpakitlib/_arpakit_project_template/src/api/create_api_app.py,sha256=alLtgeeTBuQXK4Bq5w9CDI5nkslYAa7mJ4vo3uCgqR0,72
|
72
|
+
arpakitlib/_arpakit_project_template/src/api/event.py,sha256=5CGfQ9xcEqNp3rGAod-XvobShy-AlFOKmp6p7PAzuxk,729
|
73
|
+
arpakitlib/_arpakit_project_template/src/api/start_api_for_dev.py,sha256=MndA66oVIEmhNTYAaSgaz4lz2vsfFrFa3lp24UTOwks,250
|
74
|
+
arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py,sha256=YtpATqzN216e76W5QOuzN-Vo6343PVDiHpKWYQ6oqyU,278
|
69
75
|
arpakitlib/_arpakit_project_template/src/business_service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
70
76
|
arpakitlib/_arpakit_project_template/src/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
71
77
|
arpakitlib/_arpakit_project_template/src/core/const.py,sha256=CZZew674y7LhCAlYhvuF5cV4Zb9nQ17j2Tcuj2GEBf4,1232
|
78
|
+
arpakitlib/_arpakit_project_template/src/core/operation_executor.py,sha256=oTz6gWnhfOUevjo44OK6lx4f4A9x5SuFJOUsuO-YzIo,591
|
79
|
+
arpakitlib/_arpakit_project_template/src/core/scheduled_operations.py,sha256=W6ALtmW8oNuX0Y03Aqfgb4WlUWKtQetRgv1P3Lp6acE,324
|
72
80
|
arpakitlib/_arpakit_project_template/src/core/settings.py,sha256=9NtT7KNpyqjZKbYkYRjVKfBzHnD7aLPsrOVyCyPyK5c,1242
|
73
81
|
arpakitlib/_arpakit_project_template/src/core/util.py,sha256=PG0RlXrcAMtRBd9BB-Zp3N5009wASqTI2T6PNixj1ZM,1706
|
74
82
|
arpakitlib/_arpakit_project_template/src/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
75
|
-
arpakitlib/_arpakit_project_template/src/db/sqlalchemy_model.py,sha256=
|
83
|
+
arpakitlib/_arpakit_project_template/src/db/sqlalchemy_model.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
84
|
+
arpakitlib/_arpakit_project_template/src/db/util.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
76
85
|
arpakitlib/_arpakit_project_template/src/test_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
77
86
|
arpakitlib/_arpakit_project_template/src/test_data/make_test_data_1.py,sha256=3WVPgRsNCIxWpA-6t_Phe-nFULdHPhS1S_DO11XRmqk,80
|
78
87
|
arpakitlib/_arpakit_project_template/src/test_data/make_test_data_2.py,sha256=MVDc71sj5I1muWin50GwrSxMwYtOOSDOtRmeFErHcXs,80
|
@@ -127,7 +136,7 @@ arpakitlib/ar_logging_util.py,sha256=Gyd7B9k0glIXPm6dASiigWLq9LC9lw6vhXTCeWpY5PY
|
|
127
136
|
arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk,4038
|
128
137
|
arpakitlib/ar_need_type_util.py,sha256=xq5bbAXJG-93CRVZUcLW0ZdM22rj-ZUW17C5hX_5grg,1699
|
129
138
|
arpakitlib/ar_openai_api_client_util.py,sha256=dHUbfg1sVVCjsNl_fra3iCMEz1bR-Hk9fE-DdYbu7Wc,1215
|
130
|
-
arpakitlib/ar_operation_execution_util.py,sha256=
|
139
|
+
arpakitlib/ar_operation_execution_util.py,sha256=2neWCjko_UwDdIhhHrCKbwR3L_ve7dHbtGNJf6OZ9ug,12373
|
131
140
|
arpakitlib/ar_parse_command.py,sha256=-s61xcATIsfw1eV_iD3xi-grsitbGzSDoAFc5V0OFy4,3447
|
132
141
|
arpakitlib/ar_postgresql_util.py,sha256=1AuLjEaa1Lg4pzn-ukCVnDi35Eg1k91APRTqZhIJAdo,945
|
133
142
|
arpakitlib/ar_project_template_util.py,sha256=RpzLFTjutqKmGTI6PrewfJFMwXGz7ZbXJjHjGHh6KpI,3164
|
@@ -142,9 +151,9 @@ arpakitlib/ar_str_util.py,sha256=oCEtQ_TTn35OEz9jCNLjbhopq76JmaifD_iYR-nEJJ4,214
|
|
142
151
|
arpakitlib/ar_type_util.py,sha256=GNc9PgFKonj5lRlAHSnVPBN5nLIslrG8GTiZHjkf05w,2138
|
143
152
|
arpakitlib/ar_yookassa_api_client_util.py,sha256=sh4fcUkAkdOetFn9JYoTvjcSXP-M1wU04KEY-ECLfLg,5137
|
144
153
|
arpakitlib/ar_zabbix_api_client_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
|
145
|
-
arpakitlib-1.7.
|
146
|
-
arpakitlib-1.7.
|
147
|
-
arpakitlib-1.7.
|
148
|
-
arpakitlib-1.7.
|
149
|
-
arpakitlib-1.7.
|
150
|
-
arpakitlib-1.7.
|
154
|
+
arpakitlib-1.7.14.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
155
|
+
arpakitlib-1.7.14.dist-info/METADATA,sha256=IN6o0dneQYeXMFm6bvldreVVMRdsnmIy4Ixc8rStFB4,2811
|
156
|
+
arpakitlib-1.7.14.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
|
157
|
+
arpakitlib-1.7.14.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
158
|
+
arpakitlib-1.7.14.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
|
159
|
+
arpakitlib-1.7.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|