File size: 1,935 Bytes
af3797c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from ray.util.annotations import PublicAPI
from ray.workflow.common import TaskID


@PublicAPI(stability="alpha")
class WorkflowError(Exception):
    """Workflow error base class."""


@PublicAPI(stability="alpha")
class WorkflowExecutionError(WorkflowError):
    def __init__(self, workflow_id: str):
        self.message = f"Workflow[id={workflow_id}] failed during execution."
        super().__init__(self.message)


@PublicAPI(stability="alpha")
class WorkflowCancellationError(WorkflowError):
    def __init__(self, workflow_id: str):
        self.message = f"Workflow[id={workflow_id}] is cancelled during execution."
        super().__init__(self.message)


@PublicAPI(stability="alpha")
class WorkflowNotResumableError(WorkflowError):
    """Raise the exception when we cannot resume from a workflow."""

    def __init__(self, workflow_id: str):
        self.message = f"Workflow[id={workflow_id}] is not resumable."
        super().__init__(self.message)


@PublicAPI(stability="alpha")
class WorkflowTaskNotRecoverableError(WorkflowNotResumableError):
    """Raise the exception when we find a workflow task cannot be recovered
    using the checkpointed inputs."""

    def __init__(self, task_id: TaskID):
        self.message = f"Workflow task[id={task_id}] is not recoverable"
        super(WorkflowError, self).__init__(self.message)


@PublicAPI(stability="alpha")
class WorkflowNotFoundError(WorkflowError):
    def __init__(self, workflow_id: str):
        self.message = f"Workflow[id={workflow_id}] was referenced but doesn't exist."
        super().__init__(self.message)


@PublicAPI(stability="alpha")
class WorkflowStillActiveError(WorkflowError):
    def __init__(self, operation: str, workflow_id: str):
        self.message = (
            f"{operation} couldn't be completed because "
            f"Workflow[id={workflow_id}] is still running or pending."
        )
        super().__init__(self.message)