Content-Length: 483790 | pFad | http://github.com/googleapis/python-aiplatform/commit/6de9de17254834c18eb3a9d41f87cd864e29456f

75 feat: Remove the requirement for a staging bucket to be set if an age… · googleapis/python-aiplatform@6de9de1 · GitHub
Skip to content

Commit 6de9de1

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Remove the requirement for a staging bucket to be set if an agent engine is created without extra packages or requirements files.
PiperOrigin-RevId: 754147393
1 parent 32ee6d9 commit 6de9de1

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

tests/unit/vertex_langchain/test_agent_engines.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,47 @@ def test_invalid_operation_schema(
23152315
assert want_log_output in caplog.text
23162316

23172317

2318+
@pytest.mark.usefixtures("google_auth_mock")
2319+
class TestLightweightAgentEngine:
2320+
def setup_method(self):
2321+
importlib.reload(initializer)
2322+
importlib.reload(aiplatform)
2323+
aiplatform.init(
2324+
project=_TEST_PROJECT,
2325+
location=_TEST_LOCATION,
2326+
credentials=_TEST_CREDENTIALS,
2327+
)
2328+
self.test_agent = CapitalizeEngine()
2329+
2330+
def test_create_agent_engine_with_no_spec(
2331+
self,
2332+
create_agent_engine_mock,
2333+
cloud_storage_create_bucket_mock,
2334+
tarfile_open_mock,
2335+
cloudpickle_dump_mock,
2336+
cloudpickle_load_mock,
2337+
importlib_metadata_version_mock,
2338+
get_agent_engine_mock,
2339+
):
2340+
importlib.reload(initializer)
2341+
importlib.reload(aiplatform)
2342+
aiplatform.init(
2343+
project=_TEST_PROJECT,
2344+
location=_TEST_LOCATION,
2345+
credentials=_TEST_CREDENTIALS,
2346+
)
2347+
agent_engines.create(
2348+
display_name=_TEST_AGENT_ENGINE_DISPLAY_NAME,
2349+
description=_TEST_AGENT_ENGINE_DESCRIPTION,
2350+
)
2351+
aiplatform.init(
2352+
project=_TEST_PROJECT,
2353+
location=_TEST_LOCATION,
2354+
credentials=_TEST_CREDENTIALS,
2355+
staging_bucket=_TEST_STAGING_BUCKET,
2356+
)
2357+
2358+
23182359
def _generate_agent_engine_to_update() -> "agent_engines.AgentEngine":
23192360
test_agent_engine = agent_engines.create(CapitalizeEngine())
23202361
# Resource name is required for the update method.

vertexai/agent_engines/_agent_engines.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,11 @@ def create(
338338
"""
339339
sys_version = f"{sys.version_info.major}.{sys.version_info.minor}"
340340
_validate_sys_version_or_raise(sys_version)
341+
gcs_dir_name = gcs_dir_name or _DEFAULT_GCS_DIR_NAME
342+
staging_bucket = initializer.global_config.staging_bucket
341343
if agent_engine is not None:
342344
agent_engine = _validate_agent_engine_or_raise(agent_engine)
345+
_validate_staging_bucket_or_raise(staging_bucket)
343346
if agent_engine is None:
344347
if requirements is not None:
345348
raise ValueError("requirements must be None if agent_engine is None.")
@@ -350,12 +353,9 @@ def create(
350353
requirements=requirements,
351354
)
352355
extra_packages = _validate_extra_packages_or_raise(extra_packages)
353-
gcs_dir_name = gcs_dir_name or _DEFAULT_GCS_DIR_NAME
354356

355357
sdk_resource = cls.__new__(cls)
356358
base.VertexAiResourceNounWithFutureManager.__init__(sdk_resource)
357-
staging_bucket = initializer.global_config.staging_bucket
358-
_validate_staging_bucket_or_raise(staging_bucket)
359359
# Prepares the Agent Engine for creation in Vertex AI.
360360
# This involves packaging and uploading the artifacts for
361361
# agent_engine, requirements and extra_packages to
@@ -881,17 +881,18 @@ def _prepare(
881881
gcs_dir_name (str): The GCS bucket directory under `staging_bucket` to
882882
use for staging the artifacts needed.
883883
"""
884+
if agent_engine is None:
885+
return
884886
gcs_bucket = _get_gcs_bucket(
885887
project=project,
886888
location=location,
887889
staging_bucket=staging_bucket,
888890
)
889-
if agent_engine is not None:
890-
_upload_agent_engine(
891-
agent_engine=agent_engine,
892-
gcs_bucket=gcs_bucket,
893-
gcs_dir_name=gcs_dir_name,
894-
)
891+
_upload_agent_engine(
892+
agent_engine=agent_engine,
893+
gcs_bucket=gcs_bucket,
894+
gcs_dir_name=gcs_dir_name,
895+
)
895896
if requirements is not None:
896897
_upload_requirements(
897898
requirements=requirements,
@@ -992,7 +993,7 @@ def _generate_update_request_or_raise(
992993
Union[Sequence[str], Dict[str, Union[str, aip_types.SecretRef]]]
993994
] = None,
994995
) -> reasoning_engine_service.UpdateReasoningEngineRequest:
995-
"""Tries to generates the update request for the agent engine."""
996+
"""Tries to generate the update request for the agent engine."""
996997
is_spec_update = False
997998
update_masks: List[str] = []
998999
agent_engine_spec = aip_types.ReasoningEngineSpec()

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/python-aiplatform/commit/6de9de17254834c18eb3a9d41f87cd864e29456f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy