[CLI] Validate node version (#2489)

This commit is contained in:
William FH
2024-11-20 17:24:34 -08:00
committed by GitHub
parent 588373c2d5
commit a933776436
5 changed files with 153 additions and 29 deletions
+10 -17
View File
@@ -1,4 +1,3 @@
import json
import pathlib
import shutil
import sys
@@ -354,8 +353,7 @@ def build(
with Runner() as runner, Progress(message="Pulling...") as set:
if shutil.which("docker") is None:
raise click.UsageError("Docker not installed") from None
with open(config) as f:
config_json = langgraph_cli.config.validate_config(json.load(f))
config_json = langgraph_cli.config.validate_config_file(config)
_build(
runner, set, config, config_json, base_image, pull, tag, docker_build_args
)
@@ -435,8 +433,7 @@ tests
def dockerfile(save_path: str, config: pathlib.Path, add_docker_compose: bool) -> None:
save_path = pathlib.Path(save_path).absolute()
secho(f"🔍 Validating configuration at path: {config}", fg="yellow")
with open(config, encoding="utf-8") as f:
config_json = langgraph_cli.config.validate_config(json.load(f))
config_json = langgraph_cli.config.validate_config_file(config)
secho("✅ Configuration validated!", fg="green")
secho(f"📝 Generating Dockerfile at {save_path}", fg="yellow")
@@ -575,7 +572,7 @@ def dev(
host: str,
port: int,
no_reload: bool,
config: str,
config: pathlib.Path,
n_jobs_per_worker: Optional[int],
no_browser: bool,
debug_port: Optional[int],
@@ -601,12 +598,9 @@ def dev(
"Please ensure langgraph-cli is installed with the 'inmem' extra: pip install -U \"langgraph-cli[inmem]\""
) from None
import json
config_json = langgraph_cli.config.validate_config_file(config)
with open(config, encoding="utf-8") as f:
config_data = json.load(f)
graphs = config_data.get("graphs", {})
graphs = config_json.get("graphs", {})
run_server(
host,
port,
@@ -674,8 +668,7 @@ def prepare(
debugger_base_url: Optional[str] = None,
postgres_uri: Optional[str] = None,
):
with open(config_path) as f:
config = langgraph_cli.config.validate_config(json.load(f))
config_json = langgraph_cli.config.validate_config_file(config_path)
# pull latest images
if pull:
runner.run(
@@ -683,9 +676,9 @@ def prepare(
"docker",
"pull",
(
f"langchain/langgraphjs-api:{config['node_version']}"
if config.get("node_version")
else f"langchain/langgraph-api:{config['python_version']}"
f"langchain/langgraphjs-api:{config_json['node_version']}"
if config_json.get("node_version")
else f"langchain/langgraph-api:{config_json['python_version']}"
),
verbose=verbose,
)
@@ -694,7 +687,7 @@ def prepare(
args, stdin = prepare_args_and_stdin(
capabilities=capabilities,
config_path=config_path,
config=config,
config=config_json,
docker_compose=docker_compose,
port=port,
watch=watch,