From 13a510d576b29088355388fd7f9ce33a9db77f18 Mon Sep 17 00:00:00 2001 From: Vladimir Iglovikov Date: Wed, 23 Oct 2024 13:08:34 -0700 Subject: [PATCH] Boost version (#2013) * Empty-Commit * Refactored CI * Fix * Boosted version --- .github/workflows/ci.yml | 66 +++++++++++++--------------- albumentations/__init__.py | 14 ++++-- albumentations/_version.py | 1 - albumentations/check_version.py | 2 +- albumentations/core/serialization.py | 2 +- pyproject.toml | 5 ++- setup.py | 21 ++------- 7 files changed, 51 insertions(+), 60 deletions(-) delete mode 100644 albumentations/_version.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15b95f7cb..8a90d8b13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,9 +4,8 @@ on: branches: - main paths-ignore: - - 'CONTRIBUTORS.md' + - '**.md' - 'benchmark/**' - - 'albumentations/_version.py' jobs: test_and_lint: @@ -36,38 +35,34 @@ jobs: uses: actions/cache@v4 with: path: ${{ matrix.path }} - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }} + key: ${{ runner.os }}-uv-${{ hashFiles('**/requirements-dev.txt') }} restore-keys: | - ${{ runner.os }}-pip-${{ matrix.python-version }}- - ${{ runner.os }}-pip- + ${{ runner.os }}-uv-${{ matrix.python-version }}- + ${{ runner.os }}-uv- - - name: Update pip - run: | - python -m pip install --upgrade pip uv - - name: Update pip + - name: Install uv + run: python -m pip install --upgrade uv + + - name: Install PyTorch run: | - python -m pip install --upgrade uv - - name: Install wheel - run: uv pip install --system --upgrade wheel - - name: Install PyTorch on Linux and Windows - if: > - matrix.operating-system == 'ubuntu-latest' || - matrix.operating-system == 'windows-latest' - run: > - uv pip install --system --verbose torch==2.4.1+cpu torchvision==0.19.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu - - name: Install PyTorch on MacOS - if: matrix.operating-system == 'macos-latest' - run: > - uv pip install --system --verbose torch==2.4.1 torchvision==0.19.1 - - name: Install dev requirements - run: uv pip install --system -r requirements-dev.txt - - name: Install dependencies + if [ "${{ matrix.operating-system }}" = "macos-latest" ]; then + uv pip install --system torch==2.4.1 torchvision==0.19.1 + else + uv pip install --system torch==2.4.1+cpu torchvision==0.19.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu + fi + shell: bash + + - name: Install all dependencies run: | + uv pip install --system wheel + uv pip install --system -r requirements-dev.txt uv pip install --system . + - name: Run PyTest - run: pytest --cov . + run: pytest --cov . --cov-report=xml + - name: Upload coverage reports to Codecov - if: matrix.operating-system == 'ubuntu-latest' && matrix.python-version == '3.10' + if: matrix.operating-system == 'ubuntu-latest' && matrix.python-version == '3.12' uses: codecov/codecov-action@v4.3.0 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -87,14 +82,13 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: check validity of codecov.yaml - run: cat codecov.yaml | curl --data-binary @- https://codecov.io/validate - - name: Install requirements + + - name: Install all requirements run: | - python -m pip install --upgrade pip uv + python -m pip install --upgrade uv + uv pip install --system -r requirements-dev.txt uv pip install --system . - - name: Install dev requirements - run: uv pip install --system -r requirements-dev.txt + - name: Run checks run: pre-commit run --files $(find albumentations -type f) - name: check-defaults-in-apply @@ -113,10 +107,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install requirements + - name: Install all requirements run: | - python -m pip install --upgrade pip uv - uv pip install --system requests + python -m pip install --upgrade uv + uv pip install --system requests uv pip install --system . - name: Run checks for documentation run: python -m tools.make_transforms_docs check README.md diff --git a/albumentations/__init__.py b/albumentations/__init__.py index ebf948276..8dcc15bc4 100644 --- a/albumentations/__init__.py +++ b/albumentations/__init__.py @@ -1,11 +1,19 @@ -__author__ = "Vladimir Iglovikov" -__maintainer__ = "Vladimir Iglovikov" +from importlib.metadata import metadata + +try: + _metadata = metadata("albucore") + __version__ = _metadata["Version"] + __author__ = _metadata["Author"] + __maintainer__ = _metadata["Maintainer"] +except Exception: # noqa: BLE001 + __version__ = "unknown" + __author__ = "Vladimir Iglovikov" + __maintainer__ = "Vladimir Iglovikov" import os from albumentations.check_version import check_for_updates -from ._version import __version__ # noqa: F401 from .augmentations import * from .core.composition import * from .core.serialization import * diff --git a/albumentations/_version.py b/albumentations/_version.py deleted file mode 100644 index ba5ed8f09..000000000 --- a/albumentations/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "1.4.18" diff --git a/albumentations/check_version.py b/albumentations/check_version.py index 5f7ca5d68..20ffdc224 100644 --- a/albumentations/check_version.py +++ b/albumentations/check_version.py @@ -3,7 +3,7 @@ from urllib.request import OpenerDirector from warnings import warn -from albumentations._version import __version__ as current_version +from albumentations import __version__ as current_version SUCCESS_HTML_CODE = 200 diff --git a/albumentations/core/serialization.py b/albumentations/core/serialization.py index e858ecc58..ca91bdd9e 100644 --- a/albumentations/core/serialization.py +++ b/albumentations/core/serialization.py @@ -17,7 +17,7 @@ yaml_available = False -from albumentations._version import __version__ +from albumentations import __version__ __all__ = ["to_dict", "from_dict", "save", "load"] diff --git a/pyproject.toml b/pyproject.toml index 144f30ccc..e74333846 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,9 @@ requires = [ "setuptools>=45", "wheel" ] [project] name = "albumentations" + +version = "1.4.19" + description = "Fast, flexible, and advanced image augmentation library for deep learning and computer vision. Albumentations offers a wide range of transformations for images, masks, bounding boxes, and keypoints, with optimized performance and seamless integration into ML workflows." readme = "README.md" keywords = [ @@ -55,7 +58,7 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", "Typing :: Typed", ] -dynamic = [ "dependencies", "version" ] +dynamic = [ "dependencies" ] optional-dependencies.hub = [ "huggingface-hub" ] optional-dependencies.text = [ "pillow" ] urls.Homepage = "https://albumentations.ai" diff --git a/setup.py b/setup.py index 29992cf57..40c91fd04 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,4 @@ import re -from typing import List, Tuple -import os from pkg_resources import DistributionNotFound, get_distribution from setuptools import setup, find_packages @@ -11,8 +9,8 @@ "PyYAML", "typing-extensions>=4.9.0; python_version<'3.10'", "pydantic>=2.7.0", - "albucore==0.0.18", - "eval-type-backport" + "albucore==0.0.19", + "eval-type-backport", ] MIN_OPENCV_VERSION = "4.9.0.80" @@ -24,17 +22,7 @@ ), ] -def get_version(): - version_file = os.path.join(os.path.dirname(__file__), 'albumentations', '_version.py') - with open(version_file, 'r') as f: - version_line = f.read().strip() - version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]" - match = re.match(version_regex, version_line, re.M) - if match: - return match.group(1) - raise RuntimeError("Unable to find version string.") - -def choose_requirement(mains: Tuple[str, ...], secondary: str) -> str: +def choose_requirement(mains: tuple[str, ...], secondary: str) -> str: chosen = secondary for main in mains: try: @@ -46,13 +34,12 @@ def choose_requirement(mains: Tuple[str, ...], secondary: str) -> str: pass return chosen -def get_install_requirements(install_requires: List[str], choose_install_requires: List[Tuple[Tuple[str, ...], str]]) -> List[str]: +def get_install_requirements(install_requires: list[str], choose_install_requires: list[tuple[tuple[str, ...], str]]) -> list[str]: for mains, secondary in choose_install_requires: install_requires.append(choose_requirement(mains, secondary)) return install_requires setup( - version=get_version(), packages=find_packages(exclude=["tests", "tools", "benchmark"], include=['albumentations*']), install_requires=get_install_requirements(INSTALL_REQUIRES, CHOOSE_INSTALL_REQUIRES), )