ddeutil-workflow 0.0.84__py3-none-any.whl → 0.0.85__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 +4 -4
- ddeutil/workflow/audits.py +8 -6
- ddeutil/workflow/conf.py +4 -17
- ddeutil/workflow/errors.py +31 -19
- ddeutil/workflow/job.py +276 -156
- ddeutil/workflow/plugins/providers/az.py +2 -2
- ddeutil/workflow/stages.py +404 -314
- ddeutil/workflow/traces.py +125 -185
- ddeutil/workflow/workflow.py +4 -1
- {ddeutil_workflow-0.0.84.dist-info → ddeutil_workflow-0.0.85.dist-info}/METADATA +13 -16
- {ddeutil_workflow-0.0.84.dist-info → ddeutil_workflow-0.0.85.dist-info}/RECORD +16 -16
- {ddeutil_workflow-0.0.84.dist-info → ddeutil_workflow-0.0.85.dist-info}/WHEEL +0 -0
- {ddeutil_workflow-0.0.84.dist-info → ddeutil_workflow-0.0.85.dist-info}/entry_points.txt +0 -0
- {ddeutil_workflow-0.0.84.dist-info → ddeutil_workflow-0.0.85.dist-info}/licenses/LICENSE +0 -0
- {ddeutil_workflow-0.0.84.dist-info → ddeutil_workflow-0.0.85.dist-info}/top_level.txt +0 -0
ddeutil/workflow/__about__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__: str = "0.0.
|
1
|
+
__version__: str = "0.0.85"
|
2
2
|
__python_version__: str = "3.9"
|
ddeutil/workflow/__init__.py
CHANGED
@@ -107,10 +107,10 @@ from .job import (
|
|
107
107
|
Rule,
|
108
108
|
RunsOnModel,
|
109
109
|
Strategy,
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
docker_process,
|
111
|
+
local_process,
|
112
|
+
local_process_strategy,
|
113
|
+
self_hosted_process,
|
114
114
|
)
|
115
115
|
from .params import (
|
116
116
|
ArrayParam,
|
ddeutil/workflow/audits.py
CHANGED
@@ -60,7 +60,7 @@ from typing_extensions import Self
|
|
60
60
|
|
61
61
|
from .__types import DictData
|
62
62
|
from .conf import dynamic
|
63
|
-
from .traces import Trace, get_trace
|
63
|
+
from .traces import Trace, get_trace
|
64
64
|
|
65
65
|
logger = logging.getLogger("ddeutil.workflow")
|
66
66
|
|
@@ -129,7 +129,6 @@ class BaseAudit(BaseModel, ABC):
|
|
129
129
|
"""
|
130
130
|
|
131
131
|
type: Literal["base"] = "base"
|
132
|
-
logging_name: str = "ddeutil.workflow"
|
133
132
|
extras: DictData = Field(
|
134
133
|
default_factory=dict,
|
135
134
|
description="An extras parameter that want to override core config",
|
@@ -152,9 +151,6 @@ class BaseAudit(BaseModel, ABC):
|
|
152
151
|
"""
|
153
152
|
if dynamic("enable_write_audit", extras=self.extras):
|
154
153
|
self.do_before()
|
155
|
-
|
156
|
-
# NOTE: Start setting log config in this line with cache.
|
157
|
-
set_logging(self.logging_name)
|
158
154
|
return self
|
159
155
|
|
160
156
|
@abstractmethod
|
@@ -795,7 +791,13 @@ Audit = Annotated[
|
|
795
791
|
LocalFileAudit,
|
796
792
|
LocalSQLiteAudit,
|
797
793
|
],
|
798
|
-
Field(
|
794
|
+
Field(
|
795
|
+
discriminator="type",
|
796
|
+
description=(
|
797
|
+
"An union of supported Audit model that have inherited from "
|
798
|
+
"BaseAudit."
|
799
|
+
),
|
800
|
+
),
|
799
801
|
]
|
800
802
|
|
801
803
|
|
ddeutil/workflow/conf.py
CHANGED
@@ -101,7 +101,8 @@ class Config: # pragma: no cov
|
|
101
101
|
"""Register Filter that is a list of importable string for the filter
|
102
102
|
template.
|
103
103
|
|
104
|
-
:
|
104
|
+
Returns:
|
105
|
+
list[str]: A list of module import string.
|
105
106
|
"""
|
106
107
|
regis_filter_str: str = env(
|
107
108
|
"CORE_REGISTRY_FILTER", "ddeutil.workflow.templates"
|
@@ -130,17 +131,6 @@ class Config: # pragma: no cov
|
|
130
131
|
"""
|
131
132
|
return ZoneInfo(env("LOG_TIMEZONE", "UTC"))
|
132
133
|
|
133
|
-
@property
|
134
|
-
def log_format(self) -> str:
|
135
|
-
return env(
|
136
|
-
"LOG_FORMAT",
|
137
|
-
(
|
138
|
-
"%(asctime)s.%(msecs)03d (%(process)-5d, "
|
139
|
-
"%(thread)-5d) [%(levelname)-7s] (%(cut_id)s) %(message)-120s "
|
140
|
-
"(%(filename)s:%(lineno)s) (%(name)-10s)"
|
141
|
-
),
|
142
|
-
)
|
143
|
-
|
144
134
|
@property
|
145
135
|
def audit_conf(self) -> dict[str, Any]:
|
146
136
|
return json.loads(
|
@@ -151,10 +141,6 @@ class Config: # pragma: no cov
|
|
151
141
|
def enable_write_audit(self) -> bool:
|
152
142
|
return str2bool(env("LOG_AUDIT_ENABLE_WRITE", "false"))
|
153
143
|
|
154
|
-
@property
|
155
|
-
def log_datetime_format(self) -> str:
|
156
|
-
return env("LOG_DATETIME_FORMAT", "%Y-%m-%d %H:%M:%S")
|
157
|
-
|
158
144
|
@property
|
159
145
|
def stage_default_id(self) -> bool:
|
160
146
|
return str2bool(env("CORE_STAGE_DEFAULT_ID", "false"))
|
@@ -441,7 +427,8 @@ class YamlParser:
|
|
441
427
|
"""Return object of string type which implement on any registry. The
|
442
428
|
object type.
|
443
429
|
|
444
|
-
:
|
430
|
+
Returns:
|
431
|
+
str: A type that get from config data.
|
445
432
|
"""
|
446
433
|
if _typ := self.data.get("type"):
|
447
434
|
return _typ
|
ddeutil/workflow/errors.py
CHANGED
@@ -8,17 +8,6 @@
|
|
8
8
|
This module provides a comprehensive exception hierarchy for the workflow system.
|
9
9
|
The exceptions are designed to be lightweight while providing sufficient context
|
10
10
|
for error handling and debugging.
|
11
|
-
|
12
|
-
Classes:
|
13
|
-
BaseError: Base exception class with context support
|
14
|
-
StageError: Exceptions related to stage execution
|
15
|
-
JobError: Exceptions related to job execution
|
16
|
-
WorkflowError: Exceptions related to workflow execution
|
17
|
-
ParamError: Exceptions related to parameter validation
|
18
|
-
ResultError: Exceptions related to result processing
|
19
|
-
|
20
|
-
Functions:
|
21
|
-
to_dict: Convert exception instances to dictionary format
|
22
11
|
"""
|
23
12
|
from __future__ import annotations
|
24
13
|
|
@@ -58,11 +47,13 @@ def to_dict(exception: Exception, **kwargs) -> ErrorData: # pragma: no cov
|
|
58
47
|
Example:
|
59
48
|
>>> try:
|
60
49
|
>>> raise ValueError("Something went wrong")
|
61
|
-
>>> except Exception as
|
62
|
-
>>> error_data = to_dict(
|
63
|
-
|
64
|
-
|
65
|
-
|
50
|
+
>>> except Exception as err:
|
51
|
+
>>> error_data = to_dict(err, context="workflow_execution")
|
52
|
+
{
|
53
|
+
"name": "ValueError",
|
54
|
+
"message": "Something went wrong",
|
55
|
+
"context": "workflow_execution",
|
56
|
+
}
|
66
57
|
"""
|
67
58
|
return {
|
68
59
|
"name": exception.__class__.__name__,
|
@@ -71,6 +62,20 @@ def to_dict(exception: Exception, **kwargs) -> ErrorData: # pragma: no cov
|
|
71
62
|
}
|
72
63
|
|
73
64
|
|
65
|
+
def mark_errors(context: DictData, error: JobError) -> None:
|
66
|
+
"""Make the errors context result with the refs value depends on the nested
|
67
|
+
execute func.
|
68
|
+
|
69
|
+
Args:
|
70
|
+
context (DictData): A context data.
|
71
|
+
error (JobError): A stage exception object.
|
72
|
+
"""
|
73
|
+
if "errors" in context:
|
74
|
+
context["errors"][error.refs] = error.to_dict()
|
75
|
+
else:
|
76
|
+
context["errors"] = error.to_dict(with_refs=True)
|
77
|
+
|
78
|
+
|
74
79
|
class BaseError(Exception):
|
75
80
|
"""Base exception class for all workflow-related errors.
|
76
81
|
|
@@ -80,9 +85,14 @@ class BaseError(Exception):
|
|
80
85
|
for debugging purposes.
|
81
86
|
|
82
87
|
Attributes:
|
83
|
-
refs: Optional reference identifier for error
|
84
|
-
|
85
|
-
|
88
|
+
refs (str | int, default None): Optional reference identifier for error
|
89
|
+
correlation
|
90
|
+
context (DictData, default None): Additional context data related to the
|
91
|
+
error
|
92
|
+
params (DictData, default None): Parameter data that was being processed
|
93
|
+
when error occurred
|
94
|
+
allow_traceback (bool, default True): A flag for printing traceback
|
95
|
+
after it catch this object.
|
86
96
|
|
87
97
|
Example:
|
88
98
|
>>> try:
|
@@ -100,11 +110,13 @@ class BaseError(Exception):
|
|
100
110
|
refs: Optional[StrOrInt] = None,
|
101
111
|
context: Optional[DictData] = None,
|
102
112
|
params: Optional[DictData] = None,
|
113
|
+
allow_traceback: bool = True,
|
103
114
|
) -> None:
|
104
115
|
super().__init__(message)
|
105
116
|
self.refs: Optional[str] = refs
|
106
117
|
self.context: DictData = context or {}
|
107
118
|
self.params: DictData = params or {}
|
119
|
+
self.allow_traceback: bool = allow_traceback
|
108
120
|
|
109
121
|
@overload
|
110
122
|
def to_dict(
|