File tree 2 files changed +27
-6
lines changed
2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -387,12 +387,14 @@ def get_resource_type(self) -> _Product:
387
387
return self ._resource_type
388
388
389
389
vertex_product = os .getenv ("VERTEX_PRODUCT" )
390
- if vertex_product == "COLAB_ENTERPRISE" :
391
- self ._resource_type = _Product .COLAB_ENTERPRISE
392
- if vertex_product == "WORKBENCH_CUSTOM_CONTAINER" :
393
- self ._resource_type = _Product .WORKBENCH_CUSTOM_CONTAINER
394
- if vertex_product == "WORKBENCH_INSTANCE" :
395
- self ._resource_type = _Product .WORKBENCH_INSTANCE
390
+ product_mapping = {
391
+ "COLAB_ENTERPRISE" : _Product .COLAB_ENTERPRISE ,
392
+ "WORKBENCH_CUSTOM_CONTAINER" : _Product .WORKBENCH_CUSTOM_CONTAINER ,
393
+ "WORKBENCH_INSTANCE" : _Product .WORKBENCH_INSTANCE ,
394
+ }
395
+
396
+ if vertex_product in product_mapping :
397
+ self ._resource_type = product_mapping [vertex_product ]
396
398
397
399
return self ._resource_type
398
400
Original file line number Diff line number Diff line change @@ -435,6 +435,25 @@ def test_get_client_options_with_api_override(self):
435
435
436
436
assert client_options .api_endpoint == "asia-east1-override.googleapis.com"
437
437
438
+ def test_get_resource_type (self ):
439
+ initializer .global_config .init ()
440
+ os .environ ["VERTEX_PRODUCT" ] = "COLAB_ENTERPRISE"
441
+ assert initializer .global_config .get_resource_type ().value == (
442
+ "COLAB_ENTERPRISE"
443
+ )
444
+
445
+ initializer .global_config .init ()
446
+ os .environ ["VERTEX_PRODUCT" ] = "WORKBENCH_INSTANCE"
447
+ assert initializer .global_config .get_resource_type ().value == (
448
+ "WORKBENCH_INSTANCE"
449
+ )
450
+
451
+ initializer .global_config .init ()
452
+ os .environ ["VERTEX_PRODUCT" ] = "WORKBENCH_CUSTOM_CONTAINER"
453
+ assert initializer .global_config .get_resource_type ().value == (
454
+ "WORKBENCH_CUSTOM_CONTAINER"
455
+ )
456
+
438
457
def test_init_with_only_creds_does_not_override_set_project (self ):
439
458
assert initializer .global_config .project is not _TEST_PROJECT_2
440
459
initializer .global_config .init (project = _TEST_PROJECT_2 )
You can’t perform that action at this time.
0 commit comments