ddeutil-workflow 0.0.64__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.
@@ -1 +1 @@
1
- __version__: str = "0.0.64"
1
+ __version__: str = "0.0.65"
@@ -6,8 +6,8 @@
6
6
  from .__cron import CronJob, CronRunner
7
7
  from .__types import DictData, DictStr, Matrix, Re, TupleStr
8
8
  from .conf import *
9
+ from .errors import *
9
10
  from .event import *
10
- from .exceptions import *
11
11
  from .job import *
12
12
  from .logs import (
13
13
  Audit,
@@ -12,7 +12,7 @@ from fastapi.responses import UJSONResponse
12
12
  from pydantic import BaseModel, Field
13
13
 
14
14
  from ...__types import DictData
15
- from ...exceptions import JobException
15
+ from ...errors import JobError
16
16
  from ...job import Job
17
17
  from ...logs import get_logger
18
18
  from ...result import Result
@@ -59,7 +59,7 @@ async def job_execute(
59
59
  ).context,
60
60
  to=context,
61
61
  )
62
- except JobException as err:
62
+ except JobError as err:
63
63
  rs.trace.error(f"[JOB]: {err.__class__.__name__}: {err}")
64
64
 
65
65
  return {
ddeutil/workflow/conf.py CHANGED
@@ -141,10 +141,6 @@ class Config: # pragma: no cov
141
141
  def log_datetime_format(self) -> str:
142
142
  return env("LOG_DATETIME_FORMAT", "%Y-%m-%d %H:%M:%S")
143
143
 
144
- @property
145
- def stage_raise_error(self) -> bool:
146
- return str2bool(env("CORE_STAGE_RAISE_ERROR", "false"))
147
-
148
144
  @property
149
145
  def stage_default_id(self) -> bool:
150
146
  return str2bool(env("CORE_STAGE_DEFAULT_ID", "false"))
@@ -11,6 +11,8 @@ from __future__ import annotations
11
11
 
12
12
  from typing import Literal, Optional, TypedDict, Union, overload
13
13
 
14
+ from .__types import DictData, StrOrInt
15
+
14
16
 
15
17
  class ErrorData(TypedDict):
16
18
  """Error data type dict for typing necessary keys of return of to_dict func
@@ -21,7 +23,7 @@ class ErrorData(TypedDict):
21
23
  message: str
22
24
 
23
25
 
24
- def to_dict(exception: Exception) -> ErrorData: # pragma: no cov
26
+ def to_dict(exception: Exception, **kwargs) -> ErrorData: # pragma: no cov
25
27
  """Create dict data from exception instance.
26
28
 
27
29
  :param exception: An exception object.
@@ -31,17 +33,27 @@ def to_dict(exception: Exception) -> ErrorData: # pragma: no cov
31
33
  return {
32
34
  "name": exception.__class__.__name__,
33
35
  "message": str(exception),
36
+ **kwargs,
34
37
  }
35
38
 
36
39
 
37
- class BaseWorkflowException(Exception):
40
+ class BaseError(Exception):
38
41
  """Base Workflow exception class will implement the `refs` argument for
39
42
  making an error context to the result context.
40
43
  """
41
44
 
42
- def __init__(self, message: str, *, refs: Optional[str] = None):
45
+ def __init__(
46
+ self,
47
+ message: str,
48
+ *,
49
+ refs: Optional[StrOrInt] = None,
50
+ context: Optional[DictData] = None,
51
+ params: Optional[DictData] = None,
52
+ ) -> None:
43
53
  super().__init__(message)
44
54
  self.refs: Optional[str] = refs
55
+ self.context: DictData = context or {}
56
+ self.params: DictData = params or {}
45
57
 
46
58
  @overload
47
59
  def to_dict(
@@ -54,7 +66,9 @@ class BaseWorkflowException(Exception):
54
66
  ) -> ErrorData: ... # pragma: no cov
55
67
 
56
68
  def to_dict(
57
- self, with_refs: bool = False
69
+ self,
70
+ with_refs: bool = False,
71
+ **kwargs,
58
72
  ) -> Union[ErrorData, dict[str, ErrorData]]:
59
73
  """Return ErrorData data from the current exception object. If with_refs
60
74
  flag was set, it will return mapping of refs and itself data.
@@ -64,22 +78,46 @@ class BaseWorkflowException(Exception):
64
78
  data: ErrorData = to_dict(self)
65
79
  if with_refs and (self.refs is not None and self.refs != "EMPTY"):
66
80
  return {self.refs: data}
67
- return data
81
+ return data | kwargs
82
+
83
+
84
+ class UtilError(BaseError): ...
85
+
86
+
87
+ class ResultError(UtilError): ...
88
+
89
+
90
+ class StageError(BaseError): ...
91
+
92
+
93
+ class StageRetryError(StageError): ...
94
+
95
+
96
+ class StageCancelError(StageError): ...
97
+
98
+
99
+ class StageSkipError(StageError): ...
100
+
101
+
102
+ class JobError(BaseError): ...
103
+
104
+
105
+ class JobCancelError(JobError): ...
68
106
 
69
107
 
70
- class UtilException(BaseWorkflowException): ...
108
+ class JobSkipError(JobError): ...
71
109
 
72
110
 
73
- class ResultException(UtilException): ...
111
+ class WorkflowError(BaseError): ...
74
112
 
75
113
 
76
- class StageException(BaseWorkflowException): ...
114
+ class WorkflowCancelError(WorkflowError): ...
77
115
 
78
116
 
79
- class JobException(BaseWorkflowException): ...
117
+ class WorkflowSkipError(WorkflowError): ...
80
118
 
81
119
 
82
- class WorkflowException(BaseWorkflowException): ...
120
+ class WorkflowTimeoutError(WorkflowError): ...
83
121
 
84
122
 
85
- class ParamValueException(WorkflowException): ...
123
+ class ParamError(WorkflowError): ...