fix(cli): add publish endpoint option#327
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 |
There was a problem hiding this comment.
Pull request overview
This PR fixes the Python CLI publish command so the documented kubectl agentcube publish --endpoint flag is accepted and forwarded into PublishRuntime.publish() under the agent_endpoint option key (which the runtime already consumes).
Changes:
- Add
--endpointoption to the Typerpublishcommand. - Forward the CLI option as
agent_endpointin theoptionsdict passed toPublishRuntime.publish. - Add a Typer-based CLI test that asserts
--endpointis forwarded correctly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/cli/agentcube/cli/main.py | Adds --endpoint to publish and forwards it as agent_endpoint into the runtime options. |
| cmd/cli/tests/test_cli_publish.py | Adds a CLI test verifying --endpoint is passed through to PublishRuntime as agent_endpoint. |
There was a problem hiding this comment.
Code Review
This pull request introduces a new --endpoint CLI option to the publish command, allowing users to specify a custom API endpoint for AgentCube or Kubernetes clusters. This value is correctly forwarded to the PublishRuntime. Additionally, a new test file was added to verify this functionality. Feedback was provided to improve the test mock's robustness by using .get() for dictionary access to prevent potential KeyError exceptions when the endpoint option is omitted.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #327 +/- ##
==========================================
+ Coverage 47.57% 47.74% +0.17%
==========================================
Files 30 30
Lines 2819 2855 +36
==========================================
+ Hits 1341 1363 +22
- Misses 1338 1344 +6
- Partials 140 148 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| "provider": provider, | ||
| "node_port": node_port, | ||
| "replicas": replicas, | ||
| "agent_endpoint": endpoint, |
There was a problem hiding this comment.
Can we also persist this value in the AgentCube publish path? PublishRuntime._publish_cr_to_k8s returns agent_endpoint, but its metadata update only writes agent_id and k8s_deployment; a later agentcube invoke still reads metadata.agent_endpoint, so publishing with --endpoint can succeed and then invoke fails unless the metadata already had an endpoint.
There was a problem hiding this comment.
Thank you so much for the review and catching this @acsoto .
I updated the AgentCube publish path to persist the endpoint passed via --endpoint into metadata as agent_endpoint. I also added a runtime test to cover this path, so a later invoke can read the saved endpoint from metadata.
Signed-off-by: Mrinal Chaturvedi <mrinal.chaturvedi27@gmail.com>
Signed-off-by: Mrinal Chaturvedi <mrinal.chaturvedi27@gmail.com>
Signed-off-by: Mrinal Chaturvedi <mrinal.chaturvedi27@gmail.com>
95c6685 to
26535f2
Compare
|
Hi @acsoto @YaoZengzeng quick ping for this PR :) |
| endpoint: Optional[str] = typer.Option( | ||
| None, | ||
| "--endpoint", | ||
| help="Custom API endpoint for AgentCube or Kubernetes cluster", |
There was a problem hiding this comment.
Nit: this reads like a Kubernetes API server endpoint, but the value is stored as agent_endpoint and later used as the base URL for invoking the published agent. Can we make the help text say that more directly?
| except Exception as e: | ||
| raise RuntimeError(f"Failed to deploy AgentRuntime CR to K8s: {str(e)}") | ||
|
|
||
| endpoint = options.get('agent_endpoint') or metadata.agent_endpoint |
There was a problem hiding this comment.
Can we resolve and validate this before calling deploy_agent_runtime? If neither --endpoint nor metadata.agent_endpoint is set, publish currently creates the AgentRuntime CR and then fails before updating metadata, leaving the cluster state ahead of the workspace state.
hzxuzhonghu
left a comment
There was a problem hiding this comment.
cmd/cli/agentcube/cli/main.py
- Lines 306-310: The
--endpointoption is clean. It is passed asagent_endpointin the options dict.
cmd/cli/agentcube/runtime/publish_runtime.py
- Lines 174-176: Moving the endpoint resolution and validation before the metadata update (Step 4) is a good improvement. In the original code, the endpoint check happened after
update_metadata, meaning a missing endpoint would leave stale partial metadata. Now it fails early and cleanly.
cmd/cli/tests/test_cli_publish.py
- Good end-to-end test using a stub
PublishRuntimeto verify the--endpointflag is forwarded correctly.
LGTM.
What type of PR is this?
/kind bug
What this PR does / why we need it:
This makes the documented
kubectl agentcube publish --endpointoption work. The CLI passes it toPublishRuntimeasagent_endpoint, and the AgentCube publish path saves it in metadata so later commands likeinvokecan read it.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
I found this while working on PR #325. This adds a CLI test for the option pass-through and a runtime test to check that the endpoint is saved in metadata.
What I fixed
I fixed the Python CLI publish command so
kubectl agentcube publish --endpointworks as documented. The endpoint is now passed to the runtime and saved in metadata.How I found it
I found this while working on PR #325. I checked the README section for
publish, then looked atcmd/cli/agentcube/cli/main.pyandcmd/cli/agentcube/runtime/publish_runtime.py. The runtime already checkedoptions.get('agent_endpoint'), but the CLI did not expose the option. A review also pointed out that the AgentCube publish path returned the endpoint but did not save it in metadata.What I changed
--endpointto thepublishcommand options.PublishRuntime.publishasagent_endpoint.agent_endpointin metadata in the AgentCube publish path.publish --endpoint.Why this is legit
This matches the README and keeps
publishandinvokebehavior consistent. It is a small Python CLI/runtime change and does not touch Kubernetes resources, Go code, generated files, or chart templates.Tests