cli.py — langchain Source File
Architecture documentation for cli.py, a python file in the langchain codebase. 10 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 80f3dc70_2b66_4082_12d0_bc4ec3c51536["cli.py"] f6fc3730_e0f8_6436_3e80_f1e91bad808d["argparse"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> f6fc3730_e0f8_6436_3e80_f1e91bad808d 7025b240_fdc3_cf68_b72f_f41dac94566b["json"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> 7025b240_fdc3_cf68_b72f_f41dac94566b 67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95 d76a28c2_c3ab_00a8_5208_77807a49449d["sys"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> d76a28c2_c3ab_00a8_5208_77807a49449d d47804b2_9963_be65_f855_93c7c6a0eab8["tempfile"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> d47804b2_9963_be65_f855_93c7c6a0eab8 b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 1803c8c1_a347_1256_1454_9f04c3553d93["httpx"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> 1803c8c1_a347_1256_1454_9f04c3553d93 d9ec9cdf_a4b8_690b_b761_c5e6fbb7c906["tomllib"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> d9ec9cdf_a4b8_690b_b761_c5e6fbb7c906 8d58d07c_d6f3_541d_3b74_c12fc7c0101b["tomli"] 80f3dc70_2b66_4082_12d0_bc4ec3c51536 --> 8d58d07c_d6f3_541d_3b74_c12fc7c0101b style 80f3dc70_2b66_4082_12d0_bc4ec3c51536 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""CLI for refreshing model profile data from models.dev."""
import argparse
import json
import re
import sys
import tempfile
from pathlib import Path
from typing import Any
import httpx
try:
import tomllib # type: ignore[import-not-found] # Python 3.11+
except ImportError:
import tomli as tomllib # type: ignore[import-not-found,no-redef]
def _validate_data_dir(data_dir: Path) -> Path:
"""Validate and canonicalize data directory path.
Args:
data_dir: User-provided data directory path.
Returns:
Resolved, canonical path.
Raises:
SystemExit: If user declines to write outside current directory.
"""
# Resolve to absolute, canonical path (follows symlinks)
try:
resolved = data_dir.resolve(strict=False)
except (OSError, RuntimeError) as e:
msg = f"Invalid data directory path: {e}"
print(f"❌ {msg}", file=sys.stderr)
sys.exit(1)
# Warn if writing outside current directory
cwd = Path.cwd().resolve()
try:
resolved.relative_to(cwd)
except ValueError:
# Not relative to cwd
print("⚠️ WARNING: Writing outside current directory", file=sys.stderr)
print(f" Current directory: {cwd}", file=sys.stderr)
print(f" Target directory: {resolved}", file=sys.stderr)
print(file=sys.stderr)
response = input("Continue? (y/N): ")
if response.lower() != "y":
print("Aborted.", file=sys.stderr)
sys.exit(1)
return resolved
def _load_augmentations(
data_dir: Path,
) -> tuple[dict[str, Any], dict[str, dict[str, Any]]]:
"""Load augmentations from `profile_augmentations.toml`.
// ... (302 more lines)
Domain
Subdomains
Functions
Dependencies
- argparse
- httpx
- json
- pathlib
- re
- sys
- tempfile
- tomli
- tomllib
- typing
Source
Frequently Asked Questions
What does cli.py do?
cli.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in cli.py?
cli.py defines 10 function(s): _apply_overrides, _ensure_safe_output_path, _load_augmentations, _model_data_to_profile, _validate_data_dir, _write_profiles_file, main, refresh, tomli, tomllib.
What does cli.py depend on?
cli.py imports 10 module(s): argparse, httpx, json, pathlib, re, sys, tempfile, tomli, and 2 more.
Where is cli.py in the architecture?
cli.py is located at libs/model-profiles/langchain_model_profiles/cli.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/model-profiles/langchain_model_profiles).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free