Home / Function/ _write_profiles_file() — langchain Function Reference

_write_profiles_file() — langchain Function Reference

Architecture documentation for the _write_profiles_file() function in cli.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  67e62d64_96d5_5560_dfce_06308c08d58a["_write_profiles_file()"]
  74c7ffe0_0dd5_5e6a_45ab_950da26de248["cli.py"]
  67e62d64_96d5_5560_dfce_06308c08d58a -->|defined in| 74c7ffe0_0dd5_5e6a_45ab_950da26de248
  2f2dc685_603e_b75d_c32f_a2fd813a683c["refresh()"]
  2f2dc685_603e_b75d_c32f_a2fd813a683c -->|calls| 67e62d64_96d5_5560_dfce_06308c08d58a
  639f6001_e33f_cabc_b166_c58c92df4410["_ensure_safe_output_path()"]
  67e62d64_96d5_5560_dfce_06308c08d58a -->|calls| 639f6001_e33f_cabc_b166_c58c92df4410
  style 67e62d64_96d5_5560_dfce_06308c08d58a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/model-profiles/langchain_model_profiles/cli.py lines 173–196

def _write_profiles_file(output_file: Path, contents: str) -> None:
    """Write the generated module atomically without following symlinks."""
    _ensure_safe_output_path(output_file.parent, output_file)

    temp_path: Path | None = None
    try:
        with tempfile.NamedTemporaryFile(
            mode="w", encoding="utf-8", dir=output_file.parent, delete=False
        ) as tmp_file:
            tmp_file.write(contents)
            temp_path = Path(tmp_file.name)
        temp_path.replace(output_file)
    except PermissionError:
        msg = f"Permission denied writing file: {output_file}"
        print(f"❌ {msg}", file=sys.stderr)
        if temp_path:
            temp_path.unlink(missing_ok=True)
        sys.exit(1)
    except OSError as e:
        msg = f"Failed to write file: {e}"
        print(f"❌ {msg}", file=sys.stderr)
        if temp_path:
            temp_path.unlink(missing_ok=True)
        sys.exit(1)

Domain

Subdomains

Called By

Frequently Asked Questions

What does _write_profiles_file() do?
_write_profiles_file() is a function in the langchain codebase, defined in libs/model-profiles/langchain_model_profiles/cli.py.
Where is _write_profiles_file() defined?
_write_profiles_file() is defined in libs/model-profiles/langchain_model_profiles/cli.py at line 173.
What does _write_profiles_file() call?
_write_profiles_file() calls 1 function(s): _ensure_safe_output_path.
What calls _write_profiles_file()?
_write_profiles_file() is called by 1 function(s): refresh.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free