Skip to content

Commit

Permalink
Move from poetry to hatch (#227)
Browse files Browse the repository at this point in the history
* init change from poetry to hatch

* fix quality

* fix quality and tests

* fix CI

* remove alignment

* quality:format

* move project to src folder

* simplify docker for deploy

* update usage information

* fix ci

* fix tests

* authorize python from 3.8 to 3.11

* remove old alignment deps

* clean up unused utility functions

* release v0.5.0
  • Loading branch information
Thomas Chaigneau authored Sep 1, 2023
1 parent d303ac0 commit 631e078
Show file tree
Hide file tree
Showing 53 changed files with 457 additions and 6,208 deletions.
3 changes: 0 additions & 3 deletions .darglint

This file was deleted.

8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ __pycache__
.nox
.pre-commit-config.yaml
.pytest_cache
.ruff_cache
convert_whisper_model.py
data
dist
LICENSE
nginx.conf
notebooks
noxfile.py
test.py
tests
whisper_model
whisper_model_he
wordcab_transcribe/**/__pycache__
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# The name of the project, used for API documentation.
PROJECT_NAME="Wordcab Transcribe"
# The version of the project, used for API documentation.
VERSION="0.4.0"
VERSION="0.5.0"
# The description of the project, used for API documentation.
DESCRIPTION="💬 ASR FastAPI server using faster-whisper and Auto-Tuning Spectral Clustering for diarization."
# This API prefix is used for all endpoints in the API outside of the status and cortex endpoints.
Expand Down
9 changes: 0 additions & 9 deletions .flake8

This file was deleted.

5 changes: 0 additions & 5 deletions .github/workflows/constraints.txt

This file was deleted.

173 changes: 34 additions & 139 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,171 +1,66 @@
name: Quality Checks

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
pull_request:
paths:
- "wordcab_transcribe/**"
- "tests/**"
workflow_dispatch:
- .github/workflows/ci-cd.yaml
- src/**
- tests/**
release:
types:
- published

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
quality:
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- { python: "3.9", os: "ubuntu-latest", session: "pre-commit" }
env:
NOXSESSION: ${{ matrix.session }}
FORCE_COLOR: "1"
PRE_COMMIT_COLOR: "always"
steps:
- name: Check out the repository
uses: actions/checkout@v3

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

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
import sys
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
print("::set-output name=result::{}".format(result))
- name: Restore pre-commit cache
uses: actions/cache@v3
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-
- name: Run Nox
run: |
nox --python=${{ matrix.python }}
tests:
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [quality]
strategy:
fail-fast: true
matrix:
include:
- { python: "3.9", os: "ubuntu-latest", session: "tests" }
env:
NOXSESSION: ${{ matrix.session }}
FORCE_COLOR: "1"
PRE_COMMIT_COLOR: "always"
WORDCAB_API_KEY: ${{ secrets.WORDCAB_API_KEY }}
check-quality:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
- name: checkout
uses: actions/checkout@v3

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

- name: Upgrade pip
- name: install-dependencies
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Run Nox
python -m pip install --upgrade pip
pip install ".[quality]"
- name: check-quality
run: |
nox --python=${{ matrix.python }}
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v3"
with:
name: coverage-data
path: ".coverage.*"
black --check --diff --preview src tests
ruff src tests
run-tests:
needs: check-quality

coverage:
runs-on: ubuntu-latest
needs: tests

steps:
- name: Check out the repository
- name: checkout
uses: actions/checkout@v3

- name: Set up Python
- name: setup-python
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: 3.8

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip --version
- name: Install Poetry
- name: install-dependencies
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage-data
python -m pip install --upgrade pip
pip install ".[tests]"
- name: Combine coverage data and display human readable report
run: |
nox --session=coverage
- name: Create coverage report
run: |
nox --session=coverage -- xml
- name: run-tests
run: pytest --cov=wordcab_transcribe --cov-report=term-missing tests/ -s --durations 0
57 changes: 0 additions & 57 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ __pycache__/
.coverage.*
.DS_Store
.nox/
.pytest_cache/
.python-version
.ruff_cache/
/.pytype/
/data/
/dist/
Expand Down
68 changes: 14 additions & 54 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,21 @@
repos:
- repo: local
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.3.0"
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
require_serial: true
- id: check-added-large-files
name: Check for added large files
entry: check-added-large-files
language: system
- id: check-toml
name: Check Toml
entry: check-toml
language: system
types: [toml]
- id: check-yaml
name: Check Yaml
entry: check-yaml
language: system
types: [yaml]
- id: end-of-file-fixer
name: Fix End of Files
entry: end-of-file-fixer
language: system
types: [text]
stages: [commit, push, manual]
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
require_serial: true
args: [--darglint-ignore-regex, .*]
- id: isort
name: isort
entry: isort
require_serial: true
language: system
types_or: [cython, pyi, python]
args: ["--filter-files"]
- id: pyupgrade
name: pyupgrade
description: Automatically upgrade syntax for newer versions.
entry: pyupgrade
language: system
types: [python]
args: [--py37-plus]
- id: trailing-whitespace
name: Trim Trailing Whitespace
entry: trailing-whitespace-fixer
language: system
types: [text]
stages: [commit, push, manual]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.0

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args: ["--preview"]
language_version: python3

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.263"
hooks:
- id: prettier
- id: ruff
args: [--fix]
exclude: ^notebooks/
Loading

0 comments on commit 631e078

Please sign in to comment.