5
5
6
6
import dbt .exceptions
7
7
from dbt_rpc .contracts .rpc import (
8
+ PollListResult ,
9
+ RemoteListResults ,
8
10
TaskTags ,
9
11
StatusParameters ,
10
12
ReloadParameters ,
@@ -54,7 +56,7 @@ def set_args(self, params: GCParameters):
54
56
55
57
def handle_request (self ) -> GCResult :
56
58
if self .params is None :
57
- raise dbt .exceptions .InternalException ("GC: params not set" )
59
+ raise dbt .exceptions .DbtInternalError ("GC: params not set" )
58
60
return self .task_manager .gc_safe (
59
61
task_ids = self .params .task_ids ,
60
62
before = self .params .before ,
@@ -70,7 +72,7 @@ def set_args(self, params: KillParameters):
70
72
71
73
def handle_request (self ) -> KillResult :
72
74
if self .params is None :
73
- raise dbt .exceptions .InternalException ("Kill: params not set" )
75
+ raise dbt .exceptions .DbtInternalError ("Kill: params not set" )
74
76
result = KillResult ()
75
77
task : RequestTaskHandler
76
78
try :
@@ -117,7 +119,7 @@ def set_args(self, params: PSParameters):
117
119
118
120
def keep (self , row : TaskRow ):
119
121
if self .params is None :
120
- raise dbt .exceptions .InternalException ("PS: params not set" )
122
+ raise dbt .exceptions .DbtInternalError ("PS: params not set" )
121
123
if row .state .finished and self .params .completed :
122
124
return True
123
125
elif not row .state .finished and self .params .active :
@@ -136,7 +138,7 @@ def poll_complete(
136
138
timing : TaskTiming , result : Any , tags : TaskTags , logs : List [LogMessage ]
137
139
) -> PollResult :
138
140
if timing .state not in (TaskHandlerState .Success , TaskHandlerState .Failed ):
139
- raise dbt .exceptions .InternalException (
141
+ raise dbt .exceptions .DbtInternalError (
140
142
f"got invalid result state in poll_complete: { timing .state } "
141
143
)
142
144
@@ -150,6 +152,7 @@ def poll_complete(
150
152
PollRunOperationCompleteResult ,
151
153
PollGetManifestResult ,
152
154
PollFreshnessResult ,
155
+ PollListResult ,
153
156
]
154
157
]
155
158
@@ -170,8 +173,10 @@ def poll_complete(
170
173
cls = PollGetManifestResult
171
174
elif isinstance (result , RemoteFreshnessResult ):
172
175
cls = PollFreshnessResult
176
+ elif isinstance (result , RemoteListResults ):
177
+ cls = PollListResult
173
178
else :
174
- raise dbt .exceptions .InternalException (
179
+ raise dbt .exceptions .DbtInternalError (
175
180
"got invalid result in poll_complete: {}" .format (result )
176
181
)
177
182
return cls .from_result (result , tags , timing , logs )
@@ -189,7 +194,7 @@ def set_args(self, params: PollParameters):
189
194
190
195
def handle_request (self ) -> PollResult :
191
196
if self .params is None :
192
- raise dbt .exceptions .InternalException ("Poll: params not set" )
197
+ raise dbt .exceptions .DbtInternalError ("Poll: params not set" )
193
198
task_id = self .params .request_token
194
199
task : RequestTaskHandler = self .task_manager .get_request (task_id )
195
200
@@ -216,7 +221,7 @@ def handle_request(self) -> PollResult:
216
221
elif state == TaskHandlerState .Error :
217
222
err = task .error
218
223
if err is None :
219
- exc = dbt .exceptions .InternalException (
224
+ exc = dbt .exceptions .DbtInternalError (
220
225
f"At end of task { task_id } , error state but error is None"
221
226
)
222
227
raise RPCException .from_error (
@@ -227,7 +232,7 @@ def handle_request(self) -> PollResult:
227
232
raise err
228
233
elif state in (TaskHandlerState .Success , TaskHandlerState .Failed ):
229
234
if task .result is None :
230
- exc = dbt .exceptions .InternalException (
235
+ exc = dbt .exceptions .DbtInternalError (
231
236
f"At end of task { task_id } , state={ state } but result is " "None"
232
237
)
233
238
raise RPCException .from_error (
@@ -246,7 +251,7 @@ def handle_request(self) -> PollResult:
246
251
elapsed = timing .elapsed ,
247
252
)
248
253
else :
249
- exc = dbt .exceptions .InternalException (
254
+ exc = dbt .exceptions .DbtInternalError (
250
255
f"Got unknown value state={ state } for task { task_id } "
251
256
)
252
257
raise RPCException .from_error (dbt_error (exc , logs = _dict_logs (task_logs )))
0 commit comments