Skip to content

Commit 4ce2f60

Browse files
yeesiancopybara-github
authored andcommitted
chore: Add more system test cases for reasoning engines.
PiperOrigin-RevId: 630097505
1 parent 42f5d6f commit 4ce2f60

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

tests/system/vertexai/test_reasoning_engines.py

+72
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
from vertexai.preview import reasoning_engines
2424

2525

26+
class CapitalizeEngine:
27+
"""A sample Reasoning Engine."""
28+
29+
def set_up(self):
30+
pass
31+
32+
def query(self, input: str) -> str:
33+
"""Capitalizes the input."""
34+
return input.upper()
35+
36+
2637
@pytest.mark.usefixtures(
2738
"prepare_staging_bucket", "delete_staging_bucket", "tear_down_resources"
2839
)
@@ -59,3 +70,64 @@ def test_langchain_template(self, shared_state):
5970
assert response.get("input") == "hello"
6071
except exceptions.FailedPrecondition as e:
6172
print(e)
73+
74+
def test_create_reasoning_engine_gcs_dir_name(self, shared_state):
75+
# https://github.com/googleapis/python-aiplatform/issues/3650
76+
super().setup_method()
77+
credentials, _ = auth.default(
78+
scopes=["https://www.googleapis.com/auth/cloud-platform"]
79+
)
80+
vertexai.init(
81+
project=e2e_base._PROJECT,
82+
location=e2e_base._LOCATION,
83+
staging_bucket=f"gs://{shared_state['staging_bucket_name']}",
84+
credentials=credentials,
85+
)
86+
created_app = reasoning_engines.ReasoningEngine.create(
87+
reasoning_engine=CapitalizeEngine(),
88+
gcs_dir_name="test-gcs-dir-name",
89+
)
90+
shared_state.setdefault("resources", [])
91+
shared_state["resources"].append(created_app) # Deletion at teardown.
92+
assert created_app.query(input="hello") == "HELLO"
93+
94+
def test_create_reasoning_engine_resource_attributes(self, shared_state):
95+
super().setup_method()
96+
credentials, _ = auth.default(
97+
scopes=["https://www.googleapis.com/auth/cloud-platform"]
98+
)
99+
vertexai.init(
100+
project=e2e_base._PROJECT,
101+
location=e2e_base._LOCATION,
102+
staging_bucket=f"gs://{shared_state['staging_bucket_name']}",
103+
credentials=credentials,
104+
)
105+
created_app = reasoning_engines.ReasoningEngine.create(
106+
reasoning_engine=CapitalizeEngine(),
107+
reasoning_engine_name="test-reasoning-engine-name",
108+
display_name="test-display-name",
109+
description="test-description",
110+
)
111+
shared_state.setdefault("resources", [])
112+
shared_state["resources"].append(created_app) # Deletion at teardown.
113+
assert created_app.gca_resource.name == "test-reasoning-engine-name"
114+
assert created_app.gca_resource.display_name == "test-display-name"
115+
assert created_app.gca_resource.description == "test-description"
116+
117+
def test_create_reasoning_engine_operation_schemas(self, shared_state):
118+
super().setup_method()
119+
credentials, _ = auth.default(
120+
scopes=["https://www.googleapis.com/auth/cloud-platform"]
121+
)
122+
vertexai.init(
123+
project=e2e_base._PROJECT,
124+
location=e2e_base._LOCATION,
125+
staging_bucket=f"gs://{shared_state['staging_bucket_name']}",
126+
credentials=credentials,
127+
)
128+
created_app = reasoning_engines.ReasoningEngine.create(
129+
reasoning_engine=CapitalizeEngine(),
130+
)
131+
shared_state.setdefault("resources", [])
132+
shared_state["resources"].append(created_app) # Deletion at teardown.
133+
assert created_app.operation_schemas() == []

0 commit comments

Comments
 (0)