ddeutil-workflow 0.0.63__py3-none-any.whl → 0.0.65__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.
- ddeutil/workflow/__about__.py +1 -1
- ddeutil/workflow/__init__.py +1 -8
- ddeutil/workflow/api/__init__.py +5 -84
- ddeutil/workflow/api/routes/__init__.py +0 -1
- ddeutil/workflow/api/routes/job.py +2 -3
- ddeutil/workflow/api/routes/logs.py +0 -2
- ddeutil/workflow/api/routes/workflows.py +0 -3
- ddeutil/workflow/conf.py +6 -38
- ddeutil/workflow/{exceptions.py → errors.py} +47 -12
- ddeutil/workflow/job.py +249 -118
- ddeutil/workflow/params.py +11 -11
- ddeutil/workflow/result.py +86 -10
- ddeutil/workflow/reusables.py +54 -23
- ddeutil/workflow/stages.py +692 -464
- ddeutil/workflow/utils.py +37 -2
- ddeutil/workflow/workflow.py +163 -664
- {ddeutil_workflow-0.0.63.dist-info → ddeutil_workflow-0.0.65.dist-info}/METADATA +17 -67
- ddeutil_workflow-0.0.65.dist-info/RECORD +28 -0
- {ddeutil_workflow-0.0.63.dist-info → ddeutil_workflow-0.0.65.dist-info}/WHEEL +1 -1
- ddeutil/workflow/api/routes/schedules.py +0 -141
- ddeutil/workflow/api/utils.py +0 -174
- ddeutil/workflow/scheduler.py +0 -813
- ddeutil_workflow-0.0.63.dist-info/RECORD +0 -31
- {ddeutil_workflow-0.0.63.dist-info → ddeutil_workflow-0.0.65.dist-info}/entry_points.txt +0 -0
- {ddeutil_workflow-0.0.63.dist-info → ddeutil_workflow-0.0.65.dist-info}/licenses/LICENSE +0 -0
- {ddeutil_workflow-0.0.63.dist-info → ddeutil_workflow-0.0.65.dist-info}/top_level.txt +0 -0
ddeutil/workflow/utils.py
CHANGED
@@ -6,10 +6,12 @@
|
|
6
6
|
"""Utility function model."""
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
|
+
import asyncio
|
9
10
|
import stat
|
10
11
|
import time
|
11
12
|
from collections.abc import Iterator
|
12
13
|
from datetime import date, datetime, timedelta
|
14
|
+
from functools import wraps
|
13
15
|
from hashlib import md5
|
14
16
|
from inspect import isfunction
|
15
17
|
from itertools import chain, islice, product
|
@@ -28,6 +30,16 @@ UTC: Final[ZoneInfo] = ZoneInfo("UTC")
|
|
28
30
|
MARK_NEWLINE: Final[str] = "||"
|
29
31
|
|
30
32
|
|
33
|
+
def to_train(camel: str) -> str:
|
34
|
+
"""Convert camel case string to train case.
|
35
|
+
|
36
|
+
:param camel: (str) A camel case string that want to convert.
|
37
|
+
|
38
|
+
:rtype: str
|
39
|
+
"""
|
40
|
+
return "".join("-" + i if i.isupper() else i for i in camel).lstrip("-")
|
41
|
+
|
42
|
+
|
31
43
|
def prepare_newline(msg: str) -> str:
|
32
44
|
"""Prepare message that has multiple newline char.
|
33
45
|
|
@@ -293,11 +305,13 @@ def cut_id(run_id: str, *, num: int = 6) -> str:
|
|
293
305
|
|
294
306
|
|
295
307
|
@overload
|
296
|
-
def dump_all(
|
308
|
+
def dump_all(
|
309
|
+
value: BaseModel, by_alias: bool = False
|
310
|
+
) -> DictData: ... # pragma: no cov
|
297
311
|
|
298
312
|
|
299
313
|
@overload
|
300
|
-
def dump_all(value: T, by_alias: bool = False) -> T: ...
|
314
|
+
def dump_all(value: T, by_alias: bool = False) -> T: ... # pragma: no cov
|
301
315
|
|
302
316
|
|
303
317
|
def dump_all(
|
@@ -311,3 +325,24 @@ def dump_all(
|
|
311
325
|
elif isinstance(value, BaseModel):
|
312
326
|
return value.model_dump(by_alias=by_alias)
|
313
327
|
return value
|
328
|
+
|
329
|
+
|
330
|
+
def awaitable(func):
|
331
|
+
"""Dynamic function to async or not depend on the called statement."""
|
332
|
+
|
333
|
+
@wraps(func)
|
334
|
+
async def async_wrapper(*args, **kwargs):
|
335
|
+
return func(*args, **kwargs)
|
336
|
+
|
337
|
+
@wraps(func)
|
338
|
+
def sync_wrapper(*args, **kwargs):
|
339
|
+
return func(*args, **kwargs)
|
340
|
+
|
341
|
+
def dispatch(*args, **kwargs):
|
342
|
+
try:
|
343
|
+
asyncio.get_running_loop()
|
344
|
+
return async_wrapper(*args, **kwargs)
|
345
|
+
except RuntimeError:
|
346
|
+
return sync_wrapper(*args, **kwargs)
|
347
|
+
|
348
|
+
return dispatch
|