79
79
model_deployment_instance_shape_config_details = ModelDeploymentInstanceShapeConfigDetails (
80
80
ocpus = 10 , memory_in_gbs = 36
81
81
),
82
- subnet_id = "fakeid.subnet.oc1.iad.xxx"
83
82
),
84
83
scaling_policy = FixedSizeScalingPolicy (instance_count = 5 ),
85
84
bandwidth_mbps = 5 ,
129
128
"replica" : 5 ,
130
129
"shape_name" : "VM.Standard.E4.Flex" ,
131
130
"shape_config_details" : {"ocpus" : 10 , "memoryInGBs" : 36 },
132
- "subnet_id" : "fakeid.subnet.oc1.iad.xxx" ,
133
131
"web_concurrency" : 10 ,
134
132
"access_log" : {
135
133
"logGroupId" : "fakeid.loggroup.oc1.iad.xxx" ,
150
148
"entrypoint" : ["python" , "/opt/ds/model/deployed_model/api.py" ],
151
149
"server_port" : 5000 ,
152
150
"health_check_port" : 5000 ,
153
- "env" : {"WEB_CONCURRENCY" : 10 },
151
+ "env" : {"WEB_CONCURRENCY" : "10" },
154
152
"input_stream_ids" : ["123" , "456" ],
155
153
"output_stream_ids" : ["321" , "654" ],
156
154
"model_uri" : "fakeid.datasciencemodel.oc1.iad.xxx" ,
186
184
shapeConfigDetails:
187
185
memoryInGBs: 36
188
186
ocpus: 10
189
- subnetId: fakeid.subnet.oc1.iad.xxx
190
187
replica: 5
191
188
bandwidthMbps: 5
192
- webConcurrency: 5
189
+ webConcurrency: 10
193
190
runtime:
194
191
kind: runtime
195
192
type: container
200
197
entrypoint: ["python", "/opt/ds/model/deployed_model/api.py"]
201
198
serverPort: 5000
202
199
healthCheckPort: 5000
203
- env:
204
- key: value
205
200
inputStreamIds: ["123", "456"]
206
201
outputStreamIds: ["321", "654"]
207
202
deploymentMode: STREAM_ONLY
208
203
"""
209
204
205
+ infrastructure = (
206
+ ModelDeploymentInfrastructure ()
207
+ .with_bandwidth_mbps (5 )
208
+ .with_compartment_id ("fakeid.compartment.oc1..xxx" )
209
+ .with_project_id ("fakeid.datascienceproject.oc1.iad.xxx" )
210
+ .with_replica (5 )
211
+ .with_shape_name ("VM.Standard.E4.Flex" )
212
+ .with_shape_config_details (ocpus = 10 , memory_in_gbs = 36 )
213
+ .with_web_concurrency (10 )
214
+ .with_access_log (
215
+ log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
216
+ log_id = "fakeid.log.oc1.iad.xxx" ,
217
+ )
218
+ .with_predict_log (
219
+ log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
220
+ log_id = "fakeid.log.oc1.iad.xxx" ,
221
+ )
222
+ )
210
223
211
- class ModelDeploymentBYOCTestCase (unittest .TestCase ):
212
- def initialize_model_deployment (self ):
213
- infrastructure = (
214
- ModelDeploymentInfrastructure ()
215
- .with_bandwidth_mbps (5 )
216
- .with_compartment_id ("fakeid.compartment.oc1..xxx" )
217
- .with_project_id ("fakeid.datascienceproject.oc1.iad.xxx" )
218
- .with_replica (5 )
219
- .with_shape_name ("VM.Standard.E4.Flex" )
220
- .with_shape_config_details (ocpus = 10 , memory_in_gbs = 36 )
221
- .with_subnet_id ("fakeid.subnet.oc1.iad.xxx" )
222
- .with_web_concurrency (10 )
223
- .with_access_log (
224
- log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
225
- log_id = "fakeid.log.oc1.iad.xxx" ,
226
- )
227
- .with_predict_log (
228
- log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
229
- log_id = "fakeid.log.oc1.iad.xxx" ,
230
- )
231
- )
224
+ runtime = (
225
+ ModelDeploymentContainerRuntime ()
226
+ .with_image ("iad.ocir.io/ociodscdev/ml_flask_app_demo:1.0.0" )
227
+ .with_image_digest (
228
+ "sha256:243590ea099af4019b6afc104b8a70b9552f0b001b37d0442f8b5a399244681c"
229
+ )
230
+ .with_entrypoint (["python" , "/opt/ds/model/deployed_model/api.py" ])
231
+ .with_server_port (5000 )
232
+ .with_health_check_port (5000 )
233
+ .with_input_stream_ids (["123" , "456" ])
234
+ .with_output_stream_ids (["321" , "654" ])
235
+ .with_model_uri ("fakeid.datasciencemodel.oc1.iad.xxx" )
236
+ .with_deployment_mode ("STREAM_ONLY" )
237
+ )
232
238
233
- runtime = (
234
- ModelDeploymentContainerRuntime ()
235
- .with_image ("iad.ocir.io/ociodscdev/ml_flask_app_demo:1.0.0" )
236
- .with_image_digest (
237
- "sha256:243590ea099af4019b6afc104b8a70b9552f0b001b37d0442f8b5a399244681c"
238
- )
239
- .with_entrypoint (["python" , "/opt/ds/model/deployed_model/api.py" ])
240
- .with_server_port (5000 )
241
- .with_health_check_port (5000 )
242
- .with_env (
243
- {
244
- "WEB_CONCURRENCY" : 10 ,
245
- }
246
- )
247
- .with_input_stream_ids (["123" , "456" ])
248
- .with_output_stream_ids (["321" , "654" ])
249
- .with_model_uri ("fakeid.datasciencemodel.oc1.iad.xxx" )
250
- .with_deployment_mode ("STREAM_ONLY" )
251
- )
252
239
240
+ class ModelDeploymentBYOCTestCase (unittest .TestCase ):
241
+ def initialize_model_deployment (self ):
253
242
model_deployment = (
254
243
ModelDeployment ()
255
244
.with_display_name ("Generic Model Deployment With Small Artifact" )
@@ -263,46 +252,6 @@ def initialize_model_deployment(self):
263
252
return model_deployment
264
253
265
254
def initialize_model_deployment_from_spec (self ):
266
- infrastructure = (
267
- ModelDeploymentInfrastructure ()
268
- .with_bandwidth_mbps (5 )
269
- .with_compartment_id ("fakeid.compartment.oc1..xxx" )
270
- .with_project_id ("fakeid.datascienceproject.oc1.iad.xxx" )
271
- .with_replica (5 )
272
- .with_shape_name ("VM.Standard.E4.Flex" )
273
- .with_shape_config_details (ocpus = 10 , memory_in_gbs = 36 )
274
- .with_subnet_id ("fakeid.subnet.oc1.iad.xxx" )
275
- .with_web_concurrency (10 )
276
- .with_access_log (
277
- log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
278
- log_id = "fakeid.log.oc1.iad.xxx" ,
279
- )
280
- .with_predict_log (
281
- log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
282
- log_id = "fakeid.log.oc1.iad.xxx" ,
283
- )
284
- )
285
-
286
- runtime = (
287
- ModelDeploymentContainerRuntime ()
288
- .with_image ("iad.ocir.io/ociodscdev/ml_flask_app_demo:1.0.0" )
289
- .with_image_digest (
290
- "sha256:243590ea099af4019b6afc104b8a70b9552f0b001b37d0442f8b5a399244681c"
291
- )
292
- .with_entrypoint (["python" , "/opt/ds/model/deployed_model/api.py" ])
293
- .with_server_port (5000 )
294
- .with_health_check_port (5000 )
295
- .with_env (
296
- {
297
- "WEB_CONCURRENCY" : 10 ,
298
- }
299
- )
300
- .with_input_stream_ids (["123" , "456" ])
301
- .with_output_stream_ids (["321" , "654" ])
302
- .with_model_uri ("fakeid.datasciencemodel.oc1.iad.xxx" )
303
- .with_deployment_mode ("STREAM_ONLY" )
304
- )
305
-
306
255
return ModelDeployment (
307
256
spec = {
308
257
"display_name" : "Generic Model Deployment With Small Artifact" ,
@@ -315,46 +264,6 @@ def initialize_model_deployment_from_spec(self):
315
264
)
316
265
317
266
def initialize_model_deployment_from_kwargs (self ):
318
- infrastructure = (
319
- ModelDeploymentInfrastructure ()
320
- .with_bandwidth_mbps (5 )
321
- .with_compartment_id ("fakeid.compartment.oc1..xxx" )
322
- .with_project_id ("fakeid.datascienceproject.oc1.iad.xxx" )
323
- .with_replica (5 )
324
- .with_shape_name ("VM.Standard.E4.Flex" )
325
- .with_shape_config_details (ocpus = 10 , memory_in_gbs = 36 )
326
- .with_subnet_id ("fakeid.subnet.oc1.iad.xxx" )
327
- .with_web_concurrency (10 )
328
- .with_access_log (
329
- log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
330
- log_id = "fakeid.log.oc1.iad.xxx" ,
331
- )
332
- .with_predict_log (
333
- log_group_id = "fakeid.loggroup.oc1.iad.xxx" ,
334
- log_id = "fakeid.log.oc1.iad.xxx" ,
335
- )
336
- )
337
-
338
- runtime = (
339
- ModelDeploymentContainerRuntime ()
340
- .with_image ("iad.ocir.io/ociodscdev/ml_flask_app_demo:1.0.0" )
341
- .with_image_digest (
342
- "sha256:243590ea099af4019b6afc104b8a70b9552f0b001b37d0442f8b5a399244681c"
343
- )
344
- .with_entrypoint (["python" , "/opt/ds/model/deployed_model/api.py" ])
345
- .with_server_port (5000 )
346
- .with_health_check_port (5000 )
347
- .with_env (
348
- {
349
- "WEB_CONCURRENCY" : 10 ,
350
- }
351
- )
352
- .with_input_stream_ids (["123" , "456" ])
353
- .with_output_stream_ids (["321" , "654" ])
354
- .with_model_uri ("fakeid.datasciencemodel.oc1.iad.xxx" )
355
- .with_deployment_mode ("STREAM_ONLY" )
356
- )
357
-
358
267
return ModelDeployment (
359
268
display_name = "Generic Model Deployment With Small Artifact" ,
360
269
description = "The model deployment description" ,
@@ -383,7 +292,7 @@ def test_initialize_model_deployment(self):
383
292
384
293
temp_runtime = temp_model_deployment .runtime
385
294
assert temp_runtime .environment_config_type == "OCIR_CONTAINER"
386
- assert temp_runtime .env == {"WEB_CONCURRENCY" : 10 }
295
+ assert temp_runtime .env == {"WEB_CONCURRENCY" : "10" }
387
296
assert temp_runtime .deployment_mode == "STREAM_ONLY"
388
297
assert temp_runtime .input_stream_ids == ["123" , "456" ]
389
298
assert temp_runtime .output_stream_ids == ["321" , "654" ]
@@ -410,7 +319,6 @@ def test_initialize_model_deployment(self):
410
319
"ocpus" : 10 ,
411
320
"memoryInGBs" : 36 ,
412
321
}
413
- assert temp_infrastructure .subnet_id == "fakeid.subnet.oc1.iad.xxx"
414
322
assert temp_infrastructure .replica == 5
415
323
assert temp_infrastructure .access_log == {
416
324
"logGroupId" : "fakeid.loggroup.oc1.iad.xxx" ,
@@ -468,7 +376,6 @@ def test_model_deployment_to_dict(self):
468
376
"replica" : 5 ,
469
377
"shapeName" : "VM.Standard.E4.Flex" ,
470
378
"shapeConfigDetails" : {"ocpus" : 10 , "memoryInGBs" : 36 },
471
- "subnetId" : "fakeid.subnet.oc1.iad.xxx" ,
472
379
"webConcurrency" : 10 ,
473
380
"accessLog" : {
474
381
"logGroupId" : "fakeid.loggroup.oc1.iad.xxx" ,
@@ -489,7 +396,7 @@ def test_model_deployment_to_dict(self):
489
396
"entrypoint" : ["python" , "/opt/ds/model/deployed_model/api.py" ],
490
397
"serverPort" : 5000 ,
491
398
"healthCheckPort" : 5000 ,
492
- "env" : {"WEB_CONCURRENCY" : 10 },
399
+ "env" : {"WEB_CONCURRENCY" : "10" },
493
400
"inputStreamIds" : ["123" , "456" ],
494
401
"outputStreamIds" : ["321" , "654" ],
495
402
"modelUri" : "fakeid.datasciencemodel.oc1.iad.xxx" ,
@@ -525,7 +432,6 @@ def test_build_model_deployment_configuration_details(self, mock_prepare_artifac
525
432
"ocpus" : 10 ,
526
433
"memoryInGBs" : 36 ,
527
434
},
528
- "subnetId" : "fakeid.subnet.oc1.iad.xxx" ,
529
435
},
530
436
"modelId" : "fakeid.datasciencemodel.oc1.iad.xxx" ,
531
437
"scalingPolicy" : {"policyType" : "FIXED_SIZE" , "instanceCount" : 5 },
@@ -689,7 +595,6 @@ def test_build_model_deployment_details(self, mock_prepare_artifact):
689
595
instance_configuration .model_deployment_instance_shape_config_details .memory_in_gbs
690
596
== model_deployment .infrastructure .shape_config_details ["memoryInGBs" ]
691
597
)
692
- assert instance_configuration .subnet_id == model_deployment .infrastructure .subnet_id
693
598
694
599
scaling_policy = model_configuration_details .scaling_policy
695
600
assert isinstance (scaling_policy , FixedSizeScalingPolicy )
@@ -790,7 +695,6 @@ def test_update_from_oci_model(self):
790
695
infrastructure .shape_config_details ["memoryInGBs" ]
791
696
== instance_configuration .model_deployment_instance_shape_config_details .memory_in_gbs
792
697
)
793
- assert infrastructure .subnet_id == instance_configuration .subnet_id
794
698
assert infrastructure .replica == scaling_policy .instance_count
795
699
796
700
category_log_details = OCI_MODEL_DEPLOYMENT_RESPONSE .category_log_details
@@ -853,55 +757,6 @@ def test_model_deployment_from_yaml(self):
853
757
)
854
758
assert isinstance (model_deployment_from_yaml .runtime , ModelDeploymentRuntime )
855
759
856
- assert model_deployment_from_yaml .to_dict () == {
857
- "kind" : "deployment" ,
858
- "type" : "modelDeployment" ,
859
- "spec" : {
860
- "displayName" : "Generic Model Deployment With Small Artifact" ,
861
- "description" : "The model deployment description" ,
862
- "definedTags" : {"key1" : {"skey1" : "value1" }},
863
- "freeformTags" : {"key1" : "value1" },
864
- "infrastructure" : {
865
- "kind" : "infrastructure" ,
866
- "type" : "datascienceModelDeployment" ,
867
- "spec" : {
868
- "bandwidthMbps" : 5 ,
869
- "compartmentId" : "fakeid.compartment.oc1..xxx" ,
870
- "projectId" : "fakeid.datascienceproject.oc1.iad.xxx" ,
871
- "replica" : 5 ,
872
- "shapeName" : "VM.Standard.E4.Flex" ,
873
- "shapeConfigDetails" : {"ocpus" : 10 , "memoryInGBs" : 36 },
874
- "subnetId" : "fakeid.subnet.oc1.iad.xxx" ,
875
- "accessLog" : {
876
- "logGroupId" : "fakeid.loggroup.oc1.iad.xxx" ,
877
- "logId" : "fakeid.log.oc1.iad.xxx" ,
878
- },
879
- "predictLog" : {
880
- "logGroupId" : "fakeid.loggroup.oc1.iad.xxx" ,
881
- "logId" : "fakeid.log.oc1.iad.xxx" ,
882
- },
883
- "webConcurrency" : 5 ,
884
- },
885
- },
886
- "runtime" : {
887
- "kind" : "runtime" ,
888
- "type" : "container" ,
889
- "spec" : {
890
- "image" : "iad.ocir.io/ociodscdev/ml_flask_app_demo:1.0.0" ,
891
- "imageDigest" : "sha256:243590ea099af4019b6afc104b8a70b9552f0b001b37d0442f8b5a399244681c" ,
892
- "entrypoint" : ["python" , "/opt/ds/model/deployed_model/api.py" ],
893
- "serverPort" : 5000 ,
894
- "healthCheckPort" : 5000 ,
895
- "env" : {"key" : "value" },
896
- "inputStreamIds" : ["123" , "456" ],
897
- "outputStreamIds" : ["321" , "654" ],
898
- "modelUri" : "fakeid.datasciencemodel.oc1.iad.xxx" ,
899
- "deploymentMode" : "STREAM_ONLY" ,
900
- },
901
- },
902
- },
903
- }
904
-
905
760
def test_model_deployment_from_dict (self ):
906
761
new_model_deployment = ModelDeployment .from_dict (
907
762
copy .deepcopy (OCI_MODEL_DEPLOYMENT_DICT )
@@ -1038,7 +893,6 @@ def test_update_model_deployment_details(self, mock_prepare_artifact):
1038
893
instance_configuration .model_deployment_instance_shape_config_details .memory_in_gbs
1039
894
== model_deployment .infrastructure .shape_config_details ["memoryInGBs" ]
1040
895
)
1041
- assert instance_configuration .subnet_id == model_deployment .infrastructure .subnet_id
1042
896
1043
897
scaling_policy = model_configuration_details .scaling_policy
1044
898
assert isinstance (scaling_policy , FixedSizeScalingPolicy )
@@ -1090,7 +944,6 @@ def test_extract_from_oci_model(self):
1090
944
"replica" : 5 ,
1091
945
"shapeName" : "VM.Standard.E4.Flex" ,
1092
946
"shapeConfigDetails" : {"ocpus" : 10 , "memoryInGBs" : 36 },
1093
- "subnetId" : "fakeid.subnet.oc1.iad.xxx" ,
1094
947
"accessLog" : {
1095
948
"logGroupId" : "fakeid.loggroup.oc1.iad.xxx" ,
1096
949
"logId" : "fakeid.log.oc1.iad.xxx" ,
@@ -1398,3 +1251,10 @@ def test_list_df(self, mock_list):
1398
1251
project_id = "test_project_id" ,
1399
1252
)
1400
1253
assert isinstance (df , pandas .DataFrame )
1254
+
1255
+ def test_model_deployment_with_subnet_id (self ):
1256
+ model_deployment = self .initialize_model_deployment ()
1257
+ assert model_deployment .infrastructure .subnet_id == None
1258
+
1259
+ model_deployment .infrastructure .with_subnet_id ("test_id" )
1260
+ assert model_deployment .infrastructure .subnet_id == "test_id"
0 commit comments