arpakitlib 1.7.96__py3-none-any.whl → 1.7.97__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/src/db/const.py +0 -0
- arpakitlib/ar_base_worker_util.py +1 -1
- arpakitlib/ar_operation_execution_util.py +51 -61
- {arpakitlib-1.7.96.dist-info → arpakitlib-1.7.97.dist-info}/METADATA +1 -1
- {arpakitlib-1.7.96.dist-info → arpakitlib-1.7.97.dist-info}/RECORD +9 -8
- {arpakitlib-1.7.96.dist-info → arpakitlib-1.7.97.dist-info}/LICENSE +0 -0
- {arpakitlib-1.7.96.dist-info → arpakitlib-1.7.97.dist-info}/NOTICE +0 -0
- {arpakitlib-1.7.96.dist-info → arpakitlib-1.7.97.dist-info}/WHEEL +0 -0
- {arpakitlib-1.7.96.dist-info → arpakitlib-1.7.97.dist-info}/entry_points.txt +0 -0
File without changes
|
@@ -34,7 +34,7 @@ class BaseWorker(ABC):
|
|
34
34
|
worker_name = self.__class__.__name__
|
35
35
|
self.worker_name = worker_name
|
36
36
|
self.worker_creation_dt = now_utc_dt()
|
37
|
-
self.worker_id = f"{str(uuid4()).replace('
|
37
|
+
self.worker_id = f"{str(uuid4()).replace('-', '')}_{randint(1000, 99999)}"
|
38
38
|
self.worker_fullname = (
|
39
39
|
f"{self.worker_name}_{self.worker_creation_dt.isoformat()}_{self.worker_id}"
|
40
40
|
)
|
@@ -145,7 +145,7 @@ class BaseOperationExecutor:
|
|
145
145
|
self._logger = logging.getLogger(self.__class__.__name__)
|
146
146
|
self.sql_alchemy_db = sqlalchemy_db
|
147
147
|
|
148
|
-
def sync_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
148
|
+
def sync_execute_operation(self, operation_dbm: OperationDBM, session: Session) -> OperationDBM:
|
149
149
|
if operation_dbm.type == BaseOperationTypes.healthcheck_:
|
150
150
|
self._logger.info("healthcheck")
|
151
151
|
elif operation_dbm.type == BaseOperationTypes.raise_fake_exception_:
|
@@ -172,13 +172,12 @@ class BaseOperationExecutor:
|
|
172
172
|
}
|
173
173
|
)
|
174
174
|
session.commit()
|
175
|
-
session.refresh(operation_dbm)
|
176
175
|
|
177
176
|
exception: BaseException | None = None
|
178
177
|
traceback_str: str | None = None
|
179
178
|
|
180
179
|
try:
|
181
|
-
self.sync_execute_operation(operation_dbm=operation_dbm)
|
180
|
+
self.sync_execute_operation(operation_dbm=operation_dbm, session=session)
|
182
181
|
except BaseException as exception_:
|
183
182
|
self._logger.error(
|
184
183
|
f"error in sync_execute_operation (id={operation_dbm.id}, type={operation_dbm.type})",
|
@@ -213,7 +212,6 @@ class BaseOperationExecutor:
|
|
213
212
|
)
|
214
213
|
session.add(story_log_dbm)
|
215
214
|
session.commit()
|
216
|
-
session.refresh(story_log_dbm)
|
217
215
|
|
218
216
|
session.refresh(operation_dbm)
|
219
217
|
|
@@ -227,7 +225,7 @@ class BaseOperationExecutor:
|
|
227
225
|
|
228
226
|
return operation_dbm
|
229
227
|
|
230
|
-
async def async_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
228
|
+
async def async_execute_operation(self, operation_dbm: OperationDBM, session: Session) -> OperationDBM:
|
231
229
|
if operation_dbm.type == BaseOperationTypes.healthcheck_:
|
232
230
|
self._logger.info("healthcheck")
|
233
231
|
elif operation_dbm.type == BaseOperationTypes.raise_fake_exception_:
|
@@ -236,7 +234,7 @@ class BaseOperationExecutor:
|
|
236
234
|
return operation_dbm
|
237
235
|
|
238
236
|
async def async_safe_execute_operation(
|
239
|
-
self, operation_dbm: OperationDBM, worker: OperationExecutorWorker
|
237
|
+
self, operation_dbm: OperationDBM, worker: OperationExecutorWorker, session: Session
|
240
238
|
) -> OperationDBM:
|
241
239
|
self._logger.info(
|
242
240
|
f"start "
|
@@ -245,26 +243,21 @@ class BaseOperationExecutor:
|
|
245
243
|
f"operation_dbm.status={operation_dbm.status}"
|
246
244
|
)
|
247
245
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
worker.worker_fullname: True
|
258
|
-
}
|
259
|
-
)
|
260
|
-
session.commit()
|
261
|
-
session.refresh(operation_dbm)
|
246
|
+
operation_dbm.execution_start_dt = now_utc_dt()
|
247
|
+
operation_dbm.status = OperationDBM.Statuses.executing
|
248
|
+
operation_dbm.output_data = combine_dicts(
|
249
|
+
operation_dbm.output_data,
|
250
|
+
{
|
251
|
+
worker.worker_fullname: True
|
252
|
+
}
|
253
|
+
)
|
254
|
+
session.commit()
|
262
255
|
|
263
256
|
exception: BaseException | None = None
|
264
257
|
traceback_str: str | None = None
|
265
258
|
|
266
259
|
try:
|
267
|
-
await self.async_execute_operation(operation_dbm=operation_dbm)
|
260
|
+
await self.async_execute_operation(operation_dbm=operation_dbm, session=session)
|
268
261
|
except BaseException as exception_:
|
269
262
|
self._logger.error(
|
270
263
|
f"error in async_execute_operation (id={operation_dbm.id}, type={operation_dbm.type})",
|
@@ -273,40 +266,34 @@ class BaseOperationExecutor:
|
|
273
266
|
exception = exception_
|
274
267
|
traceback_str = traceback.format_exc()
|
275
268
|
|
276
|
-
|
269
|
+
operation_dbm.execution_finish_dt = now_utc_dt()
|
270
|
+
if exception:
|
271
|
+
operation_dbm.status = OperationDBM.Statuses.executed_with_error
|
272
|
+
operation_dbm.error_data = combine_dicts(
|
273
|
+
{
|
274
|
+
"exception_str": str(exception),
|
275
|
+
"traceback_str": traceback_str
|
276
|
+
},
|
277
|
+
operation_dbm.error_data
|
278
|
+
)
|
279
|
+
else:
|
280
|
+
operation_dbm.status = OperationDBM.Statuses.executed_without_error
|
281
|
+
session.commit()
|
277
282
|
|
278
|
-
|
279
|
-
|
283
|
+
if exception:
|
284
|
+
story_log_dbm = StoryLogDBM(
|
285
|
+
level=StoryLogDBM.Levels.error,
|
286
|
+
title=f"error in async_execute_operation (id={operation_dbm.id}, type={operation_dbm.type})",
|
287
|
+
data={
|
288
|
+
"operation_id": operation_dbm.id,
|
289
|
+
"exception_str": str(exception),
|
290
|
+
"traceback_str": traceback_str
|
291
|
+
}
|
280
292
|
)
|
281
|
-
|
282
|
-
if exception:
|
283
|
-
operation_dbm.status = OperationDBM.Statuses.executed_with_error
|
284
|
-
operation_dbm.error_data = combine_dicts(
|
285
|
-
{
|
286
|
-
"exception_str": str(exception),
|
287
|
-
"traceback_str": traceback_str
|
288
|
-
},
|
289
|
-
operation_dbm.error_data
|
290
|
-
)
|
291
|
-
else:
|
292
|
-
operation_dbm.status = OperationDBM.Statuses.executed_without_error
|
293
|
+
session.add(story_log_dbm)
|
293
294
|
session.commit()
|
294
295
|
|
295
|
-
|
296
|
-
story_log_dbm = StoryLogDBM(
|
297
|
-
level=StoryLogDBM.Levels.error,
|
298
|
-
title=f"error in async_execute_operation (id={operation_dbm.id}, type={operation_dbm.type})",
|
299
|
-
data={
|
300
|
-
"operation_id": operation_dbm.id,
|
301
|
-
"exception_str": str(exception),
|
302
|
-
"traceback_str": traceback_str
|
303
|
-
}
|
304
|
-
)
|
305
|
-
session.add(story_log_dbm)
|
306
|
-
session.commit()
|
307
|
-
session.refresh(story_log_dbm)
|
308
|
-
|
309
|
-
session.refresh(operation_dbm)
|
296
|
+
session.refresh(operation_dbm)
|
310
297
|
|
311
298
|
self._logger.info(
|
312
299
|
f"finish async_safe_execute_operation, "
|
@@ -365,18 +352,21 @@ class OperationExecutorWorker(BaseWorker):
|
|
365
352
|
self.sqlalchemy_db.init()
|
366
353
|
await self.async_run_startup_funcs()
|
367
354
|
|
368
|
-
async def async_execute_operation(self, operation_dbm: OperationDBM) -> OperationDBM:
|
369
|
-
return await self.operation_executor.async_safe_execute_operation(
|
355
|
+
async def async_execute_operation(self, operation_dbm: OperationDBM, session: Session) -> OperationDBM:
|
356
|
+
return await self.operation_executor.async_safe_execute_operation(
|
357
|
+
operation_dbm=operation_dbm, worker=self, session=session
|
358
|
+
)
|
370
359
|
|
371
360
|
async def async_run(self):
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
361
|
+
with self.sqlalchemy_db.new_session() as session:
|
362
|
+
operation_dbm: OperationDBM | None = get_operation_for_execution(
|
363
|
+
sqlalchemy_db=self.sqlalchemy_db,
|
364
|
+
filter_operation_types=self.filter_operation_types,
|
365
|
+
lock=True
|
366
|
+
)
|
367
|
+
if not operation_dbm:
|
368
|
+
return
|
369
|
+
await self.async_execute_operation(operation_dbm=operation_dbm, session=session)
|
380
370
|
|
381
371
|
async def async_run_on_error(self, exception: BaseException, **kwargs):
|
382
372
|
pass
|
@@ -96,6 +96,7 @@ arpakitlib/_arpakit_project_template/src/core/const.py,sha256=CZZew674y7LhCAlYhv
|
|
96
96
|
arpakitlib/_arpakit_project_template/src/core/settings.py,sha256=S1WPgnFWiRNjCXLllZHq6xp3AiyzzqnRBubg02iRkvo,2238
|
97
97
|
arpakitlib/_arpakit_project_template/src/core/util.py,sha256=5R8gvcZdvuDQes45FBnLC2IDv2Jhajp1VhJJYNKYjMQ,1539
|
98
98
|
arpakitlib/_arpakit_project_template/src/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
99
|
+
arpakitlib/_arpakit_project_template/src/db/const.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
99
100
|
arpakitlib/_arpakit_project_template/src/db/sqlalchemy_model.py,sha256=nXtayUkBaVb6tWx5qJgXZLbLOTVAjnSLpSDxBm7yZLc,234
|
100
101
|
arpakitlib/_arpakit_project_template/src/db/util.py,sha256=8Jg9TtTwvyxVYIN_W5_lk9y-Pyh8To1aMRFUKCRDuuA,550
|
101
102
|
arpakitlib/_arpakit_project_template/src/operation_execution/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -120,7 +121,7 @@ arpakitlib/ar_arpakit_project_template_util.py,sha256=AswzQvvb-zfUyrcP4EP0K756YL
|
|
120
121
|
arpakitlib/ar_arpakit_schedule_uust_api_client_util.py,sha256=jGbP6egs2yhgfheyqhM0J-SeM2qp2YrW7dV-u9djv4Q,19223
|
121
122
|
arpakitlib/ar_arpakitlib_cli_util.py,sha256=8lhEDxnwMSRX2PGV2xQtQru1AYKSA92SVolol5u7iBk,3154
|
122
123
|
arpakitlib/ar_base64_util.py,sha256=aZkg2cZTuAaP2IWeG_LXJ6RO7qhyskVwec-Lks0iM-k,676
|
123
|
-
arpakitlib/ar_base_worker_util.py,sha256=
|
124
|
+
arpakitlib/ar_base_worker_util.py,sha256=T53HIx1azgal4ZmBR1afXqQ3_zex35NIAYPHNchhxfs,5666
|
124
125
|
arpakitlib/ar_cache_file_util.py,sha256=Fo2pH-Zqm966KWFBHG_pbiySGZvhIFCYqy7k1weRfJ0,3476
|
125
126
|
arpakitlib/ar_datetime_util.py,sha256=Xe1NiT9oPQzNSG7RVRkhukhbg4i-hhS5ImmV7sPUc8o,971
|
126
127
|
arpakitlib/ar_dict_util.py,sha256=cF5LQJ6tLqyGoEXfDljMDZrikeZoWPw7CgINHIFGvXM,419
|
@@ -164,7 +165,7 @@ arpakitlib/ar_logging_util.py,sha256=mx3H6CzX9dsh29ruFmYnva8lL6mwvdBXmeHH9E2tvu8
|
|
164
165
|
arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk,4038
|
165
166
|
arpakitlib/ar_need_type_util.py,sha256=GETiREPMEYhch-yU6T--Bdawlbb04Jp1Qy7cOsUlIeA,2228
|
166
167
|
arpakitlib/ar_openai_api_client_util.py,sha256=_XmlApvHFMSyjvZydPa_kASIt9LsFrZmSC7YEzIG8Bg,1806
|
167
|
-
arpakitlib/ar_operation_execution_util.py,sha256=
|
168
|
+
arpakitlib/ar_operation_execution_util.py,sha256=bREu2IpBzbITEioS6SaL9bhvUPlYCuVgclTVEZCGx-Q,17696
|
168
169
|
arpakitlib/ar_parse_command.py,sha256=-s61xcATIsfw1eV_iD3xi-grsitbGzSDoAFc5V0OFy4,3447
|
169
170
|
arpakitlib/ar_postgresql_util.py,sha256=1AuLjEaa1Lg4pzn-ukCVnDi35Eg1k91APRTqZhIJAdo,945
|
170
171
|
arpakitlib/ar_run_cmd_util.py,sha256=D_rPavKMmWkQtwvZFz-Io5Ak8eSODHkcFeLPzNVC68g,1072
|
@@ -178,9 +179,9 @@ arpakitlib/ar_str_util.py,sha256=tFoGSDYoGpfdVHWor5Li9pEOFmDFlHkX-Z8iOy1LK7Y,353
|
|
178
179
|
arpakitlib/ar_type_util.py,sha256=s0NsTM7mV3HuwyRwyYLdNn7Ep2HbyI4FIr-dd8x0lfI,3734
|
179
180
|
arpakitlib/ar_yookassa_api_client_util.py,sha256=sh4fcUkAkdOetFn9JYoTvjcSXP-M1wU04KEY-ECLfLg,5137
|
180
181
|
arpakitlib/ar_zabbix_api_client_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
|
181
|
-
arpakitlib-1.7.
|
182
|
-
arpakitlib-1.7.
|
183
|
-
arpakitlib-1.7.
|
184
|
-
arpakitlib-1.7.
|
185
|
-
arpakitlib-1.7.
|
186
|
-
arpakitlib-1.7.
|
182
|
+
arpakitlib-1.7.97.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
183
|
+
arpakitlib-1.7.97.dist-info/METADATA,sha256=nf_HE_ed1KP5IJxPAZsDNsA_YysGS-qjT6wK5whA2rQ,2824
|
184
|
+
arpakitlib-1.7.97.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
|
185
|
+
arpakitlib-1.7.97.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
186
|
+
arpakitlib-1.7.97.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
|
187
|
+
arpakitlib-1.7.97.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|