This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
transition_info.go
184 lines (149 loc) · 3.87 KB
/
transition_info.go
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package handler
import (
"time"
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core"
"github.com/lyft/flytestdlib/storage"
)
type EPhase uint8
const (
EPhaseUndefined EPhase = iota
EPhaseNotReady
EPhaseQueued
EPhaseRunning
EPhaseSkip
EPhaseFailed
EPhaseRetryableFailure
EPhaseSuccess
EPhaseTimedout
)
func (p EPhase) String() string {
switch p {
case EPhaseNotReady:
return "not-ready"
case EPhaseQueued:
return "queued"
case EPhaseRunning:
return "running"
case EPhaseSkip:
return "skip"
case EPhaseFailed:
return "failed"
case EPhaseRetryableFailure:
return "retryable-fail"
case EPhaseSuccess:
return "success"
case EPhaseTimedout:
return "timedout"
}
return "undefined"
}
func (p EPhase) IsTerminal() bool {
if p == EPhaseFailed || p == EPhaseSuccess || p == EPhaseSkip || p == EPhaseTimedout {
return true
}
return false
}
type DynamicNodeInfo struct {
}
type WorkflowNodeInfo struct {
LaunchedWorkflowID *core.WorkflowExecutionIdentifier
}
type BranchNodeInfo struct {
}
type TaskNodeInfo struct {
CacheHit bool
// TaskPhase etc
}
type OutputInfo struct {
OutputURI storage.DataReference
}
type ExecutionInfo struct {
DynamicNodeInfo *DynamicNodeInfo
WorkflowNodeInfo *WorkflowNodeInfo
BranchNodeInfo *BranchNodeInfo
OutputInfo *OutputInfo
TaskNodeInfo *TaskNodeInfo
}
type PhaseInfo struct {
p EPhase
occurredAt time.Time
err *core.ExecutionError
info *ExecutionInfo
reason string
}
func (p PhaseInfo) GetPhase() EPhase {
return p.p
}
func (p PhaseInfo) GetOccurredAt() time.Time {
return p.occurredAt
}
func (p PhaseInfo) GetErr() *core.ExecutionError {
return p.err
}
func (p PhaseInfo) GetInfo() *ExecutionInfo {
return p.info
}
func (p PhaseInfo) GetReason() string {
return p.reason
}
func (p *PhaseInfo) SetOcurredAt(t time.Time) {
p.occurredAt = t
}
func (p *PhaseInfo) SetErr(err *core.ExecutionError) {
p.err = err
}
func (p *PhaseInfo) SetInfo(info *ExecutionInfo) {
p.info = info
}
func (p *PhaseInfo) SetReason() string {
return p.reason
}
var PhaseInfoUndefined = PhaseInfo{p: EPhaseUndefined}
func phaseInfo(p EPhase, err *core.ExecutionError, info *ExecutionInfo, reason string) PhaseInfo {
return PhaseInfo{
p: p,
err: err,
occurredAt: time.Now(),
info: info,
reason: reason,
}
}
func PhaseInfoNotReady(reason string) PhaseInfo {
return phaseInfo(EPhaseNotReady, nil, nil, reason)
}
func PhaseInfoQueued(reason string) PhaseInfo {
return phaseInfo(EPhaseQueued, nil, nil, reason)
}
func PhaseInfoRunning(info *ExecutionInfo) PhaseInfo {
return phaseInfo(EPhaseRunning, nil, info, "running")
}
func PhaseInfoSuccess(info *ExecutionInfo) PhaseInfo {
return phaseInfo(EPhaseSuccess, nil, info, "successfully completed")
}
func PhaseInfoSkip(info *ExecutionInfo, reason string) PhaseInfo {
return phaseInfo(EPhaseSkip, nil, info, reason)
}
func PhaseInfoTimedOut(info *ExecutionInfo, reason string) PhaseInfo {
return phaseInfo(EPhaseTimedout, nil, info, reason)
}
func phaseInfoFailed(p EPhase, err *core.ExecutionError, info *ExecutionInfo) PhaseInfo {
if err == nil {
err = &core.ExecutionError{
Code: "Unknown",
Message: "Unknown error message",
}
}
return phaseInfo(p, err, info, "")
}
func PhaseInfoFailure(code, reason string, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseFailed, &core.ExecutionError{Code: code, Message: reason}, info)
}
func PhaseInfoFailureErr(err *core.ExecutionError, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseFailed, err, info)
}
func PhaseInfoRetryableFailure(code, reason string, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseRetryableFailure, &core.ExecutionError{Code: code, Message: reason}, info)
}
func PhaseInfoRetryableFailureErr(err *core.ExecutionError, info *ExecutionInfo) PhaseInfo {
return phaseInfoFailed(EPhaseRetryableFailure, err, info)
}