Skip to content

feat: [vertexai] Added concise option name to OpenModel.list_deploy_options() #5463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions tests/unit/vertexai/model_garden/test_model_garden.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def get_publisher_model_mock():
multi_deploy_vertex=types.PublisherModel.CallToAction.DeployVertex(
multi_deploy_vertex=[
types.PublisherModel.CallToAction.Deploy(
deploy_task_name="vLLM 32K context",
container_spec=types.ModelContainerSpec(
image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/pytorch-vllm-serve:20241202_0916_RC00",
command=["python", "main.py"],
Expand All @@ -198,6 +199,7 @@ def get_publisher_model_mock():
),
),
types.PublisherModel.CallToAction.Deploy(
deploy_task_name="vLLM 128K context",
container_spec=types.ModelContainerSpec(
image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/text-generation-inference-cu121.2-1.py310:latest",
command=["python", "main.py"],
Expand Down Expand Up @@ -1032,17 +1034,17 @@ def test_list_deploy_options_concise(self, get_publisher_model_mock):
result = model.list_deploy_options(concise=True)
expected_result = textwrap.dedent(
"""\
[Option 1]
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/pytorch-vllm-serve:20241202_0916_RC00",
machine_type="g2-standard-16",
accelerator_type="NVIDIA_L4",
accelerator_count=1,
[Option 1: vLLM 32K context]
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/pytorch-vllm-serve:20241202_0916_RC00",
machine_type="g2-standard-16",
accelerator_type="NVIDIA_L4",
accelerator_count=1,

[Option 2]
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/text-generation-inference-cu121.2-1.py310:latest",
machine_type="g2-standard-32",
accelerator_type="NVIDIA_L4",
accelerator_count=4,"""
[Option 2: vLLM 128K context]
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/text-generation-inference-cu121.2-1.py310:latest",
machine_type="g2-standard-32",
accelerator_type="NVIDIA_L4",
accelerator_count=4,"""
)
assert result == expected_result
get_publisher_model_mock.assert_called_with(
Expand All @@ -1058,16 +1060,16 @@ def test_list_deploy_options_concise(self, get_publisher_model_mock):
expected_hf_result = textwrap.dedent(
"""\
[Option 1]
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/pytorch-vllm-serve:20241202_0916_RC00",
machine_type="g2-standard-16",
accelerator_type="NVIDIA_L4",
accelerator_count=1,
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/pytorch-vllm-serve:20241202_0916_RC00",
machine_type="g2-standard-16",
accelerator_type="NVIDIA_L4",
accelerator_count=1,

[Option 2]
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/text-generation-inference-cu121.2-1.py310:latest",
machine_type="g2-standard-32",
accelerator_type="NVIDIA_L4",
accelerator_count=4,"""
serving_container_image_uri="us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/text-generation-inference-cu121.2-1.py310:latest",
machine_type="g2-standard-32",
accelerator_type="NVIDIA_L4",
accelerator_count=4,"""
)
assert hf_result == expected_hf_result
get_publisher_model_mock.assert_called_with(
Expand Down
14 changes: 10 additions & 4 deletions vertexai/model_garden/_model_garden.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def list_deploy_options(

Args:
concise: If true, returns a human-readable string with container and
machine specs.
machine specs.

Returns:
A list of deploy options or a concise formatted string.
Expand Down Expand Up @@ -694,8 +694,10 @@ def _extract_config(option):
if option.dedicated_resources
else None
)
option_name = getattr(option, "deploy_task_name", None)

return {
"option_name": option_name,
"serving_container_image_uri": container,
"machine_type": getattr(machine, "machine_type", None),
"accelerator_type": getattr(
Expand All @@ -706,11 +708,15 @@ def _extract_config(option):

concise_deploy_options = [_extract_config(opt) for opt in deploy_options]
return "\n\n".join(
f"[Option {i + 1}]\n"
(
f"[Option {i + 1}: {config['option_name']}]\n"
if config.get("option_name")
else f"[Option {i + 1}]\n"
)
+ "\n".join(
f' {k}="{v}",' if k != "accelerator_count" else f" {k}={v},"
f' {k}="{v}",' if k != "accelerator_count" else f" {k}={v},"
for k, v in config.items()
if v is not None
if v is not None and k != "option_name"
)
for i, config in enumerate(concise_deploy_options)
)
Expand Down