Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality Improvements and Development Infrastructure Updates #167

Merged
merged 23 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ docker-compose.yml
build/*
dist/*
docs/*
docker/
docker/
51 changes: 51 additions & 0 deletions .github/workflows/gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Temporarily disabled - requires GitHub Teams plan for GPU runners
# name: GPU Tests
#
# on:
# push:
# branches: [ master ]
# pull_request:
# branches: [ master ]
#
# jobs:
# gpu-test:
# runs-on: ubuntu-20.04
#
# steps:
# - uses: actions/checkout@v3
#
# - name: Set up Python 3.7
# uses: actions/setup-python@v4
# with:
# python-version: '3.7'
#
# - name: Install FFMPEG
# run: |
# sudo apt-get update
# sudo apt-get install -y ffmpeg
#
# - name: Install PySide2
# run: |
# python -m pip install --upgrade pip
# pip install "pyside2==5.13.2"
#
# - name: Install PyTorch with CUDA
# run: |
# pip install torch==1.11.0+cu115 torchvision==0.12.0+cu115 -f https://download.pytorch.org/whl/torch_stable.html
#
# - name: Install package and test dependencies
# run: |
# python -m pip install --upgrade "pip<24.0"
# pip install -r requirements.txt
# pip install pytest pytest-cov
# python setup.py develop
#
# - name: Setup test data
# run: |
# python setup_tests.py
#
# - name: GPU Tests
# run: |
# pytest -v -m "gpu" tests/
# env:
# CUDA_VISIBLE_DEVICES: 0
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CPU Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-13]

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'

- name: Install FFMPEG (Ubuntu)
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg

- name: Install FFMPEG (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install ffmpeg

- name: Install FFMPEG (macOS)
if: matrix.os == 'macos-13'
run: |
brew install ffmpeg

- name: Install PySide2
run: |
python -m pip install --upgrade pip
pip install "pyside2==5.13.2"

- name: Install PyTorch CPU
run: |
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu

- name: Install package and test dependencies
run: |
python -m pip install --upgrade "pip<24.0"
pip install -r requirements.txt
pip install pytest pytest-cov
python setup.py develop

- name: Setup test data
run: |
python setup_tests.py

- name: Run CPU tests
run: |
pytest -v -m "not gpu" tests/
28 changes: 28 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pre-commit

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
pre-commit:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: '3.7'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pre-commit ruff

- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files
100 changes: 100 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Publish Python 🐍 distribution 📦 to PyPI

on:
push:
# Only run this workflow when a tag with the pattern 'v*' is pushed
tags:
- 'v*'

jobs:
# Step 1: Build the Python package
build:
name: Build distribution 📦
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build pytest
pip install -e .

- name: Run tests
run: pytest tests/

- name: Build package
run: python -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

# Step 2: Publish the distribution to PyPI
publish-to-pypi:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest

steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish to PyPI
uses: pypa/[email protected]
with:
# If using a secret-based token:
username: '__token__'
password: ${{ secrets.PYPI_API_TOKEN }}

# Step 3: Sign the distribution and create a GitHub release
github-release:
name: Sign the distribution 📦 with Sigstore and upload to GitHub Release
needs: publish-to-pypi
runs-on: ubuntu-latest
permissions:
contents: write # Required to create GitHub Releases
id-token: write # Required for sigstore

steps:
- name: Download distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
# $GITHUB_REF_NAME is the tag name, e.g. 'v1.0.0'
gh release create "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--title "Release $GITHUB_REF_NAME" \
--notes "See CHANGELOG for details."

- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release upload "$GITHUB_REF_NAME" dist/** \
--repo "$GITHUB_REPOSITORY"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ venv.bak/
dmypy.json

# Pyre type checker
.pyre/
.pyre/
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: check-merge-conflict
- id: detect-private-key

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
3 changes: 0 additions & 3 deletions .style.yapf

This file was deleted.

1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@jbohnslav
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include README.md
include deepethogram/gui/icons/*.png
recursive-include deepethogram/conf *
recursive-include deepethogram/conf *
Loading