cli: Implement cloud build functionality in BuildRuntime#435
cli: Implement cloud build functionality in BuildRuntime#435singhshresth26 wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @singhshresth26! It looks like this is your first PR to volcano-sh/agentcube 🎉 |
There was a problem hiding this comment.
Code Review
This pull request implements the cloud build functionality in _build_cloud for BuildRuntime and adds corresponding unit tests. The feedback suggests returning the fully qualified image name (including the tag) instead of just the registry URL in _build_cloud to maintain consistency with local builds, and updating the unit test assertions accordingly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| return { | ||
| "image_name": registry_url, | ||
| "image_tag": tag, | ||
| "image_size": build_size, | ||
| "build_time": build_time, | ||
| "build_mode": "cloud" | ||
| } |
There was a problem hiding this comment.
The return dictionary for _build_cloud returns registry_url as the image_name. However, in _build_local, the returned image_name is the fully qualified image name including the tag (e.g., image_name:tag). To maintain consistency across local and cloud build modes, _build_cloud should return the fully qualified image_name (which is already constructed on line 227 as f"{registry_url}:{tag}") instead of just the registry_url.
| return { | |
| "image_name": registry_url, | |
| "image_tag": tag, | |
| "image_size": build_size, | |
| "build_time": build_time, | |
| "build_mode": "cloud" | |
| } | |
| return { | |
| "image_name": image_name, | |
| "image_tag": tag, | |
| "image_size": build_size, | |
| "build_time": build_time, | |
| "build_mode": "cloud" | |
| } |
| assert result["build_mode"] == "cloud" | ||
| assert result["image_name"] == "swr.cn-east-3.myhuaweicloud.com/agentcube/test-agent" | ||
| assert result["image_tag"] == "0.0.3" |
There was a problem hiding this comment.
Update the test assertion to expect the fully qualified image name (including the tag) to align with the consistency improvement in _build_cloud.
| assert result["build_mode"] == "cloud" | |
| assert result["image_name"] == "swr.cn-east-3.myhuaweicloud.com/agentcube/test-agent" | |
| assert result["image_tag"] == "0.0.3" | |
| assert result["build_mode"] == "cloud" | |
| assert result["image_name"] == "swr.cn-east-3.myhuaweicloud.com/agentcube/test-agent:0.0.3" | |
| assert result["image_tag"] == "0.0.3" |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #435 +/- ##
==========================================
+ Coverage 58.41% 58.56% +0.14%
==========================================
Files 36 36
Lines 3463 3463
==========================================
+ Hits 2023 2028 +5
+ Misses 1231 1227 -4
+ Partials 209 208 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a simulated cloud build path to the AgentCube CLI BuildRuntime so users can run agentcube build with --build-mode cloud and have the CLI resolve a cloud registry destination and persist build information into agent_metadata.yaml.
Changes:
- Implemented
_build_cloud()inBuildRuntimeto simulate a remote build and update metadata with cloud build details. - Added unit tests covering local and cloud build flows.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
cmd/cli/agentcube/runtime/build_runtime.py |
Implements the cloud build strategy and metadata persistence for cloud builds. |
cmd/cli/tests/test_build_runtime.py |
Adds tests for both local and cloud build paths. |
|
|
||
| # For MVP, fall back to local build | ||
| return self._build_local(workspace_path, metadata, options) | ||
| cloud_provider = options.get("cloud_provider") or metadata.region or "huawei" |
| image_info = { | ||
| "repository_url": registry_url, | ||
| "tag": tag, | ||
| "build_mode": "cloud", | ||
| "build_size": build_size, | ||
| "build_time": build_time | ||
| } | ||
| updates = {"image": image_info} | ||
| self.metadata_service.update_metadata(workspace_path, updates) | ||
|
|
||
| return { | ||
| "image_name": registry_url, | ||
| "image_tag": tag, | ||
| "image_size": build_size, | ||
| "build_time": build_time, | ||
| "build_mode": "cloud" | ||
| } |
| "agent_name": "test-agent", | ||
| "entrypoint": "python main.py", | ||
| "build_mode": "local", | ||
| "version": "0.0.1", |
| assert result["build_mode"] == "cloud" | ||
| assert result["image_name"] == "swr.cn-east-3.myhuaweicloud.com/agentcube/test-agent" | ||
| assert result["image_tag"] == "0.0.3" | ||
|
|
||
| # Check metadata got updated with cloud build mode | ||
| metadata = runtime.metadata_service.load_metadata(ws) | ||
| assert metadata.image is not None | ||
| assert metadata.image["build_mode"] == "cloud" | ||
| assert metadata.image["repository_url"] == "swr.cn-east-3.myhuaweicloud.com/agentcube/test-agent" | ||
| assert metadata.image["tag"] == "0.0.3" |
| # If registry_url is defined, use it. Otherwise construct a cloud SWR registry URL. | ||
| registry_url = metadata.registry_url | ||
| if not registry_url: | ||
| region = metadata.region or "cn-east-3" | ||
| registry_url = f"swr.{region}.myhuaweicloud.com/agentcube/{agent_name}" | ||
|
|
||
| image_name = f"{registry_url}:{tag}" |
| cloud_provider = options.get("cloud_provider") or "huawei" | ||
|
|
||
| logger.info(f"Initiating cloud build using provider: {cloud_provider}") | ||
| logger.info(f"Packaging workspace {workspace_path} for cloud build...") | ||
| logger.info(f"Uploading workspace to {cloud_provider} build service...") |
| with tempfile.TemporaryDirectory() as tmpdir: | ||
| ws = Path(tmpdir) | ||
| self._write_yaml(ws / "agent_metadata.yaml", { | ||
| "agent_name": "test-agent", | ||
| "entrypoint": "python main.py", | ||
| "build_mode": "cloud", | ||
| "version": "0.0.2", | ||
| }) | ||
| (ws / "main.py").touch() | ||
| (ws / "requirements.txt").touch() | ||
| (ws / "Dockerfile").touch() | ||
|
|
||
| runtime = BuildRuntime(verbose=True) | ||
| result = runtime.build(ws, cloud_provider="huawei") | ||
|
|
||
| assert result["build_mode"] == "cloud" | ||
| assert result["image_name"] == "swr.cn-east-3.myhuaweicloud.com/agentcube/test-agent:0.0.3" | ||
| assert result["image_tag"] == "0.0.3" | ||
|
|
||
| # Check metadata got updated with cloud build mode | ||
| metadata = runtime.metadata_service.load_metadata(ws) | ||
| assert metadata.image is not None | ||
| assert metadata.image["build_mode"] == "cloud" | ||
| assert metadata.image["repository_url"] == "swr.cn-east-3.myhuaweicloud.com/agentcube/test-agent:0.0.3" | ||
| assert metadata.image["tag"] == "0.0.3" |
What type of PR is this?
/kind enhancement
What this PR does / why we need it:
This PR implements the simulated cloud build strategy (
_build_cloudmethod) in the CLIBuildRuntime.When a user specifies
--build-mode cloud(or configures it inagent_metadata.yaml), the CLI will:build_mode: cloudtoagent_metadata.yaml.It also adds comprehensive unit tests in
cmd/cli/tests/test_build_runtime.pycovering both the local and cloud build paths.Which issue(s) this PR fixes:
Fixes #434
Special notes for your reviewer:
This resolves the first code issue/TODO placeholder (
# TODO: Implement cloud build functionality) inbuild_runtime.py.Does this PR introduce a user-facing change?: