mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-26 11:35:02 +02:00
feat(cli): announce the listener a deployment is placed on
This commit is contained in:
@@ -172,6 +172,10 @@ class Listener:
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class Unplaced:
|
||||
@property
|
||||
def summary(self) -> str:
|
||||
return ""
|
||||
|
||||
def source_config(self) -> dict[str, object]:
|
||||
return {}
|
||||
|
||||
@@ -181,6 +185,13 @@ class OnListener:
|
||||
listener_id: str
|
||||
k8s_namespace: str
|
||||
|
||||
@property
|
||||
def summary(self) -> str:
|
||||
return (
|
||||
f"Deploying through listener {self.listener_id} "
|
||||
f"in namespace {self.k8s_namespace}"
|
||||
)
|
||||
|
||||
def source_config(self) -> dict[str, object]:
|
||||
return {
|
||||
"listener_id": self.listener_id,
|
||||
@@ -817,7 +828,6 @@ def _create_deployment(
|
||||
def _get_deployment_status_url(
|
||||
updated: object, deployment_id: str, endpoints: ControlPlaneEndpoints
|
||||
) -> str | None:
|
||||
"""Compute the LangSmith dashboard URL for a deployment, if possible."""
|
||||
tenant_id = updated.get("tenant_id") if isinstance(updated, dict) else None
|
||||
if not tenant_id:
|
||||
return None
|
||||
@@ -827,7 +837,6 @@ def _get_deployment_status_url(
|
||||
def _emit_deployment_status_url(
|
||||
updated: object, deployment_id: str, endpoints: ControlPlaneEndpoints
|
||||
) -> str | None:
|
||||
"""Emit the deployment status URL and return it."""
|
||||
url = _get_deployment_status_url(updated, deployment_id, endpoints)
|
||||
if url:
|
||||
_get_emitter().status_url(url)
|
||||
@@ -1526,6 +1535,8 @@ class CustomerRegistrySource:
|
||||
placement = self.placement.resolve(
|
||||
_available_listeners(ctx.client), required=ctx.endpoints.is_cloud
|
||||
)
|
||||
if placement.summary:
|
||||
_get_emitter().info(placement.summary)
|
||||
image_uri, step = self._publish(ctx, step)
|
||||
created, _ = _create_deployment(
|
||||
ctx.client,
|
||||
|
||||
@@ -810,3 +810,24 @@ def test_listener_flags_are_refused_on_an_existing_deployment(
|
||||
assert result.exit_code != 0
|
||||
assert "fixed when the deployment is created" in result.output
|
||||
assert deploy_project.docker.verbs() == []
|
||||
|
||||
|
||||
def test_automatic_placement_is_announced(deploy_project: DeployProject) -> None:
|
||||
deploy_project.control_plane.listeners = [LISTENER]
|
||||
|
||||
result = deploy_project.run(
|
||||
"--push-to", PUSH_REPOSITORY, host_url=CLOUD_CONTROL_PLANE_URL
|
||||
)
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "listener-1" in result.output
|
||||
assert "agents" in result.output
|
||||
|
||||
|
||||
def test_a_deployment_without_a_listener_announces_nothing(
|
||||
deploy_project: DeployProject,
|
||||
) -> None:
|
||||
result = deploy_project.run("--push-to", PUSH_REPOSITORY)
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "listener" not in result.output
|
||||
|
||||
Reference in New Issue
Block a user