Skip to content

Commit

Permalink
Updated CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ternaus committed Oct 23, 2024
1 parent d1b8b55 commit 3e462d5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
55 changes: 30 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ on:
branches:
- main
paths-ignore:
- 'CONTRIBUTORS.md'
- 'README.md'
- 'benchmarks/results/**'

- 'benchmarks/albucore_benchmark/results/**'
- '**.md' # Ignore all markdown files
- 'docs/**' # Ignore documentation changes
jobs:
test_and_lint:
name: Test and lint
Expand All @@ -24,13 +23,18 @@ jobs:
- operating-system: macos-13
path: ~/Library/Caches/pip
fail-fast: true

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements-dev.txt
setup.py
- name: Cache Python packages
uses: actions/cache@v4
Expand All @@ -41,29 +45,25 @@ jobs:
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install wheel
run: python -m pip install --upgrade wheel
- name: Install dev requirements
run: pip install -r requirements-dev.txt
- name: Install uv
run: pip install uv

- name: Install dependencies
run: |
python -m ensurepip --upgrade
pip install .
- name: Cleanup the build directory
uses: JesseTG/[email protected]
with:
path: build
- name: Run PyTest
run: pytest --cov .
uv pip install --system --upgrade pip wheel
uv pip install --system -r requirements-dev.txt
uv pip install --system .
- name: Run PyTest with coverage
run: pytest --cov . --cov-report=xml

- name: Upload coverage reports to Codecov
if: matrix.operating-system == 'ubuntu-latest' && matrix.python-version == '3.8'
if: matrix.operating-system == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: albumentations-team/albucore
files: ./coverage.xml

check_code_formatting_types:
name: Check code formatting with ruff and mypy
Expand All @@ -75,15 +75,20 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements-dev.txt
setup.py
- name: Install requirements
run: |
python -m pip install --upgrade pip uv
uv pip install --system --upgrade pip
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
run: pre-commit run --all-files
13 changes: 10 additions & 3 deletions albucore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
__author__ = "Vladimir Iglovikov"
__maintainer__ = "Vladimir Iglovikov"
from importlib.metadata import metadata

__version__ = "0.0.19"
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"

from .decorators import *
from .functions import *
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ requires = [ "setuptools>=45", "wheel" ]

[project]
name = "albucore"
version = "0.0.19"

description = "High-performance image processing functions for deep learning and computer vision."
readme = "README.md"
keywords = [ "deep learning", "image processing" ]
license = { file = "LICENSE" }
authors = [ { name = "Vladimir I. Iglovikov" } ]
maintainers = [ { name = "Vladimir Iglovikov" } ]

authors = [ { name = "Vladimir Iglovikov" } ]
requires-python = ">=3.9"

classifiers = [
Expand All @@ -31,7 +35,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]
dynamic = [ "dependencies", "version" ]
dynamic = [ "dependencies" ]

[tool.setuptools]
packages = { find = { include = [
Expand Down
17 changes: 2 additions & 15 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 @@ -21,17 +19,7 @@
),
]

def get_version():
version_file = os.path.join(os.path.dirname(__file__), 'albucore', '__init__.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 @@ -43,13 +31,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", "benchmark"], include=['albucore*']),
install_requires=get_install_requirements(INSTALL_REQUIRES, CHOOSE_INSTALL_REQUIRES),
)

0 comments on commit 3e462d5

Please sign in to comment.