@@ -67,11 +67,11 @@ def wrapper(self, *args, **kwargs):
67
67
return decorator
68
68
69
69
70
- class MissingModelDeploymentIdError (Exception ): # pragma: no cover
70
+ class MissingModelDeploymentIdError (Exception ): # pragma: no cover
71
71
pass
72
72
73
73
74
- class MissingModelDeploymentWorkflowIdError (Exception ): # pragma: no cover
74
+ class MissingModelDeploymentWorkflowIdError (Exception ): # pragma: no cover
75
75
pass
76
76
77
77
@@ -175,32 +175,23 @@ def activate(
175
175
The `OCIDataScienceModelDeployment` instance (self).
176
176
"""
177
177
dsc_model_deployment = OCIDataScienceModelDeployment .from_id (self .id )
178
- if (
179
- dsc_model_deployment .lifecycle_state
180
- == self .LIFECYCLE_STATE_ACTIVE
181
- ):
178
+ if dsc_model_deployment .lifecycle_state == self .LIFECYCLE_STATE_ACTIVE :
182
179
raise Exception (
183
180
f"Model deployment { dsc_model_deployment .id } is already in active state."
184
181
)
185
182
186
- if (
187
- dsc_model_deployment .lifecycle_state
188
- == self .LIFECYCLE_STATE_INACTIVE
189
- ):
183
+ if dsc_model_deployment .lifecycle_state == self .LIFECYCLE_STATE_INACTIVE :
190
184
logger .info (f"Activating model deployment `{ self .id } `." )
191
185
response = self .client .activate_model_deployment (
192
186
self .id ,
193
187
)
194
188
195
189
if wait_for_completion :
196
-
197
190
self .workflow_req_id = response .headers .get ("opc-work-request-id" , None )
198
191
199
192
try :
200
193
self .wait_for_progress (
201
- self .workflow_req_id ,
202
- max_wait_time ,
203
- poll_interval
194
+ self .workflow_req_id , max_wait_time , poll_interval
204
195
)
205
196
except Exception as e :
206
197
logger .error (
@@ -241,21 +232,17 @@ def create(
241
232
response = self .client .create_model_deployment (create_model_deployment_details )
242
233
self .update_from_oci_model (response .data )
243
234
logger .info (f"Creating model deployment `{ self .id } `." )
235
+ print (f"Model Deployment OCID: { self .id } " )
244
236
245
237
if wait_for_completion :
246
-
247
238
self .workflow_req_id = response .headers .get ("opc-work-request-id" , None )
248
239
249
240
try :
250
241
self .wait_for_progress (
251
- self .workflow_req_id ,
252
- max_wait_time ,
253
- poll_interval
242
+ self .workflow_req_id , max_wait_time , poll_interval
254
243
)
255
244
except Exception as e :
256
- logger .error (
257
- "Error while trying to create model deployment: " + str (e )
258
- )
245
+ logger .error ("Error while trying to create model deployment: " + str (e ))
259
246
260
247
return self .sync ()
261
248
@@ -287,32 +274,23 @@ def deactivate(
287
274
The `OCIDataScienceModelDeployment` instance (self).
288
275
"""
289
276
dsc_model_deployment = OCIDataScienceModelDeployment .from_id (self .id )
290
- if (
291
- dsc_model_deployment .lifecycle_state
292
- == self .LIFECYCLE_STATE_INACTIVE
293
- ):
277
+ if dsc_model_deployment .lifecycle_state == self .LIFECYCLE_STATE_INACTIVE :
294
278
raise Exception (
295
279
f"Model deployment { dsc_model_deployment .id } is already in inactive state."
296
280
)
297
281
298
- if (
299
- dsc_model_deployment .lifecycle_state
300
- == self .LIFECYCLE_STATE_ACTIVE
301
- ):
282
+ if dsc_model_deployment .lifecycle_state == self .LIFECYCLE_STATE_ACTIVE :
302
283
logger .info (f"Deactivating model deployment `{ self .id } `." )
303
284
response = self .client .deactivate_model_deployment (
304
285
self .id ,
305
286
)
306
287
307
288
if wait_for_completion :
308
-
309
289
self .workflow_req_id = response .headers .get ("opc-work-request-id" , None )
310
290
311
291
try :
312
292
self .wait_for_progress (
313
- self .workflow_req_id ,
314
- max_wait_time ,
315
- poll_interval
293
+ self .workflow_req_id , max_wait_time , poll_interval
316
294
)
317
295
except Exception as e :
318
296
logger .error (
@@ -355,7 +333,7 @@ def delete(
355
333
dsc_model_deployment = OCIDataScienceModelDeployment .from_id (self .id )
356
334
if dsc_model_deployment .lifecycle_state in [
357
335
self .LIFECYCLE_STATE_DELETED ,
358
- self .LIFECYCLE_STATE_DELETING
336
+ self .LIFECYCLE_STATE_DELETING ,
359
337
]:
360
338
raise Exception (
361
339
f"Model deployment { dsc_model_deployment .id } is either deleted or being deleted."
@@ -374,19 +352,14 @@ def delete(
374
352
)
375
353
376
354
if wait_for_completion :
377
-
378
355
self .workflow_req_id = response .headers .get ("opc-work-request-id" , None )
379
356
380
357
try :
381
358
self .wait_for_progress (
382
- self .workflow_req_id ,
383
- max_wait_time ,
384
- poll_interval
359
+ self .workflow_req_id , max_wait_time , poll_interval
385
360
)
386
361
except Exception as e :
387
- logger .error (
388
- "Error while trying to delete model deployment: " + str (e )
389
- )
362
+ logger .error ("Error while trying to delete model deployment: " + str (e ))
390
363
391
364
return self .sync ()
392
365
@@ -440,9 +413,7 @@ def update(
440
413
)
441
414
self .workflow_req_id = response .headers .get ("opc-work-request-id" , None )
442
415
except Exception as e :
443
- logger .error (
444
- "Error while trying to update model deployment: " + str (e )
445
- )
416
+ logger .error ("Error while trying to update model deployment: " + str (e ))
446
417
447
418
return self .sync ()
448
419
0 commit comments