Skip to content

Commit

Permalink
Boost version (#2013)
Browse files Browse the repository at this point in the history
* Empty-Commit

* Refactored CI

* Fix

* Boosted version
  • Loading branch information
ternaus authored Oct 23, 2024
1 parent a212f87 commit 13a510d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 60 deletions.
66 changes: 30 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
branches:
- main
paths-ignore:
- 'CONTRIBUTORS.md'
- '**.md'
- 'benchmark/**'
- 'albumentations/_version.py'

jobs:
test_and_lint:
Expand Down Expand Up @@ -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/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -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
Expand All @@ -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
Expand Down
14 changes: 11 additions & 3 deletions albumentations/__init__.py
Original file line number Diff line number Diff line change
@@ -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 *
Expand Down
1 change: 0 additions & 1 deletion albumentations/_version.py

This file was deleted.

2 changes: 1 addition & 1 deletion albumentations/check_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion albumentations/core/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
yaml_available = False


from albumentations._version import __version__
from albumentations import __version__

__all__ = ["to_dict", "from_dict", "save", "load"]

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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"
Expand Down
21 changes: 4 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -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),
)

0 comments on commit 13a510d

Please sign in to comment.