ddeutil-workflow 0.0.64__py3-none-any.whl → 0.0.66__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 -1
- ddeutil/workflow/__main__.py +1 -27
- ddeutil/workflow/api/routes/job.py +2 -2
- ddeutil/workflow/cli.py +66 -0
- ddeutil/workflow/conf.py +1 -9
- ddeutil/workflow/{exceptions.py → errors.py} +46 -11
- ddeutil/workflow/job.py +247 -120
- ddeutil/workflow/logs.py +1 -1
- ddeutil/workflow/params.py +11 -11
- ddeutil/workflow/result.py +84 -10
- ddeutil/workflow/reusables.py +15 -17
- ddeutil/workflow/stages.py +685 -450
- ddeutil/workflow/utils.py +33 -0
- ddeutil/workflow/workflow.py +177 -664
- {ddeutil_workflow-0.0.64.dist-info → ddeutil_workflow-0.0.66.dist-info}/METADATA +15 -13
- ddeutil_workflow-0.0.66.dist-info/RECORD +29 -0
- {ddeutil_workflow-0.0.64.dist-info → ddeutil_workflow-0.0.66.dist-info}/WHEEL +1 -1
- ddeutil_workflow-0.0.64.dist-info/RECORD +0 -28
- {ddeutil_workflow-0.0.64.dist-info → ddeutil_workflow-0.0.66.dist-info}/entry_points.txt +0 -0
- {ddeutil_workflow-0.0.64.dist-info → ddeutil_workflow-0.0.66.dist-info}/licenses/LICENSE +0 -0
- {ddeutil_workflow-0.0.64.dist-info → ddeutil_workflow-0.0.66.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
|
|
@@ -313,3 +325,24 @@ def dump_all(
|
|
313
325
|
elif isinstance(value, BaseModel):
|
314
326
|
return value.model_dump(by_alias=by_alias)
|
315
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
|