|
26 | 26 | from google.auth import credentials as auth_credentials |
27 | 27 | from google.cloud import storage |
28 | 28 | import vertexai |
29 | | -from google.cloud import aiplatform |
30 | 29 | from google.cloud.aiplatform_v1 import types as aip_types |
31 | 30 | from google.cloud.aiplatform_v1.services import reasoning_engine_service |
32 | 31 | from google.cloud.aiplatform import base |
@@ -1012,99 +1011,100 @@ def update_agent_engine_mock(): |
1012 | 1011 | yield update_agent_engine_mock |
1013 | 1012 |
|
1014 | 1013 |
|
1015 | | -@pytest.mark.usefixtures("google_auth_mock") |
1016 | | -class TestAgentEngines: |
1017 | | - def setup_method(self): |
1018 | | - importlib.reload(initializer) |
1019 | | - importlib.reload(aiplatform) |
1020 | | - aiplatform.init( |
1021 | | - project=_TEST_PROJECT, |
1022 | | - location=_TEST_LOCATION, |
1023 | | - credentials=_TEST_CREDENTIALS, |
1024 | | - staging_bucket=_TEST_STAGING_BUCKET, |
1025 | | - ) |
1026 | | - |
1027 | | - def teardown_method(self): |
1028 | | - initializer.global_pool.shutdown(wait=True) |
1029 | | - |
1030 | | - @pytest.mark.parametrize( |
1031 | | - "env_vars,expected_env_vars", |
1032 | | - [ |
1033 | | - ({}, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}), |
1034 | | - (None, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}), |
1035 | | - ( |
1036 | | - {"some_env": "some_val"}, |
1037 | | - { |
1038 | | - "some_env": "some_val", |
1039 | | - GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true", |
1040 | | - }, |
1041 | | - ), |
1042 | | - ( |
1043 | | - {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}, |
1044 | | - {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}, |
1045 | | - ), |
1046 | | - ], |
1047 | | - ) |
1048 | | - def test_create_default_telemetry_enablement( |
1049 | | - self, |
1050 | | - create_agent_engine_mock: mock.Mock, |
1051 | | - cloud_storage_create_bucket_mock: mock.Mock, |
1052 | | - cloudpickle_dump_mock: mock.Mock, |
1053 | | - cloudpickle_load_mock: mock.Mock, |
1054 | | - get_gca_resource_mock: mock.Mock, |
1055 | | - env_vars: dict[str, str], |
1056 | | - expected_env_vars: dict[str, str], |
1057 | | - ): |
1058 | | - agent_engines.create( |
1059 | | - agent_engine=agent_engines.AdkApp(agent=_TEST_AGENT), |
1060 | | - env_vars=env_vars, |
1061 | | - ) |
1062 | | - create_agent_engine_mock.assert_called_once() |
1063 | | - deployment_spec = create_agent_engine_mock.call_args.kwargs[ |
1064 | | - "reasoning_engine" |
1065 | | - ].spec.deployment_spec |
1066 | | - assert _utils.to_dict(deployment_spec)["env"] == [ |
1067 | | - {"name": key, "value": value} for key, value in expected_env_vars.items() |
1068 | | - ] |
1069 | | - |
1070 | | - @pytest.mark.parametrize( |
1071 | | - "env_vars,expected_env_vars", |
1072 | | - [ |
1073 | | - ({}, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}), |
1074 | | - (None, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}), |
1075 | | - ( |
1076 | | - {"some_env": "some_val"}, |
1077 | | - { |
1078 | | - "some_env": "some_val", |
1079 | | - GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true", |
1080 | | - }, |
1081 | | - ), |
1082 | | - ( |
1083 | | - {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}, |
1084 | | - {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}, |
1085 | | - ), |
1086 | | - ], |
1087 | | - ) |
1088 | | - def test_update_default_telemetry_enablement( |
1089 | | - self, |
1090 | | - update_agent_engine_mock: mock.Mock, |
1091 | | - cloud_storage_create_bucket_mock: mock.Mock, |
1092 | | - cloudpickle_dump_mock: mock.Mock, |
1093 | | - cloudpickle_load_mock: mock.Mock, |
1094 | | - get_gca_resource_mock: mock.Mock, |
1095 | | - get_agent_engine_mock: mock.Mock, |
1096 | | - env_vars: dict[str, str], |
1097 | | - expected_env_vars: dict[str, str], |
1098 | | - ): |
1099 | | - agent_engines.update( |
1100 | | - resource_name=_TEST_AGENT_ENGINE_RESOURCE_NAME, |
1101 | | - description="foobar", # avoid "At least one of ... must be specified" errors. |
1102 | | - env_vars=env_vars, |
1103 | | - ) |
1104 | | - update_agent_engine_mock.assert_called_once() |
1105 | | - deployment_spec = update_agent_engine_mock.call_args.kwargs[ |
1106 | | - "request" |
1107 | | - ].reasoning_engine.spec.deployment_spec |
1108 | | - assert _utils.to_dict(deployment_spec)["env"] == [ |
1109 | | - {"name": key, "value": value} for key, value in expected_env_vars.items() |
1110 | | - ] |
| 1014 | +# TODO(jawoszek): Uncomment once we're ready for default-on. |
| 1015 | +# @pytest.mark.usefixtures("google_auth_mock") |
| 1016 | +# class TestAgentEngines: |
| 1017 | +# def setup_method(self): |
| 1018 | +# importlib.reload(initializer) |
| 1019 | +# importlib.reload(aiplatform) |
| 1020 | +# aiplatform.init( |
| 1021 | +# project=_TEST_PROJECT, |
| 1022 | +# location=_TEST_LOCATION, |
| 1023 | +# credentials=_TEST_CREDENTIALS, |
| 1024 | +# staging_bucket=_TEST_STAGING_BUCKET, |
| 1025 | +# ) |
| 1026 | + |
| 1027 | +# def teardown_method(self): |
| 1028 | +# initializer.global_pool.shutdown(wait=True) |
| 1029 | + |
| 1030 | +# @pytest.mark.parametrize( |
| 1031 | +# "env_vars,expected_env_vars", |
| 1032 | +# [ |
| 1033 | +# ({}, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}), |
| 1034 | +# (None, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}), |
| 1035 | +# ( |
| 1036 | +# {"some_env": "some_val"}, |
| 1037 | +# { |
| 1038 | +# "some_env": "some_val", |
| 1039 | +# GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false", |
| 1040 | +# }, |
| 1041 | +# ), |
| 1042 | +# ( |
| 1043 | +# {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}, |
| 1044 | +# {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}, |
| 1045 | +# ), |
| 1046 | +# ], |
| 1047 | +# ) |
| 1048 | +# def test_create_default_telemetry_enablement( |
| 1049 | +# self, |
| 1050 | +# create_agent_engine_mock: mock.Mock, |
| 1051 | +# cloud_storage_create_bucket_mock: mock.Mock, |
| 1052 | +# cloudpickle_dump_mock: mock.Mock, |
| 1053 | +# cloudpickle_load_mock: mock.Mock, |
| 1054 | +# get_gca_resource_mock: mock.Mock, |
| 1055 | +# env_vars: dict[str, str], |
| 1056 | +# expected_env_vars: dict[str, str], |
| 1057 | +# ): |
| 1058 | +# agent_engines.create( |
| 1059 | +# agent_engine=agent_engines.AdkApp(agent=_TEST_AGENT), |
| 1060 | +# env_vars=env_vars, |
| 1061 | +# ) |
| 1062 | +# create_agent_engine_mock.assert_called_once() |
| 1063 | +# deployment_spec = create_agent_engine_mock.call_args.kwargs[ |
| 1064 | +# "reasoning_engine" |
| 1065 | +# ].spec.deployment_spec |
| 1066 | +# assert _utils.to_dict(deployment_spec)["env"] == [ |
| 1067 | +# {"name": key, "value": value} for key, value in expected_env_vars.items() |
| 1068 | +# ] |
| 1069 | + |
| 1070 | +# @pytest.mark.parametrize( |
| 1071 | +# "env_vars,expected_env_vars", |
| 1072 | +# [ |
| 1073 | +# ({}, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}), |
| 1074 | +# (None, {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false"}), |
| 1075 | +# ( |
| 1076 | +# {"some_env": "some_val"}, |
| 1077 | +# { |
| 1078 | +# "some_env": "some_val", |
| 1079 | +# GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "false", |
| 1080 | +# }, |
| 1081 | +# ), |
| 1082 | +# ( |
| 1083 | +# {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}, |
| 1084 | +# {GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY: "true"}, |
| 1085 | +# ), |
| 1086 | +# ], |
| 1087 | +# ) |
| 1088 | +# def test_update_default_telemetry_enablement( |
| 1089 | +# self, |
| 1090 | +# update_agent_engine_mock: mock.Mock, |
| 1091 | +# cloud_storage_create_bucket_mock: mock.Mock, |
| 1092 | +# cloudpickle_dump_mock: mock.Mock, |
| 1093 | +# cloudpickle_load_mock: mock.Mock, |
| 1094 | +# get_gca_resource_mock: mock.Mock, |
| 1095 | +# get_agent_engine_mock: mock.Mock, |
| 1096 | +# env_vars: dict[str, str], |
| 1097 | +# expected_env_vars: dict[str, str], |
| 1098 | +# ): |
| 1099 | +# agent_engines.update( |
| 1100 | +# resource_name=_TEST_AGENT_ENGINE_RESOURCE_NAME, |
| 1101 | +# description="foobar", # avoid "At least one of ... must be specified" errors. |
| 1102 | +# env_vars=env_vars, |
| 1103 | +# ) |
| 1104 | +# update_agent_engine_mock.assert_called_once() |
| 1105 | +# deployment_spec = update_agent_engine_mock.call_args.kwargs[ |
| 1106 | +# "request" |
| 1107 | +# ].reasoning_engine.spec.deployment_spec |
| 1108 | +# assert _utils.to_dict(deployment_spec)["env"] == [ |
| 1109 | +# {"name": key, "value": value} for key, value in expected_env_vars.items() |
| 1110 | +# ] |
0 commit comments