@@ -169,6 +169,135 @@ def test_fill_config_with_defaults(self):
169
169
},
170
170
}
171
171
172
+ def test_config_flex_shape_details (self ):
173
+ config_one = {
174
+ "execution" : {
175
+ "backend" : "job" ,
176
+ "auth" : "api_key" ,
177
+ "oci_config" : DEFAULT_OCI_CONFIG_FILE ,
178
+ "oci_profile" : "PROFILE" ,
179
+ "conda_pack_folder" : "~/condapack" ,
180
+ "conda_pack_os_prefix" : "oci://bucket@namespace/path2" ,
181
+ },
182
+ "infrastructure" : {
183
+ "compartment_id" : "oci.compartmentid.abcd" ,
184
+ "project_id" : "oci.projectid.abcd" ,
185
+ "shape_name" : "VM.Standard.E2.4"
186
+ },
187
+ }
188
+
189
+ m = ConfigMerger (config_one )
190
+ m ._config_flex_shape_details ()
191
+
192
+ assert m .config == {
193
+ "execution" : {
194
+ "backend" : "job" ,
195
+ "auth" : "api_key" ,
196
+ "oci_config" : DEFAULT_OCI_CONFIG_FILE ,
197
+ "oci_profile" : "PROFILE" ,
198
+ "conda_pack_folder" : "~/condapack" ,
199
+ "conda_pack_os_prefix" : "oci://bucket@namespace/path2" ,
200
+ },
201
+ "infrastructure" : {
202
+ "compartment_id" : "oci.compartmentid.abcd" ,
203
+ "project_id" : "oci.projectid.abcd" ,
204
+ "shape_name" : "VM.Standard.E2.4"
205
+ },
206
+ }
207
+
208
+ config_one ["infrastructure" ]["shape_name" ] = "VM.Standard.E3.Flex"
209
+ m = ConfigMerger (config_one )
210
+
211
+ with pytest .raises (
212
+ ValueError ,
213
+ match = "Parameters `ocpus` and `memory_in_gbs` must be provided for using flex shape. "
214
+ "Call `ads opctl config` to specify."
215
+ ):
216
+ m ._config_flex_shape_details ()
217
+
218
+ config_one ["infrastructure" ]["ocpus" ] = 2
219
+ config_one ["infrastructure" ]["memory_in_gbs" ] = 24
220
+ m = ConfigMerger (config_one )
221
+ m ._config_flex_shape_details ()
222
+
223
+ assert m .config == {
224
+ "execution" : {
225
+ "backend" : "job" ,
226
+ "auth" : "api_key" ,
227
+ "oci_config" : DEFAULT_OCI_CONFIG_FILE ,
228
+ "oci_profile" : "PROFILE" ,
229
+ "conda_pack_folder" : "~/condapack" ,
230
+ "conda_pack_os_prefix" : "oci://bucket@namespace/path2" ,
231
+ },
232
+ "infrastructure" : {
233
+ "compartment_id" : "oci.compartmentid.abcd" ,
234
+ "project_id" : "oci.projectid.abcd" ,
235
+ "shape_name" : "VM.Standard.E3.Flex" ,
236
+ "shape_config_details" : {
237
+ "ocpus" : 2 ,
238
+ "memory_in_gbs" : 24
239
+ }
240
+ },
241
+ }
242
+
243
+ config_two = {
244
+ "execution" : {
245
+ "backend" : "dataflow" ,
246
+ "auth" : "api_key" ,
247
+ "oci_config" : DEFAULT_OCI_CONFIG_FILE ,
248
+ "oci_profile" : "PROFILE" ,
249
+ "conda_pack_folder" : "~/condapack" ,
250
+ "conda_pack_os_prefix" : "oci://bucket@namespace/path2" ,
251
+ },
252
+ "infrastructure" : {
253
+ "compartment_id" : "oci.compartmentid.abcd" ,
254
+ "project_id" : "oci.projectid.abcd" ,
255
+ "executor_shape" : "VM.Standard.E3.Flex" ,
256
+ "driver_shape" : "VM.Standard.E3.Flex"
257
+ },
258
+ }
259
+
260
+ m = ConfigMerger (config_two )
261
+
262
+ with pytest .raises (
263
+ ValueError ,
264
+ match = "Parameters driver_shape_memory_in_gbs must be provided for using flex shape. "
265
+ "Call `ads opctl config` to specify."
266
+ ):
267
+ m ._config_flex_shape_details ()
268
+
269
+
270
+ config_two ["infrastructure" ]["driver_shape_memory_in_gbs" ] = 36
271
+ config_two ["infrastructure" ]["driver_shape_ocpus" ] = 4
272
+ config_two ["infrastructure" ]["executor_shape_memory_in_gbs" ] = 48
273
+ config_two ["infrastructure" ]["executor_shape_ocpus" ] = 5
274
+
275
+ m = ConfigMerger (config_two )
276
+ m ._config_flex_shape_details ()
277
+ assert m .config == {
278
+ "execution" : {
279
+ "backend" : "dataflow" ,
280
+ "auth" : "api_key" ,
281
+ "oci_config" : DEFAULT_OCI_CONFIG_FILE ,
282
+ "oci_profile" : "PROFILE" ,
283
+ "conda_pack_folder" : "~/condapack" ,
284
+ "conda_pack_os_prefix" : "oci://bucket@namespace/path2" ,
285
+ },
286
+ "infrastructure" : {
287
+ "compartment_id" : "oci.compartmentid.abcd" ,
288
+ "project_id" : "oci.projectid.abcd" ,
289
+ "executor_shape" : "VM.Standard.E3.Flex" ,
290
+ "executor_shape_config" : {
291
+ "ocpus" : 5 ,
292
+ "memory_in_gbs" : 48
293
+ },
294
+ "driver_shape" : "VM.Standard.E3.Flex" ,
295
+ "driver_shape_config" : {
296
+ "ocpus" : 4 ,
297
+ "memory_in_gbs" : 36
298
+ }
299
+ },
300
+ }
172
301
173
302
class TestConfigResolver :
174
303
def test_resolve_operator_name (self ):
0 commit comments