Skip to content
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

[CLI] Add auth param to langgraph.json #2762

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions libs/cli/langgraph_cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os

Check notice on line 1 in libs/cli/langgraph_cli/cli.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... fanout_to_subgraph_10x: Mean +- std dev: 61.5 ms +- 1.4 ms ......................................... fanout_to_subgraph_10x_sync: Mean +- std dev: 52.2 ms +- 0.5 ms ......................................... fanout_to_subgraph_10x_checkpoint: Mean +- std dev: 74.3 ms +- 1.3 ms ......................................... fanout_to_subgraph_10x_checkpoint_sync: Mean +- std dev: 94.4 ms +- 1.5 ms ......................................... fanout_to_subgraph_100x: Mean +- std dev: 609 ms +- 25 ms ......................................... fanout_to_subgraph_100x_sync: Mean +- std dev: 513 ms +- 7 ms ......................................... fanout_to_subgraph_100x_checkpoint: Mean +- std dev: 753 ms +- 17 ms ......................................... fanout_to_subgraph_100x_checkpoint_sync: Mean +- std dev: 962 ms +- 26 ms ......................................... react_agent_10x: Mean +- std dev: 31.3 ms +- 0.6 ms ......................................... react_agent_10x_sync: Mean +- std dev: 23.0 ms +- 0.4 ms ......................................... react_agent_10x_checkpoint: Mean +- std dev: 38.3 ms +- 0.7 ms ......................................... react_agent_10x_checkpoint_sync: Mean +- std dev: 37.2 ms +- 0.7 ms ......................................... react_agent_100x: Mean +- std dev: 341 ms +- 6 ms ......................................... react_agent_100x_sync: Mean +- std dev: 275 ms +- 3 ms ......................................... react_agent_100x_checkpoint: Mean +- std dev: 871 ms +- 20 ms ......................................... react_agent_100x_checkpoint_sync: Mean +- std dev: 855 ms +- 14 ms ......................................... wide_state_25x300: Mean +- std dev: 23.1 ms +- 0.6 ms ......................................... wide_state_25x300_sync: Mean +- std dev: 14.9 ms +- 0.2 ms ......................................... wide_state_25x300_checkpoint: Mean +- std dev: 276 ms +- 15 ms ......................................... wide_state_25x300_checkpoint_sync: Mean +- std dev: 275 ms +- 16 ms ......................................... wide_state_15x600: Mean +- std dev: 27.1 ms +- 0.8 ms ......................................... wide_state_15x600_sync: Mean +- std dev: 17.3 ms +- 0.1 ms ......................................... wide_state_15x600_checkpoint: Mean +- std dev: 472 ms +- 14 ms ......................................... wide_state_15x600_checkpoint_sync: Mean +- std dev: 472 ms +- 15 ms ......................................... wide_state_9x1200: Mean +- std dev: 26.9 ms +- 0.6 ms ......................................... wide_state_9x1200_sync: Mean +- std dev: 17.2 ms +- 0.3 ms ......................................... wide_state_9x1200_checkpoint: Mean +- std dev: 308 ms +- 13 ms ......................................... wide_state_9x1200_checkpoint_sync: Mean +- std dev: 306 ms +- 13 ms

Check notice on line 1 in libs/cli/langgraph_cli/cli.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------+---------+-----------------------+ | Benchmark | main | changes | +=========================================+=========+=======================+ | wide_state_15x600_checkpoint | 487 ms | 472 ms: 1.03x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_9x1200_checkpoint | 317 ms | 308 ms: 1.03x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_checkpoint | 283 ms | 276 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint | 769 ms | 753 ms: 1.02x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint | 75.1 ms | 74.3 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_10x_checkpoint_sync | 95.2 ms | 94.4 ms: 1.01x faster | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600_sync | 17.3 ms | 17.3 ms: 1.00x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint | 38.1 ms | 38.3 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_sync | 511 ms | 513 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300 | 23.0 ms | 23.1 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_checkpoint_sync | 37.0 ms | 37.2 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x_sync | 22.9 ms | 23.0 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_15x600 | 26.8 ms | 27.1 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | wide_state_25x300_sync | 14.7 ms | 14.9 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | fanout_to_subgraph_100x_checkpoint_sync | 950 ms | 962 ms: 1.01x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_10x | 30.9 ms | 31.3 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint_sync | 835 ms | 855 ms: 1.02x slower | +-----------------------------------------+---------+-----------------------+ | react_agent_100x_checkpoint | 840 ms | 871 ms: 1.04x slower | +-----------------------------------------+---------+-----------------------+ | Geometric mean | (ref) | 1.00x slower | +-----------------------------------------+---------+-----------------------+ Benchmark hidden because not significant (10): fanout_to_subgraph_100x, wide_state_15x600_checkpoint_sync, wide_state_9x1200_checkpoint_sync, react_agent_100x, fanout_to_subgraph_10x_sync, wide_state_9x1200, wide_state_9x1200_sync, react_agent_100x_sync, wide_state_25x300_checkpoint_sync, fanout_to_subgraph_10x
import pathlib
import shutil
import sys
Expand Down Expand Up @@ -576,16 +576,18 @@
from langgraph_api.cli import run_server
except ImportError:
try:
import pkg_resources

pkg_resources.require("langgraph-api-inmem")
except (ImportError, pkg_resources.DistributionNotFound):
from importlib import util

if not util.find_spec("langgraph_api"):
raise click.UsageError(
"Required package 'langgraph-api' is not installed.\n"
"Please install it with:\n\n"
' pip install -U "langgraph-cli[inmem]"\n\n'
) from None
except ImportError:
raise click.UsageError(
"Required package 'langgraph-api-inmem' is not installed.\n"
"Please install it with:\n\n"
' pip install -U "langgraph-cli[inmem]"\n\n'
"If you're developing the langgraph-cli package locally, you can install in development mode:\n"
" pip install -e ."
"Could not verify package installation. Please ensure Python is up to date and\n"
"langgraph-cli is installed with the 'inmem' extra: pip install -U \"langgraph-cli[inmem]\""
) from None
raise click.UsageError(
"Could not import run_server. This likely means your installation is incomplete.\n"
Expand Down Expand Up @@ -614,6 +616,7 @@
env=config_json.get("env"),
store=config_json.get("store"),
wait_for_client=wait_for_client,
auth=config_json.get("auth"),
)


Expand Down
16 changes: 16 additions & 0 deletions libs/cli/langgraph_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class StoreConfig(TypedDict, total=False):
"""Configuration for vector embeddings in store."""


class AuthConfig(TypedDict, total=False):
path: str
disable_studio_auth: bool


class Config(TypedDict, total=False):
python_version: str
node_version: Optional[str]
Expand All @@ -56,6 +61,7 @@ class Config(TypedDict, total=False):
graphs: dict[str, str]
env: Union[dict[str, str], str]
store: Optional[StoreConfig]
auth: Optional[AuthConfig]


def _parse_version(version_str: str) -> tuple[int, int]:
Expand Down Expand Up @@ -88,6 +94,7 @@ def validate_config(config: Config) -> Config:
"graphs": config.get("graphs", {}),
"env": config.get("env", {}),
"store": config.get("store"),
"auth": config.get("auth"),
}
if config.get("node_version")
else {
Expand All @@ -98,6 +105,7 @@ def validate_config(config: Config) -> Config:
"graphs": config.get("graphs", {}),
"env": config.get("env", {}),
"store": config.get("store"),
"auth": config.get("auth"),
}
)

Expand Down Expand Up @@ -400,6 +408,10 @@ def python_config_to_docker(config_path: pathlib.Path, config: Config, base_imag
ENV LANGGRAPH_STORE='{json.dumps(store_config)}'
"""
)
if (auth_config := config.get("auth")) is not None:
env_additional_config += f"""
ENV LANGGRAPH_AUTH='{json.dumps(auth_config)}'
"""
return f"""FROM {base_image}:{config['python_version']}

{os.linesep.join(config["dockerfile_lines"])}
Expand Down Expand Up @@ -445,6 +457,10 @@ def test_file(file_name):
ENV LANGGRAPH_STORE='{json.dumps(store_config)}'
"""
)
if (auth_config := config.get("auth")) is not None:
env_additional_config += f"""
ENV LANGGRAPH_AUTH='{json.dumps(auth_config)}'
"""
return f"""FROM {base_image}:{config['node_version']}

{os.linesep.join(config["dockerfile_lines"])}
Expand Down
Loading
Loading