changhe batch
This commit is contained in:
@@ -2,8 +2,9 @@ import inspect
|
||||
import logging
|
||||
import os
|
||||
from contextlib import AbstractContextManager
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import Any, Callable, NamedTuple, Self, Sequence
|
||||
from typing import Any, Callable, Self, Sequence
|
||||
|
||||
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO').upper()
|
||||
|
||||
@@ -18,7 +19,8 @@ class Status(Enum):
|
||||
FAIL = 'fail'
|
||||
|
||||
|
||||
class Result(NamedTuple):
|
||||
@dataclass(frozen=True)
|
||||
class Result:
|
||||
status: Status
|
||||
input_record: Any
|
||||
output: Any | None = None
|
||||
@@ -129,5 +131,8 @@ class BatchProcessor(AbstractContextManager):
|
||||
return Result(
|
||||
status=Status.FAIL,
|
||||
input_record=record,
|
||||
cause=exc,
|
||||
cause={
|
||||
'type': type(exc).__name__,
|
||||
'message': str(exc),
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user