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:Mlflow Mlflow Remove Experimental Decorators

From Leeroopedia
Revision as of 13:18, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Mlflow_Mlflow_Remove_Experimental_Decorators.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Release Automation, Code Maintenance
Last Updated 2026-02-13 20:00 GMT

Overview

A development script that automatically removes @experimental decorators from functions and classes that have been in experimental status longer than a configurable cutoff period (default: 6 months).

Description

remove_experimental_decorators.py automates the graduation of experimental APIs to stable status. The script works by:

  1. Fetching MLflow release dates from the PyPI JSON API to determine when each version was published.
  2. Using Python's ast module to parse source files and locate @experimental decorator calls that include a version keyword argument.
  3. Computing the age of each decorator by comparing the release date of the version specified in the decorator against the current date.
  4. Removing decorator lines from files where the decorator's age exceeds the cutoff threshold.

The script uses the ExperimentalDecorator dataclass to track metadata about each decorator occurrence, including version, line numbers, column offset, age in days, and the unparsed decorator content. It supports a --dry-run mode that reports what would be removed without modifying files, and a --cutoff-days option to override the default 180-day threshold.

Usage

Use this script during MLflow release preparation to graduate experimental APIs that have been stable long enough. It can also be run periodically as part of CI or maintenance workflows to identify stale experimental annotations.

Code Reference

Source Location

Signature

@dataclass
class ExperimentalDecorator:
    version: str
    line_number: int
    end_line_number: int
    column: int
    age_days: int
    content: str

def get_tracked_python_files() -> list[Path]: ...

def get_mlflow_release_dates() -> dict[str, datetime]: ...

def find_experimental_decorators(
    file_path: Path, release_dates: dict[str, datetime], now: datetime
) -> list[ExperimentalDecorator]: ...

def remove_decorators_from_file(
    file_path: Path,
    decorators_to_remove: list[ExperimentalDecorator],
    dry_run: bool,
) -> list[ExperimentalDecorator]: ...

def main() -> None: ...

Import

# Run as a standalone script
python dev/remove_experimental_decorators.py

I/O Contract

Inputs

Name Type Required Description
--dry-run flag No Show what would be removed without making changes
--cutoff-days int No Number of days after which to remove decorators (default: 180)
files positional args No Python files to process; defaults to all git-tracked .py files

Outputs

Name Type Description
stdout text Reports each decorator found or removed with file path, line, column, content, and age in days
file modifications in-place edits Removes decorator lines from source files (unless --dry-run is specified)

Usage Examples

Dry Run

# Preview which decorators would be removed (default 180-day cutoff)
python dev/remove_experimental_decorators.py --dry-run

Custom Cutoff

# Remove decorators older than 90 days
python dev/remove_experimental_decorators.py --cutoff-days 90

Specific Files

# Process only specific files
python dev/remove_experimental_decorators.py mlflow/tracking/client.py mlflow/models/model.py

Internal Workflow

The script follows this processing pipeline:

  1. get_mlflow_release_dates() fetches the complete release history from https://pypi.org/pypi/mlflow/json and extracts the earliest upload time for each version.
  2. get_tracked_python_files() runs git ls-files *.py to enumerate all tracked Python files in the repository.
  3. For each file, find_experimental_decorators() parses the AST, walks all function/class definitions, and identifies @experimental(version="X.Y.Z") calls. It extracts the version via _extract_version_from_ast_decorator() and computes the age using the release date lookup.
  4. Decorators older than the cutoff are passed to remove_decorators_from_file(), which removes the corresponding line ranges and writes the modified content back to disk.

Related Pages

Page Connections

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