111
111
"loss_fn" : "mse" ,
112
112
}
113
113
_TEST_SERVING_CONTAINER_PORTS = [8888 , 10000 ]
114
+ _TEST_SERVING_CONTAINER_GRPC_PORTS = [7777 , 7000 ]
114
115
_TEST_ID = "1028944691210842416"
115
116
_TEST_LABEL = {"team" : "experimentation" , "trial_id" : "x435" }
116
117
_TEST_APPENDED_USER_AGENT = ["fake_user_agent" ]
@@ -1112,6 +1113,10 @@ def test_init_with_serving_container_spec(self):
1112
1113
gca_model_compat .Port (container_port = port )
1113
1114
for port in _TEST_SERVING_CONTAINER_PORTS
1114
1115
]
1116
+ grpc_ports = [
1117
+ gca_model_compat .Port (container_port = port )
1118
+ for port in _TEST_SERVING_CONTAINER_GRPC_PORTS
1119
+ ]
1115
1120
container_spec = gca_model_compat .ModelContainerSpec (
1116
1121
image_uri = _TEST_SERVING_CONTAINER_IMAGE ,
1117
1122
predict_route = _TEST_SERVING_CONTAINER_PREDICTION_ROUTE ,
@@ -1120,6 +1125,7 @@ def test_init_with_serving_container_spec(self):
1120
1125
args = _TEST_SERVING_CONTAINER_ARGS ,
1121
1126
env = env ,
1122
1127
ports = ports ,
1128
+ grpc_ports = grpc_ports ,
1123
1129
)
1124
1130
1125
1131
local_model = LocalModel (
@@ -1139,6 +1145,9 @@ def test_init_with_serving_container_spec(self):
1139
1145
assert local_model .serving_container_spec .args == container_spec .args
1140
1146
assert local_model .serving_container_spec .env == container_spec .env
1141
1147
assert local_model .serving_container_spec .ports == container_spec .ports
1148
+ assert (
1149
+ local_model .serving_container_spec .grpc_ports == container_spec .grpc_ports
1150
+ )
1142
1151
1143
1152
def test_init_with_serving_container_spec_but_not_image_uri_throws_exception (self ):
1144
1153
env = [
@@ -1149,13 +1158,18 @@ def test_init_with_serving_container_spec_but_not_image_uri_throws_exception(sel
1149
1158
gca_model_compat .Port (container_port = port )
1150
1159
for port in _TEST_SERVING_CONTAINER_PORTS
1151
1160
]
1161
+ grpc_ports = [
1162
+ gca_model_compat .Port (container_port = port )
1163
+ for port in _TEST_SERVING_CONTAINER_GRPC_PORTS
1164
+ ]
1152
1165
container_spec = gca_model_compat .ModelContainerSpec (
1153
1166
predict_route = _TEST_SERVING_CONTAINER_PREDICTION_ROUTE ,
1154
1167
health_route = _TEST_SERVING_CONTAINER_HEALTH_ROUTE ,
1155
1168
command = _TEST_SERVING_CONTAINER_COMMAND ,
1156
1169
args = _TEST_SERVING_CONTAINER_ARGS ,
1157
1170
env = env ,
1158
1171
ports = ports ,
1172
+ grpc_ports = grpc_ports ,
1159
1173
)
1160
1174
expected_message = "Image uri is required for the serving container spec to initialize a LocalModel instance."
1161
1175
@@ -1175,6 +1189,7 @@ def test_init_with_separate_args(self):
1175
1189
serving_container_args = _TEST_SERVING_CONTAINER_ARGS ,
1176
1190
serving_container_environment_variables = _TEST_SERVING_CONTAINER_ENVIRONMENT_VARIABLES ,
1177
1191
serving_container_ports = _TEST_SERVING_CONTAINER_PORTS ,
1192
+ serving_container_grpc_ports = _TEST_SERVING_CONTAINER_GRPC_PORTS ,
1178
1193
)
1179
1194
1180
1195
env = [
@@ -1187,6 +1202,11 @@ def test_init_with_separate_args(self):
1187
1202
for port in _TEST_SERVING_CONTAINER_PORTS
1188
1203
]
1189
1204
1205
+ grpc_ports = [
1206
+ gca_model_compat .Port (container_port = port )
1207
+ for port in _TEST_SERVING_CONTAINER_GRPC_PORTS
1208
+ ]
1209
+
1190
1210
container_spec = gca_model_compat .ModelContainerSpec (
1191
1211
image_uri = _TEST_SERVING_CONTAINER_IMAGE ,
1192
1212
predict_route = _TEST_SERVING_CONTAINER_PREDICTION_ROUTE ,
@@ -1195,6 +1215,7 @@ def test_init_with_separate_args(self):
1195
1215
args = _TEST_SERVING_CONTAINER_ARGS ,
1196
1216
env = env ,
1197
1217
ports = ports ,
1218
+ grpc_ports = grpc_ports ,
1198
1219
)
1199
1220
1200
1221
assert local_model .serving_container_spec .image_uri == container_spec .image_uri
@@ -1210,6 +1231,9 @@ def test_init_with_separate_args(self):
1210
1231
assert local_model .serving_container_spec .args == container_spec .args
1211
1232
assert local_model .serving_container_spec .env == container_spec .env
1212
1233
assert local_model .serving_container_spec .ports == container_spec .ports
1234
+ assert (
1235
+ local_model .serving_container_spec .grpc_ports == container_spec .grpc_ports
1236
+ )
1213
1237
1214
1238
def test_init_with_separate_args_but_not_image_uri_throws_exception (self ):
1215
1239
expected_message = "Serving container image uri is required to initialize a LocalModel instance."
@@ -1222,6 +1246,7 @@ def test_init_with_separate_args_but_not_image_uri_throws_exception(self):
1222
1246
serving_container_args = _TEST_SERVING_CONTAINER_ARGS ,
1223
1247
serving_container_environment_variables = _TEST_SERVING_CONTAINER_ENVIRONMENT_VARIABLES ,
1224
1248
serving_container_ports = _TEST_SERVING_CONTAINER_PORTS ,
1249
+ serving_container_grpc_ports = _TEST_SERVING_CONTAINER_GRPC_PORTS ,
1225
1250
)
1226
1251
1227
1252
assert str (exception .value ) == expected_message
0 commit comments