-
Notifications
You must be signed in to change notification settings - Fork 69
fix(cli): add publish endpoint option #327
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,6 +303,11 @@ def publish( | |
| "--replicas", | ||
| help="Number of replicas for K8s deployment (default: 1)", | ||
| ), | ||
| endpoint: Optional[str] = typer.Option( | ||
| None, | ||
| "--endpoint", | ||
| help="Custom API endpoint for AgentCube or Kubernetes cluster", | ||
| ), | ||
| namespace: Optional[str] = typer.Option( | ||
| None, | ||
| "--namespace", | ||
|
|
@@ -339,9 +344,10 @@ def publish( | |
| "description": description, | ||
| "region": region, | ||
| "cloud_provider": cloud_provider, | ||
| "provider": provider, # Pass provider down | ||
| "provider": provider, | ||
| "node_port": node_port, | ||
| "replicas": replicas, | ||
| "agent_endpoint": endpoint, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also persist this value in the AgentCube publish path?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you so much for the review and catching this @acsoto . |
||
| "namespace": namespace, | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,20 +171,20 @@ def _publish_cr_to_k8s( | |
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we resolve and validate this before calling |
||
| if not endpoint: | ||
| raise ValueError("Please enter the endpoint for the agent") | ||
|
|
||
| # Step 4: Update metadata with K8s deployment information | ||
| updates = { | ||
| "agent_id": k8s_info["deployment_name"], | ||
| "agent_endpoint": endpoint, | ||
| "k8s_deployment": { | ||
| **k8s_info, | ||
| "type": "AgentRuntime", | ||
| } | ||
| } | ||
|
|
||
| # Use provided endpoint or fall back to router_url from metadata | ||
| endpoint = options.get('agent_endpoint') or metadata.agent_endpoint | ||
| if not endpoint: | ||
| raise ValueError("Please enter the endpoint for the agent") | ||
|
|
||
| self.metadata_service.update_metadata(workspace_path, updates) | ||
|
|
||
| result = { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Copyright The Volcano Authors. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from typer.testing import CliRunner | ||
|
|
||
| from agentcube.cli.main import app | ||
|
|
||
|
|
||
| def test_publish_endpoint_option_is_forwarded(monkeypatch, tmp_path): | ||
| call = {} | ||
|
|
||
| class StubPublishRuntime: | ||
| def __init__(self, verbose=False, provider="agentcube"): | ||
| call["verbose"] = verbose | ||
| call["provider"] = provider | ||
|
|
||
| def publish(self, workspace_path, **options): | ||
| call["workspace_path"] = workspace_path | ||
| call["options"] = options | ||
| return { | ||
| "agent_name": "test-agent", | ||
| "agent_id": "test-agent", | ||
| "agent_endpoint": options["agent_endpoint"], | ||
| "namespace": options.get("namespace", "default"), | ||
| "status": "deployed", | ||
| } | ||
|
|
||
| monkeypatch.setattr("agentcube.cli.main.PublishRuntime", StubPublishRuntime) | ||
|
|
||
| result = CliRunner().invoke( | ||
| app, | ||
| [ | ||
| "publish", | ||
| "-f", | ||
| str(tmp_path), | ||
| "--endpoint", | ||
| "http://router.example.com", | ||
| ], | ||
| ) | ||
|
|
||
| assert result.exit_code == 0, result.output | ||
| assert call["provider"] == "agentcube" | ||
| assert call["workspace_path"] == tmp_path.resolve() | ||
| assert call["options"]["agent_endpoint"] == "http://router.example.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this reads like a Kubernetes API server endpoint, but the value is stored as
agent_endpointand later used as the base URL for invoking the published agent. Can we make the help text say that more directly?