Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Langchain ai Langchain Pre Release Checks

From Leeroopedia

Template:Metadata

Overview

Concrete tool for validating LangChain release artifacts through a multi-step quality gate, provided by the pre-release-checks job in _release.yml along with supporting Python scripts.

Description

The pre-release-checks job runs after Test PyPI publishing and performs six sequential validation steps:

  1. Import dist package (L266-290): Creates a fresh venv, installs the built wheel via uv pip install dist/*.whl, and runs python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))". Dashes in package names are converted to underscores, and the _official suffix is stripped for the import name.
  1. Import test dependencies (L292-294): Runs uv sync --group test to install the test dependency group.
  1. Re-install the built wheel (L296-304): Overrides the editable install with the actual wheel via uv pip install dist/*.whl to ensure tests run against the packaged artifact.
  1. Check for prerelease dependencies (L306-311): Runs check_prerelease_dependencies.py which loads pyproject.toml, checks if the release is itself an RC/dev version, and if not, ensures no dependency specifiers contain rc or have allow-prereleases set to true.
  1. Run unit tests + minimum version tests (L313-336): Runs make tests, then uses get_min_versions.py to compute the minimum published versions satisfying each dependency constraint (querying PyPI), installs those versions, and re-runs make tests.
  1. Run integration tests (L338-382): Only for partner packages (libs/partners/*). Installs integration test dependencies and runs make integration_tests with API keys from repository secrets.

The job explicitly does not use caching, to avoid false positives from cached dependencies masking missing package requirements.

Usage

This job runs automatically in the release pipeline after Test PyPI publishing. It has a 20-minute timeout. Failure in any step blocks the release.

Code Reference

Source Location: .github/workflows/_release.yml (lines 230-382)

Import Check:

uv venv
VIRTUAL_ENV=.venv uv pip install dist/*.whl

# Convert package name for import
IMPORT_NAME="$(echo "$PKG_NAME" | sed s/-/_/g | sed s/_official//g)"

uv run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"

Prerelease Dependency Check (.github/scripts/check_prerelease_dependencies.py):

import sys
import tomllib

if __name__ == "__main__":
    toml_file = sys.argv[1]
    with open(toml_file, "rb") as file:
        toml_data = tomllib.load(file)

    version = toml_data["project"]["version"]
    releasing_rc = "rc" in version or "dev" in version

    if not releasing_rc:
        dependencies = toml_data["project"]["dependencies"]
        for dep_version in dependencies:
            dep_version_string = (
                dep_version["version"]
                if isinstance(dep_version, dict) else dep_version
            )
            if "rc" in dep_version_string:
                raise ValueError(
                    f"Dependency {dep_version} has a prerelease version."
                )
            if isinstance(dep_version, dict) and dep_version.get(
                "allow-prereleases", False
            ):
                raise ValueError(
                    f"Dependency {dep_version} has allow-prereleases set."
                )

Minimum Version Computation (.github/scripts/get_min_versions.py, signature):

def get_min_version_from_toml(
    toml_path: str,
    versions_for: str,
    python_version: str,
    *,
    include: list | None = None,
) -> dict[str, str | None]:
    ...

Minimum Version Test Steps:

- name: Get minimum versions
  working-directory: ${{ inputs.working-directory }}
  id: min-version
  run: |
    VIRTUAL_ENV=.venv uv pip install packaging requests
    python_version="$(uv run python --version | awk '{print $2}')"
    min_versions="$(uv run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml release $python_version)"
    echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"

- name: Run unit tests with minimum dependency versions
  if: ${{ steps.min-version.outputs.min-versions != '' }}
  env:
    MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
  run: |
    VIRTUAL_ENV=.venv uv pip install --force-reinstall --editable .
    VIRTUAL_ENV=.venv uv pip install --force-reinstall $MIN_VERSIONS
    make tests
  working-directory: ${{ inputs.working-directory }}

Invocation: Automatic. Depends on build, release-notes, and test-pypi-publish jobs.

I/O Contract

Direction Name Type Description
Input dist/*.whl File Built wheel artifact from the build job
Input PKG_NAME string Package name (e.g., langchain-core)
Input VERSION string Version string (e.g., 1.2.11)
Input pyproject.toml File Package metadata with dependency declarations
Input API key secrets Secrets Required for integration tests of partner packages
Output Test results Pass/Fail Unit tests, min-version tests, and integration tests must all pass
Output min-versions string Space-separated list of pkg==version pairs (e.g., langchain-core==0.2.0 numpy==1.24.0)

Usage Examples

Example 1: Running the prerelease dependency check locally

cd libs/core
python ../../.github/scripts/check_prerelease_dependencies.py pyproject.toml

Example 2: Computing minimum versions locally

cd libs/partners/openai
pip install packaging requests
python ../../../.github/scripts/get_min_versions.py pyproject.toml release 3.11.0
# Output: langchain-core==0.2.0 numpy==1.24.0

Example 3: Simulating the import check locally

cd libs/core
uv build
uv venv
VIRTUAL_ENV=.venv uv pip install dist/*.whl
uv run python -c "import langchain_core; print(dir(langchain_core))"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment