mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
### Summary
This PR introduces a subcommand implementation that allows `langgraph
deploy list` and `langgraph deploy delete` subcommands.
#### `langgraph deploy list`
```bash
(env) andrewnguonly@Andrew-Nguonly-KC23X90J02 langgraph % langgraph deploy list --help ⎈ gke_langchain-test-387119_us-west1_langgraph-cloud-us-west1
Usage: langgraph deploy list [OPTIONS]
[Beta] List LangSmith Deployments.
Options:
--name-contains TEXT Only show deployments whose names contain this value.
--api-key TEXT API key. Can also be set via LANGGRAPH_HOST_API_KEY,
LANGSMITH_API_KEY, or LANGCHAIN_API_KEY environment
variable or .env file.
--help Show this message and exit.
```
Output example:
```bash
(env) andrewnguonly@Andrew-Nguonly-KC23X90J02 cli % langgraph deploy list
Deployment ID Deployment Name Deployment URL
------------------------------------ -------------------------- ------------------------------------------------------------------------------------
a40d6567-87c0-485a-a23d-94309a7d4519 ht-andrew-test-04 -
9da26acb-d0c9-4af0-af9e-f3fe8dfe85bc ht-anirudh-deployment-test https://ht-anirudh-deployment-test-428af4737f8a533cb2b107587eb8f38f.us.langgraph.app
```
#### `langgraph deploy delete`
```bash
(env) andrewnguonly@Andrew-Nguonly-KC23X90J02 langgraph % langgraph deploy delete --help ⎈ gke_langchain-test-387119_us-west1_langgraph-cloud-us-west1
Usage: langgraph deploy delete [OPTIONS] DEPLOYMENT_ID
[Beta] Delete a LangSmith Deployment.
Options:
--force Delete without prompting for confirmation.
--api-key TEXT API key. Can also be set via LANGGRAPH_HOST_API_KEY,
LANGSMITH_API_KEY, or LANGCHAIN_API_KEY environment variable
or .env file.
--help Show this message and exit.
```
Output example:
```bash
(env) andrewnguonly@Andrew-Nguonly-KC23X90J02 cli % langgraph deploy delete a40d6567-87c0-485a-a23d-94309a7d4519
Are you sure you want to delete deployment ID a40d6567-87c0-485a-a23d-94309a7d4519? (Y/n): Y
Host API key:
Deleted deployment a40d6567-87c0-485a-a23d-94309a7d4519.
```
```bash
(env) andrewnguonly@Andrew-Nguonly-KC23X90J02 cli % langgraph deploy delete a40d6567-87c0-485a-a23d-94309a7d4519
Are you sure you want to delete deployment ID a40d6567-87c0-485a-a23d-94309a7d4519? (Y/n): n
Aborted!
```
```bash
(env) andrewnguonly@Andrew-Nguonly-KC23X90J02 cli % langgraph deploy delete 9da26acb-d0c9-4af0-af9e-f3fe8dfe85bc --force
Host API key:
Deleted deployment 9da26acb-d0c9-4af0-af9e-f3fe8dfe85bc.
```
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
from collections.abc import Sequence
|
|
|
|
import click
|
|
|
|
|
|
def clean_empty_lines(input_str: str):
|
|
return "\n".join(filter(None, input_str.splitlines()))
|
|
|
|
|
|
def warn_non_wolfi_distro(config_json: dict) -> None:
|
|
"""Show warning if image_distro is not set to 'wolfi'."""
|
|
image_distro = config_json.get("image_distro", "debian") # Default is debian
|
|
if image_distro != "wolfi":
|
|
click.secho(
|
|
"⚠️ Security Recommendation: Consider switching to Wolfi Linux for enhanced security.",
|
|
fg="yellow",
|
|
bold=True,
|
|
)
|
|
click.secho(
|
|
" Wolfi is a security-oriented, minimal Linux distribution designed for containers.",
|
|
fg="yellow",
|
|
)
|
|
click.secho(
|
|
' To switch, add \'"image_distro": "wolfi"\' to your langgraph.json config file.',
|
|
fg="yellow",
|
|
)
|
|
click.secho("") # Empty line for better readability
|
|
|
|
|
|
def _extract_deployment_url(deployment: dict[str, object]) -> str:
|
|
source_config = deployment.get("source_config")
|
|
if isinstance(source_config, dict):
|
|
custom_url = source_config.get("custom_url")
|
|
if isinstance(custom_url, str) and custom_url:
|
|
return custom_url
|
|
return "-"
|
|
|
|
|
|
def format_deployments_table(deployments: Sequence[dict[str, object]]) -> str:
|
|
headers = ("Deployment ID", "Deployment Name", "Deployment URL")
|
|
rows = [
|
|
(
|
|
str(deployment.get("id", "-") or "-"),
|
|
str(deployment.get("name", "-") or "-"),
|
|
_extract_deployment_url(deployment),
|
|
)
|
|
for deployment in deployments
|
|
]
|
|
widths = [
|
|
max(len(headers[index]), *(len(row[index]) for row in rows))
|
|
for index in range(len(headers))
|
|
]
|
|
|
|
def format_row(row: Sequence[str]) -> str:
|
|
return " ".join(value.ljust(widths[index]) for index, value in enumerate(row))
|
|
|
|
lines = [format_row(headers), format_row(tuple("-" * width for width in widths))]
|
|
lines.extend(format_row(row) for row in rows)
|
|
return "\n".join(lines)
|