Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Scikit learn Scikit learn UpdateEnvironments

From Leeroopedia


Knowledge Sources
Domains Build Tools, CI/CD
Last Updated 2026-02-08 15:00 GMT

Overview

Concrete tool for updating CI environment files and associated lock files provided by scikit-learn.

Description

This script manages the CI environment configuration by updating conda environment.yml files, pip requirements.txt files, and their associated lock files (conda-lock and pip-compile). It reads minimum dependency specifications from sklearn/_min_dependencies.py and generates environment files for all CI build configurations. The script supports selective updates via regex-based build filtering and uses Jinja2 templating to generate environment files.

Usage

Use this script when bumping minimum dependency versions, pinning packages to work around regressions, or ensuring that CI uses the latest compatible versions of all dependencies.

Code Reference

Source Location

Signature

# Command-line script using click
# python build_tools/update_environments_and_lock_files.py [--select-build REGEX]

# Key configuration variables:
common_dependencies_without_coverage = [...]
# Uses Jinja2 Environment for template rendering
# Uses packaging.version.Version for version comparison

Import

import click
from jinja2 import Environment
from packaging.version import Version

I/O Contract

Inputs

Name Type Required Description
--select-build str (regex) No Regex pattern to filter which build configurations to update
sklearn/_min_dependencies.py file Yes Source of minimum dependency version specifications
build_tools/*/environment.yml templates files Yes Jinja2 templates for conda environment files

Outputs

Name Type Description
environment.yml files YAML files Updated conda environment configuration files
requirements.txt files text files Updated pip requirements files
lock files text files Generated conda-lock or pip-compile lock files

Usage Examples

Basic Usage

# Run from the root of the scikit-learn repository
# Update all environments:
# python build_tools/update_environments_and_lock_files.py

# Update only documentation builds:
# python build_tools/update_environments_and_lock_files.py --select-build doc

Related Pages

Page Connections

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