albumentations.check_version


Module for checking and comparing albumentations package versions. This module provides utilities for version checking and comparison, including the ability to fetch the latest version from PyPI and compare it with the currently installed version. It helps users stay informed about available updates and encourages keeping the library up-to-date with the latest features and bug fixes.

check_for_updatesfunction

check_for_updates()

Check if a newer version of albumentations is available on PyPI. This function compares the current installed version with the latest version available on PyPI. If a newer version is found, it issues a warning to the user with upgrade instructions. All exceptions are caught to ensure this check doesn't affect normal package operation. The check can be disabled by setting the environment variable NO_ALBUMENTATIONS_UPDATE to 1.

compare_versionsfunction

compare_versions(
    v1: tuple[int | str, ...],
    v2: tuple[int | str, ...]
)

Compare two version tuples. Returns True if v1 > v2, False otherwise. Special rules: 1. Release version > pre-release version (e.g., (1, 4) > (1, 4, 'beta')) 2. Numeric parts are compared numerically 3. String parts are compared lexicographically

Parameters

NameTypeDefaultDescription
v1
One of:
  • tuple[int | str, ...]
--
v2
One of:
  • tuple[int | str, ...]
--

fetch_version_infofunction

fetch_version_info()

Fetch version information from PyPI for albumentations package. This function retrieves JSON data from PyPI containing information about the latest available version of albumentations. It handles network errors gracefully and returns an empty string if the request fails.

Returns

  • str: JSON string containing version information if successful,

get_openerfunction

get_opener()

Get or create a URL opener for making HTTP requests. This function implements a singleton pattern for the opener to avoid recreating it on each request. It lazily instantiates a URL opener with HTTP and HTTPS handlers.

Returns

  • OpenerDirector: URL opener instance for making HTTP requests.

parse_versionfunction

parse_version(
    data: str
)

Parses the version from the given JSON data.

Parameters

NameTypeDefaultDescription
datastr--

parse_version_partsfunction

parse_version_parts(
    version_str: str
)

Convert version string to tuple of (int | str) parts following PEP 440 conventions.

Parameters

NameTypeDefaultDescription
version_strstr--