ddeutil-workflow 0.0.7__py3-none-any.whl → 0.0.8__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/app.py +4 -0
- ddeutil/workflow/exceptions.py +1 -4
- ddeutil/workflow/log.py +49 -0
- ddeutil/workflow/pipeline.py +327 -167
- ddeutil/workflow/stage.py +191 -97
- ddeutil/workflow/utils.py +94 -16
- {ddeutil_workflow-0.0.7.dist-info → ddeutil_workflow-0.0.8.dist-info}/METADATA +17 -92
- ddeutil_workflow-0.0.8.dist-info/RECORD +20 -0
- ddeutil_workflow-0.0.7.dist-info/RECORD +0 -20
- {ddeutil_workflow-0.0.7.dist-info → ddeutil_workflow-0.0.8.dist-info}/LICENSE +0 -0
- {ddeutil_workflow-0.0.7.dist-info → ddeutil_workflow-0.0.8.dist-info}/WHEEL +0 -0
- {ddeutil_workflow-0.0.7.dist-info → ddeutil_workflow-0.0.8.dist-info}/top_level.txt +0 -0
ddeutil/workflow/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__: str = "0.0.
|
1
|
+
__version__: str = "0.0.8"
|
ddeutil/workflow/app.py
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# Licensed under the MIT License. See LICENSE in the project root for
|
4
4
|
# license information.
|
5
5
|
# ------------------------------------------------------------------------------
|
6
|
+
from __future__ import annotations
|
7
|
+
|
6
8
|
import functools
|
7
9
|
import time
|
8
10
|
|
@@ -10,6 +12,8 @@ import schedule
|
|
10
12
|
|
11
13
|
|
12
14
|
def catch_exceptions(cancel_on_failure=False):
|
15
|
+
"""Catch exception error from scheduler job."""
|
16
|
+
|
13
17
|
def catch_exceptions_decorator(job_func):
|
14
18
|
@functools.wraps(job_func)
|
15
19
|
def wrapper(*args, **kwargs):
|
ddeutil/workflow/exceptions.py
CHANGED
@@ -3,9 +3,6 @@
|
|
3
3
|
# Licensed under the MIT License. See LICENSE in the project root for
|
4
4
|
# license information.
|
5
5
|
# ------------------------------------------------------------------------------
|
6
|
-
"""
|
7
|
-
Define Errors Object for Node package
|
8
|
-
"""
|
9
6
|
from __future__ import annotations
|
10
7
|
|
11
8
|
|
@@ -24,4 +21,4 @@ class JobException(WorkflowException): ...
|
|
24
21
|
class PipelineException(WorkflowException): ...
|
25
22
|
|
26
23
|
|
27
|
-
class ParamValueException(
|
24
|
+
class ParamValueException(WorkflowException): ...
|
ddeutil/workflow/log.py
CHANGED
@@ -6,11 +6,16 @@
|
|
6
6
|
from __future__ import annotations
|
7
7
|
|
8
8
|
import logging
|
9
|
+
from datetime import datetime
|
9
10
|
from functools import lru_cache
|
11
|
+
from typing import Union
|
10
12
|
|
13
|
+
from pydantic import BaseModel, Field
|
11
14
|
from rich.console import Console
|
12
15
|
from rich.logging import RichHandler
|
13
16
|
|
17
|
+
from .__types import DictData
|
18
|
+
|
14
19
|
console = Console(color_system="256", width=200, style="blue")
|
15
20
|
|
16
21
|
|
@@ -28,3 +33,47 @@ def get_logger(module_name):
|
|
28
33
|
logger.addHandler(handler)
|
29
34
|
logger.setLevel(logging.DEBUG)
|
30
35
|
return logger
|
36
|
+
|
37
|
+
|
38
|
+
class BaseLog(BaseModel):
|
39
|
+
"""Base logging model."""
|
40
|
+
|
41
|
+
parent_id: str
|
42
|
+
id: str
|
43
|
+
input: DictData
|
44
|
+
output: DictData
|
45
|
+
update_time: datetime = Field(default_factory=datetime.now)
|
46
|
+
|
47
|
+
|
48
|
+
class StageLog(BaseLog): ...
|
49
|
+
|
50
|
+
|
51
|
+
class JobLog(BaseLog): ...
|
52
|
+
|
53
|
+
|
54
|
+
class PipelineLog(BaseLog): ...
|
55
|
+
|
56
|
+
|
57
|
+
Log = Union[
|
58
|
+
StageLog,
|
59
|
+
JobLog,
|
60
|
+
PipelineLog,
|
61
|
+
]
|
62
|
+
|
63
|
+
|
64
|
+
def push_log_memory(log: DictData):
|
65
|
+
"""Push message log to globals log queue."""
|
66
|
+
print(log)
|
67
|
+
|
68
|
+
|
69
|
+
LOGS_REGISTRY = {
|
70
|
+
"memory": push_log_memory,
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
def push_log(log: DictData, mode: str = "memory"):
|
75
|
+
return LOGS_REGISTRY[mode](log)
|
76
|
+
|
77
|
+
|
78
|
+
def save_log():
|
79
|
+
"""Save log that push to queue to target saving"""
|