Skip to content

Commit

Permalink
Merge pre-release: Update CI workflow for uv
Browse files Browse the repository at this point in the history
  • Loading branch information
remsky committed Jan 14, 2025
2 parents e1dc8e5 + 0bb2c1d commit 5045cf9
Show file tree
Hide file tree
Showing 69 changed files with 9,209 additions and 769 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ omit =
MagicMock/*
test_*.py
examples/*
src/builds/*

[report]
exclude_lines =
Expand Down
71 changes: 26 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,32 @@
# name: CI
name: CI

# on:
# push:
# branches: [ "develop", "master" ]
# pull_request:
# branches: [ "develop", "master" ]
on:
push:
branches: [ "master", "pre-release" ]
pull_request:
branches: [ "master", "pre-release" ]

# jobs:
# test:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: ["3.9", "3.10", "3.11"]
# fail-fast: false
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
fail-fast: false

# steps:
# - uses: actions/checkout@v4
steps:
- uses: actions/checkout@v4

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}

# - name: Set up pip cache
# uses: actions/cache@v3
# with:
# path: ~/.cache/pip
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

# - name: Install PyTorch CPU
# run: |
# python -m pip install --upgrade pip
# pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Install dependencies
run: |
uv pip install -e .[test,cpu]
# - name: Install dependencies
# run: |
# pip install ruff pytest-cov
# pip install -r requirements.txt
# pip install -r requirements-test.txt

# - name: Lint with ruff
# run: |
# ruff check .


# - name: Test with pytest
# run: |
# pytest --asyncio-mode=auto --cov=api --cov-report=term-missing
- name: Run Tests
run: |
uv run pytest api/tests/ --asyncio-mode=auto --cov=api --cov-report=term-missing
124 changes: 71 additions & 53 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Docker Build and Publish
name: Docker Build, Slim, and Publish

on:
push:
branches:
- master
tags: [ 'v*.*.*' ]
# Allow manual trigger from GitHub UI
workflow_dispatch:
Expand All @@ -16,6 +18,7 @@ jobs:
permissions:
contents: read
packages: write
actions: write

steps:
- name: Checkout repository
Expand All @@ -28,67 +31,76 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata for GPU image
- name: Extract metadata (tags, labels) for GPU Docker
id: meta-gpu
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=raw,value=latest
# Set up image names (converting to lowercase)
- name: Set image names
run: |
echo "GPU_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-gpu" >> $GITHUB_ENV
echo "CPU_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-cpu" >> $GITHUB_ENV
echo "UI_IMAGE_NAME=${{ env.REGISTRY }}/$(echo ${{ env.IMAGE_NAME }} | tr '[:upper:]' '[:lower:]')-ui" >> $GITHUB_ENV
# Extract metadata for CPU image
- name: Extract metadata (tags, labels) for CPU Docker
id: meta-cpu
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=-cpu
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=raw,value=latest
# Build and push GPU version
- name: Build and push GPU Docker image
# Build GPU version
- name: Build GPU Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta-gpu.outputs.tags }}
labels: ${{ steps.meta-gpu.outputs.labels }}
file: ./docker/gpu/Dockerfile
push: false
load: true
tags: ${{ env.GPU_IMAGE_NAME }}:v0.1.0
build-args: |
DOCKER_BUILDKIT=1
platforms: linux/amd64

# Build and push CPU version
- name: Build and push CPU Docker image
# Slim GPU version
- name: Slim GPU Docker image
uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
with:
target: ${{ env.GPU_IMAGE_NAME }}:v0.1.0
tag: v0.1.0-slim

# Push GPU versions
- name: Push GPU Docker images
run: |
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0
docker push ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim
docker tag ${{ env.GPU_IMAGE_NAME }}:v0.1.0 ${{ env.GPU_IMAGE_NAME }}:latest
docker tag ${{ env.GPU_IMAGE_NAME }}:v0.1.0-slim ${{ env.GPU_IMAGE_NAME }}:latest-slim
docker push ${{ env.GPU_IMAGE_NAME }}:latest
docker push ${{ env.GPU_IMAGE_NAME }}:latest-slim
# Build CPU version
- name: Build CPU Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.cpu
push: true
tags: ${{ steps.meta-cpu.outputs.tags }}
labels: ${{ steps.meta-cpu.outputs.labels }}
file: ./docker/cpu/Dockerfile
push: false
load: true
tags: ${{ env.CPU_IMAGE_NAME }}:v0.1.0
build-args: |
DOCKER_BUILDKIT=1
platforms: linux/amd64

# Extract metadata for UI image
- name: Extract metadata (tags, labels) for UI Docker
id: meta-ui
uses: docker/metadata-action@v5
# Slim CPU version
- name: Slim CPU Docker image
uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=-ui
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=raw,value=latest
target: ${{ env.CPU_IMAGE_NAME }}:v0.1.0
tag: v0.1.0-slim

# Push CPU versions
- name: Push CPU Docker images
run: |
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0
docker push ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim
docker tag ${{ env.CPU_IMAGE_NAME }}:v0.1.0 ${{ env.CPU_IMAGE_NAME }}:latest
docker tag ${{ env.CPU_IMAGE_NAME }}:v0.1.0-slim ${{ env.CPU_IMAGE_NAME }}:latest-slim
docker push ${{ env.CPU_IMAGE_NAME }}:latest
docker push ${{ env.CPU_IMAGE_NAME }}:latest-slim
# Build and push UI version
- name: Build and push UI Docker image
Expand All @@ -97,8 +109,11 @@ jobs:
context: ./ui
file: ./ui/Dockerfile
push: true
tags: ${{ steps.meta-ui.outputs.tags }}
labels: ${{ steps.meta-ui.outputs.labels }}
tags: |
${{ env.UI_IMAGE_NAME }}:v0.1.0
${{ env.UI_IMAGE_NAME }}:latest
build-args: |
DOCKER_BUILDKIT=1
platforms: linux/amd64

create-release:
Expand All @@ -108,13 +123,16 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Create Release
uses: softprops/action-gh-release@v1
env:
IS_PRERELEASE: ${{ contains(github.ref, '-pre') }}
with:
generate_release_notes: true
draft: false
prerelease: false
prerelease: ${{ contains(github.ref, '-pre') }}
71 changes: 49 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,78 @@
.git

# Python
__pycache__
__pycache__/
*.pyc
*.pyo
*.pyd
*.pt
.Python
*.py[cod]
*$py.class
.Python
.pytest_cache
.coverage
.coveragerc

# Python package build artifacts
*.egg-info/
*.egg
dist/
build/

# Environment
# .env
.venv
.venv/
env/
venv/
ENV/

# IDE
.idea
.vscode
.idea/
.vscode/
*.swp
*.swo

# Project specific
*examples/*.wav
*examples/*.pcm
*examples/*.mp3
*examples/*.flac
*examples/*.acc
*examples/*.ogg
# Model files
*.pt
*.pth
*.tar*

# Voice files
api/src/voices/af_bella.pt
api/src/voices/af_nicole.pt
api/src/voices/af_sarah.pt
api/src/voices/af_sky.pt
api/src/voices/af.pt
api/src/voices/am_adam.pt
api/src/voices/am_michael.pt
api/src/voices/bf_emma.pt
api/src/voices/bf_isabella.pt
api/src/voices/bm_george.pt
api/src/voices/bm_lewis.pt

# Audio files
examples/*.wav
examples/*.pcm
examples/*.mp3
examples/*.flac
examples/*.acc
examples/*.ogg
examples/speech.mp3
examples/phoneme_examples/output/example_1.wav
examples/phoneme_examples/output/example_2.wav
examples/phoneme_examples/output/example_3.wav

# Other project files
Kokoro-82M/
ui/data
tests/
*.md
*.txt
requirements.txt
ui/data/
EXTERNAL_UV_DOCUMENTATION*

# Docker
Dockerfile*
docker-compose*

*.egg-info
*.pt
*.wav
*.tar*
examples/assorted_checks/River_of_Teet_-_Sarah_Gailey.epub
examples/ebook_test/chapter_to_audio.py
examples/ebook_test/chapters_to_audio.py
examples/ebook_test/parse_epub.py
examples/ebook_test/River_of_Teet_-_Sarah_Gailey.epub
examples/ebook_test/River_of_Teet_-_Sarah_Gailey.txt
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
3 changes: 2 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
line-length = 88

exclude = ["examples"]

[lint]
select = ["I"]

[lint.isort]
combine-as-imports = true
force-wrap-aliases = true
length-sort = true
split-on-trailing-comma = true
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

Notable changes to this project will be documented in this file.

## [v0.1.0] - 2025-01-13
### Changed
- Major Docker improvements:
- Baked model directly into Dockerfile for improved deployment reliability
- Switched to uv for dependency management
- Streamlined container builds and reduced image sizes
- Dependency Management:
- Migrated from pip/poetry to uv for faster, more reliable package management
- Added uv.lock for deterministic builds
- Updated dependency resolution strategy

## [v0.0.5post1] - 2025-01-11
### Fixed
- Docker image tagging and versioning improvements (-gpu, -cpu, -ui)
Expand Down
Loading

0 comments on commit 5045cf9

Please sign in to comment.