Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 40 additions & 10 deletions agentplatform/_genai/runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,7 @@ def _is_lightweight_creation(
agent
or config.source_packages
or config.developer_connect_source
or config.git_source
or config.agent_config_source
or config.container_spec
):
Expand Down Expand Up @@ -1860,6 +1861,9 @@ def create(
developer_connect_source = json.loads(
developer_connect_source.model_dump_json()
)
git_source = config.git_source
if git_source is not None:
git_source = json.loads(git_source.model_dump_json(exclude_none=True))
agent_config_source = config.agent_config_source
if agent_config_source is not None:
agent_config_source = json.loads(agent_config_source.model_dump_json())
Expand Down Expand Up @@ -1900,6 +1904,7 @@ def create(
class_methods=config.class_methods,
source_packages=config.source_packages,
developer_connect_source=developer_connect_source,
git_source=git_source,
entrypoint_module=config.entrypoint_module,
entrypoint_object=config.entrypoint_object,
requirements_file=config.requirements_file,
Expand Down Expand Up @@ -1969,6 +1974,9 @@ def _set_source_code_spec(
developer_connect_source: Optional[
types.ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict
] = None,
git_source: Optional[
types.ReasoningEngineSpecSourceCodeSpecGitSourceDict
] = None,
class_methods: Optional[Sequence[dict[str, Any]]] = None,
entrypoint_module: Optional[str] = None,
entrypoint_object: Optional[str] = None,
Expand Down Expand Up @@ -2000,10 +2008,13 @@ def _set_source_code_spec(
source_code_spec["developer_connect_source"] = {
"config": developer_connect_source
}
elif git_source:
update_masks.append("spec.source_code_spec.git_source")
source_code_spec["git_source"] = git_source
elif not agent_config_source:
raise ValueError(
"Please specify one of `source_packages`, `developer_connect_source`, "
"or `agent_config_source`."
"`git_source`, or `agent_config_source`."
)
if class_methods is not None:
update_masks.append("spec.class_methods")
Expand All @@ -2019,8 +2030,8 @@ def _set_source_code_spec(
elif image_spec is None:
raise ValueError(
"`class_methods` must be specified if `source_packages`, "
"`developer_connect_source`, or `agent_config_source` is "
"specified without a Dockerfile or `image_spec`."
"`developer_connect_source`, `git_source`, or `agent_config_source` "
"is specified without a Dockerfile or `image_spec`."
)
if image_spec is not None:
if entrypoint_module or entrypoint_object or requirements_file:
Expand Down Expand Up @@ -2077,13 +2088,13 @@ def _set_source_code_spec(

if not entrypoint_module:
raise ValueError(
"`entrypoint_module` must be specified if `source_packages` or `developer_connect_source` is specified."
"`entrypoint_module` must be specified if `source_packages`, `developer_connect_source`, or `git_source` is specified."
)
update_masks.append("spec.source_code_spec.python_spec.entrypoint_module")
python_spec["entrypoint_module"] = entrypoint_module
if not entrypoint_object:
raise ValueError(
"`entrypoint_object` must be specified if `source_packages` or `developer_connect_source` is specified."
"`entrypoint_object` must be specified if `source_packages`, `developer_connect_source`, or `git_source` is specified."
)
update_masks.append("spec.source_code_spec.python_spec.entrypoint_object")
python_spec["entrypoint_object"] = entrypoint_object
Expand Down Expand Up @@ -2215,6 +2226,9 @@ def _create_config(
developer_connect_source: Optional[
types.ReasoningEngineSpecSourceCodeSpecDeveloperConnectConfigDict
] = None,
git_source: Optional[
types.ReasoningEngineSpecSourceCodeSpecGitSourceDict
] = None,
entrypoint_module: Optional[str] = None,
entrypoint_object: Optional[str] = None,
requirements_file: Optional[str] = None,
Expand Down Expand Up @@ -2284,9 +2298,18 @@ def _create_config(
"do not specify `agent` in `runtimes.create()` or "
"`runtimes.update()`."
)
elif source_packages and developer_connect_source:
if git_source:
raise ValueError(
"If you have provided `git_source` in `config`, please "
"do not specify `agent` in `runtimes.create()` or "
"`runtimes.update()`."
)
elif (
sum(map(bool, (source_packages, developer_connect_source, git_source))) > 1
):
raise ValueError(
"Please specify only one of `source_packages` or `developer_connect_source` in `config`."
"Please specify only one of `source_packages`, "
"`developer_connect_source`, or `git_source` in `config`."
)

if container_spec:
Expand All @@ -2296,10 +2319,11 @@ def _create_config(
"do not specify `agent` in `runtimes.create()` or "
"`runtimes.update()`."
)
if source_packages or developer_connect_source:
if source_packages or developer_connect_source or git_source:
raise ValueError(
"If you have provided `container_spec` in `config`, please "
"do not specify `source_packages` or `developer_connect_source` in `config`."
"do not specify `source_packages`, `developer_connect_source`, or "
"`git_source` in `config`."
)

runtime_spec: Any = None
Expand All @@ -2323,6 +2347,7 @@ def _create_config(
elif (
source_packages
or developer_connect_source
or git_source
or image_spec
or agent_config_source
):
Expand All @@ -2332,6 +2357,7 @@ def _create_config(
update_masks=update_masks,
source_packages=source_packages,
developer_connect_source=developer_connect_source,
git_source=git_source,
class_methods=class_methods,
entrypoint_module=entrypoint_module,
entrypoint_object=entrypoint_object,
Expand Down Expand Up @@ -2373,7 +2399,7 @@ def _create_config(
"`max_instances`, `resource_limits`, `container_concurrency`, or "
"`keep_alive_probe`, you must also provide the `agent` variable or "
"the source code options (`source_packages`, "
"`developer_connect_source` or `agent_config_source`)."
"`developer_connect_source`, `git_source` or `agent_config_source`)."
)

if runtime_spec is not None:
Expand Down Expand Up @@ -2672,6 +2698,9 @@ def update(
developer_connect_source = json.loads(
developer_connect_source.model_dump_json()
)
git_source = config.git_source
if git_source is not None:
git_source = json.loads(git_source.model_dump_json(exclude_none=True))
agent_config_source = config.agent_config_source
if agent_config_source is not None:
agent_config_source = json.loads(agent_config_source.model_dump_json())
Expand Down Expand Up @@ -2721,6 +2750,7 @@ def update(
class_methods=config.class_methods,
source_packages=config.source_packages,
developer_connect_source=developer_connect_source,
git_source=git_source,
entrypoint_module=config.entrypoint_module,
entrypoint_object=config.entrypoint_object,
requirements_file=config.requirements_file,
Expand Down
21 changes: 21 additions & 0 deletions agentplatform/_genai/types/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9759,6 +9759,10 @@ class CreateRuntimeConfig(_common.BaseModel):
subdirectory and the path must be added to `extra_packages`.
""",
)
git_source: Optional[ReasoningEngineSpecSourceCodeSpecGitSource] = Field(
default=None,
description="""Specifies the public Git repository to fetch the source code from. This includes the URL, revision, and directory to use.""",
)


class CreateRuntimeConfigDict(TypedDict, total=False):
Expand Down Expand Up @@ -9900,6 +9904,9 @@ class CreateRuntimeConfigDict(TypedDict, total=False):
subdirectory and the path must be added to `extra_packages`.
"""

git_source: Optional[ReasoningEngineSpecSourceCodeSpecGitSourceDict]
"""Specifies the public Git repository to fetch the source code from. This includes the URL, revision, and directory to use."""


CreateRuntimeConfigOrDict = Union[CreateRuntimeConfig, CreateRuntimeConfigDict]

Expand Down Expand Up @@ -10420,6 +10427,10 @@ class UpdateRuntimeConfig(_common.BaseModel):
subdirectory and the path must be added to `extra_packages`.
""",
)
git_source: Optional[ReasoningEngineSpecSourceCodeSpecGitSource] = Field(
default=None,
description="""Specifies the public Git repository to fetch the source code from. This includes the URL, revision, and directory to use.""",
)
update_mask: Optional[str] = Field(
default=None,
description="""The update mask to apply. For the `FieldMask` definition, see
Expand Down Expand Up @@ -10570,6 +10581,9 @@ class UpdateRuntimeConfigDict(TypedDict, total=False):
subdirectory and the path must be added to `extra_packages`.
"""

git_source: Optional[ReasoningEngineSpecSourceCodeSpecGitSourceDict]
"""Specifies the public Git repository to fetch the source code from. This includes the URL, revision, and directory to use."""

update_mask: Optional[str]
"""The update mask to apply. For the `FieldMask` definition, see
https://protobuf.dev/reference/protobuf/google.protobuf/#field-mask."""
Expand Down Expand Up @@ -33290,6 +33304,10 @@ class AgentRuntimeConfig(_common.BaseModel):
replaces the deployed card; pass `{}` to remove it. The service sets
the card's `url` to the runtime's A2A endpoint.""",
)
git_source: Optional[ReasoningEngineSpecSourceCodeSpecGitSource] = Field(
default=None,
description="""Specifies the public Git repository to fetch the source code from. This includes the URL, revision, and directory to use.""",
)


class AgentRuntimeConfigDict(TypedDict, total=False):
Expand Down Expand Up @@ -33489,6 +33507,9 @@ class AgentRuntimeConfigDict(TypedDict, total=False):
replaces the deployed card; pass `{}` to remove it. The service sets
the card's `url` to the runtime's A2A endpoint."""

git_source: Optional[ReasoningEngineSpecSourceCodeSpecGitSourceDict]
"""Specifies the public Git repository to fetch the source code from. This includes the URL, revision, and directory to use."""


AgentRuntimeConfigOrDict = Union[AgentRuntimeConfig, AgentRuntimeConfigDict]

Expand Down
Loading
Loading