|
|
@@ -12,6 +12,7 @@ from collections.abc import Callable, Mapping, Sequence
|
|
|
|
from contextlib import contextmanager
|
|
|
|
from contextlib import contextmanager
|
|
|
|
from dataclasses import asdict, dataclass, field
|
|
|
|
from dataclasses import asdict, dataclass, field
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
|
|
from functools import partial
|
|
|
|
from typing import Protocol, TypeVar
|
|
|
|
from typing import Protocol, TypeVar
|
|
|
|
|
|
|
|
|
|
|
|
import click
|
|
|
|
import click
|
|
|
@@ -1690,11 +1691,18 @@ OPT_HOST_URL = click.option(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
OPT_AGENT_ID = click.option(
|
|
|
|
OPT_AGENT_ID = click.option(
|
|
|
|
"--agent-id", help="Logical agent ID (requires agent mode enabled for the tenant)."
|
|
|
|
"--agent-id",
|
|
|
|
|
|
|
|
envvar="LANGSMITH_AGENT_ID",
|
|
|
|
|
|
|
|
show_envvar=True,
|
|
|
|
|
|
|
|
help="Logical agent ID (requires agent mode enabled for the tenant).",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
OPT_AGENT_ENVIRONMENT = click.option(
|
|
|
|
OPT_AGENT_ENVIRONMENT = partial(
|
|
|
|
"--environment",
|
|
|
|
click.option,
|
|
|
|
|
|
|
|
"--agent-environment",
|
|
|
|
|
|
|
|
"environment",
|
|
|
|
|
|
|
|
envvar="LANGSMITH_AGENT_ENVIRONMENT",
|
|
|
|
|
|
|
|
show_envvar=True,
|
|
|
|
type=click.Choice(["development", "staging", "production"]),
|
|
|
|
type=click.Choice(["development", "staging", "production"]),
|
|
|
|
help="Agent environment (requires agent mode enabled for the tenant).",
|
|
|
|
help="Agent environment (requires agent mode enabled for the tenant).",
|
|
|
|
)
|
|
|
|
)
|
|
|
@@ -1798,7 +1806,9 @@ def _deploy_base_options(
|
|
|
|
OPT_HOST_API_KEY,
|
|
|
|
OPT_HOST_API_KEY,
|
|
|
|
OPT_HOST_DEPLOYMENT_NAME,
|
|
|
|
OPT_HOST_DEPLOYMENT_NAME,
|
|
|
|
OPT_AGENT_ID,
|
|
|
|
OPT_AGENT_ID,
|
|
|
|
OPT_AGENT_ENVIRONMENT,
|
|
|
|
OPT_AGENT_ENVIRONMENT()
|
|
|
|
|
|
|
|
if include_docker_args
|
|
|
|
|
|
|
|
else OPT_AGENT_ENVIRONMENT(type=str),
|
|
|
|
click.option(
|
|
|
|
click.option(
|
|
|
|
"--deployment-id",
|
|
|
|
"--deployment-id",
|
|
|
|
help=(
|
|
|
|
help=(
|
|
|
@@ -1930,6 +1940,12 @@ def deploy(ctx: click.Context, **_: object):
|
|
|
|
# otherwise, we return None here and click will proceed to actually run the subcommand (list or delete)
|
|
|
|
# otherwise, we return None here and click will proceed to actually run the subcommand (list or delete)
|
|
|
|
if ctx.invoked_subcommand is not None:
|
|
|
|
if ctx.invoked_subcommand is not None:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
environment_param = next(
|
|
|
|
|
|
|
|
param for param in _deploy_cmd.params if param.name == "environment"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
ctx.params["environment"] = environment_param.type_cast_value(
|
|
|
|
|
|
|
|
ctx, ctx.params["environment"]
|
|
|
|
|
|
|
|
)
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
ctx.params.get("agent_id") is not None
|
|
|
|
ctx.params.get("agent_id") is not None
|
|
|
|
or ctx.params.get("environment") is not None
|
|
|
|
or ctx.params.get("environment") is not None
|
|
|
@@ -1982,13 +1998,14 @@ def _deploy_cmd(
|
|
|
|
validate_deploy_commands(install_command, build_command)
|
|
|
|
validate_deploy_commands(install_command, build_command)
|
|
|
|
agent = None
|
|
|
|
agent = None
|
|
|
|
if agent_id is not None or environment is not None:
|
|
|
|
if agent_id is not None or environment is not None:
|
|
|
|
|
|
|
|
em.note("Note: --agent-id and --agent-environment flags are in private beta")
|
|
|
|
if not agent_id or not agent_id.strip() or not environment:
|
|
|
|
if not agent_id or not agent_id.strip() or not environment:
|
|
|
|
raise click.UsageError(
|
|
|
|
raise click.UsageError(
|
|
|
|
"--agent-id and --environment are required together."
|
|
|
|
"--agent-id and --agent-environment are required together."
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if name is not None or deployment_id is not None:
|
|
|
|
if name is not None or deployment_id is not None:
|
|
|
|
raise click.UsageError(
|
|
|
|
raise click.UsageError(
|
|
|
|
"--agent-id and --environment cannot be combined with --name or --deployment-id."
|
|
|
|
"--agent-id and --agent-environment cannot be combined with --name or --deployment-id."
|
|
|
|
)
|
|
|
|
)
|
|
|
|
agent = {"agent_id": agent_id, "environment": environment}
|
|
|
|
agent = {"agent_id": agent_id, "environment": environment}
|
|
|
|
if not config.exists():
|
|
|
|
if not config.exists():
|
|
|
@@ -2124,7 +2141,7 @@ def _deploy_cmd(
|
|
|
|
@OPT_HOST_API_KEY
|
|
|
|
@OPT_HOST_API_KEY
|
|
|
|
@OPT_HOST_URL
|
|
|
|
@OPT_HOST_URL
|
|
|
|
@OPT_AGENT_ID
|
|
|
|
@OPT_AGENT_ID
|
|
|
|
@OPT_AGENT_ENVIRONMENT
|
|
|
|
@OPT_AGENT_ENVIRONMENT()
|
|
|
|
@click.option(
|
|
|
|
@click.option(
|
|
|
|
"--name-contains",
|
|
|
|
"--name-contains",
|
|
|
|
default="",
|
|
|
|
default="",
|
|
|
@@ -2138,6 +2155,11 @@ def deploy_list(
|
|
|
|
agent_id: str | None,
|
|
|
|
agent_id: str | None,
|
|
|
|
environment: str | None,
|
|
|
|
environment: str | None,
|
|
|
|
) -> None:
|
|
|
|
) -> None:
|
|
|
|
|
|
|
|
if agent_id is not None or environment is not None:
|
|
|
|
|
|
|
|
click.secho(
|
|
|
|
|
|
|
|
"Note: --agent-id and --agent-environment flags are in private beta",
|
|
|
|
|
|
|
|
fg="yellow",
|
|
|
|
|
|
|
|
)
|
|
|
|
if agent_id is not None and not agent_id.strip():
|
|
|
|
if agent_id is not None and not agent_id.strip():
|
|
|
|
raise click.UsageError("--agent-id must not be empty.")
|
|
|
|
raise click.UsageError("--agent-id must not be empty.")
|
|
|
|
filters = {}
|
|
|
|
filters = {}
|
|
|
|