Skip to content

Commit fc0901e

Browse files
committed
🎨 format: refactor process on job module.
1 parent d5a8e7c commit fc0901e

7 files changed

Lines changed: 177 additions & 150 deletions

File tree

src/ddeutil/workflow/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@
107107
Rule,
108108
RunsOnModel,
109109
Strategy,
110-
docker_execution,
111-
local_execute,
112-
local_execute_strategy,
113-
self_hosted_execute,
110+
docker_process,
111+
local_process,
112+
local_process_strategy,
113+
self_hosted_process,
114114
)
115115
from .params import (
116116
ArrayParam,

src/ddeutil/workflow/errors.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@
88
This module provides a comprehensive exception hierarchy for the workflow system.
99
The exceptions are designed to be lightweight while providing sufficient context
1010
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
2211
"""
2312
from __future__ import annotations
2413

@@ -58,11 +47,13 @@ def to_dict(exception: Exception, **kwargs) -> ErrorData: # pragma: no cov
5847
Example:
5948
>>> try:
6049
>>> raise ValueError("Something went wrong")
61-
>>> except Exception as e:
62-
>>> error_data = to_dict(e, context="workflow_execution")
63-
>>> # Returns: {
64-
>>> # "name": "ValueError", "message": "Something went wrong", "context": "workflow_execution"
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+
}
6657
"""
6758
return {
6859
"name": exception.__class__.__name__,
@@ -71,6 +62,20 @@ def to_dict(exception: Exception, **kwargs) -> ErrorData: # pragma: no cov
7162
}
7263

7364

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+
7479
class BaseError(Exception):
7580
"""Base exception class for all workflow-related errors.
7681

0 commit comments

Comments
 (0)