Skip to content

Commit

Permalink
Merge pull request #11 from idiap/weights-only
Browse files Browse the repository at this point in the history
fix(io): only enable load with weights_only in pytorch>=2.4
  • Loading branch information
eginhard authored Nov 4, 2024
2 parents 2f13956 + ee45efc commit 76c031e
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 191 deletions.
72 changes: 20 additions & 52 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defaults:
shell:
bash
jobs:
build-sdist:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -19,70 +19,38 @@ jobs:
if [[ "v$version" != "$tag" ]]; then
exit 1
fi
- uses: actions/setup-python@v5
with:
python-version: 3.9
- run: |
python -m pip install -U pip setuptools wheel build
- run: |
python -m build
- run: |
pip install dist/*.tar.gz
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
build-wheels:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: |
python -m pip install -U pip setuptools wheel build
- run: |
python -m build
- run: |
python -m pip install dist/*.whl
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.27"
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"
- name: Set up Python
run: uv python install 3.12
- name: Build sdist and wheel
run: uv build
- name: Test installation of sdist and wheel
run: |
uv venv --no-project
uv pip install dist/*.tar.gz
uv pip install dist/*.whl
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python-version }}
path: dist/*.whl
name: build
path: dist/*
publish-artifacts:
runs-on: ubuntu-latest
needs: [build-sdist, build-wheels]
needs: [build]
environment:
name: release
url: https://pypi.org/p/coqui-tts-trainer
permissions:
id-token: write
steps:
- run: |
mkdir dist
- uses: actions/download-artifact@v4
with:
name: "sdist"
path: "dist/"
- uses: actions/download-artifact@v4
with:
name: "wheel-3.9"
path: "dist/"
- uses: actions/download-artifact@v4
with:
name: "wheel-3.10"
path: "dist/"
- uses: actions/download-artifact@v4
with:
name: "wheel-3.11"
path: "dist/"
- uses: actions/download-artifact@v4
with:
name: "wheel-3.12"
path: "dist/"
name: build
- run: |
ls -lh dist/
- name: Publish package distributions to PyPI
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/style_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,13 @@ jobs:
python-version: [3.9]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: 'requirements*'
- name: check OS
run: cat /etc/os-release
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y git make gcc
- name: Install/upgrade dev dependencies
run: python3 -m pip install -r requirements.dev.txt
version: "0.4.27"
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Lint check
run: |
make lint
run: make lint
41 changes: 15 additions & 26 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,16 @@ jobs:
uv-resolution: ["lowest-direct", "highest"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: 'requirements*'
- name: check OS
run: cat /etc/os-release
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends git make gcc
- name: Install/upgrade Python setup deps
run: python3 -m pip install --upgrade pip setuptools uv
- name: Install Trainer
run: |
python3 -m uv pip install --resolution=${{ matrix.uv-resolution }} --system "coqui-tts-trainer[dev,test] @ ."
version: "0.4.27"
enable-cache: true
cache-dependency-glob: "**/pyproject.toml"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Unit tests
run: make test_all
run: uv run --resolution=${{ matrix.uv-resolution }} --all-extras coverage run -m pytest trainer tests
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
Expand All @@ -49,18 +39,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: "3.12"
version: "0.4.27"
- uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true
- name: Combine coverage
run: |
python -Im pip install --upgrade coverage[toml]
python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
uv python install
uvx coverage combine
uvx coverage html --skip-covered --skip-empty
uvx coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
uv.lock

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
11 changes: 2 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
repos:
- repo: "https://github.com/pre-commit/pre-commit-hooks"
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
rev: v0.6.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: local
hooks:
- id: generate_requirements.py
name: generate_requirements.py
language: system
entry: python bin/generate_requirements.py
files: "pyproject.toml|requirements.*\\.txt|tools/generate_requirements.py"
43 changes: 27 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,36 @@ If you have a new feature or a bug to squash, go ahead and send a ✨**PR**✨.
Please use the following steps for a ✨**PR**✨.
Let us know if you encounter a problem along the way.

The following steps are tested on an Ubuntu system.
The following steps are tested on an Ubuntu system and require
[uv](https://docs.astral.sh/uv/) for virtual environment management. Choose your
preferred [installation
method](https://docs.astral.sh/uv/getting-started/installation/), e.g. the
standalone installer:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

1. Fork 👟[https://github.com/idiap/coqui-ai-Trainer] by clicking the fork button at the top right corner of the project page.

2. Clone 👟 and add the main repo as a new remote named ```upsteam```.

```bash
$ git clone [email protected]:<your Github name>/coqui-ai-Trainer.git
$ cd coqui-ai-Trainer
$ git remote add upstream https://github.com/idiap/coqui-ai-Trainer.git
git clone [email protected]:<your Github name>/coqui-ai-Trainer.git
cd coqui-ai-Trainer
git remote add upstream https://github.com/idiap/coqui-ai-Trainer.git
```

3. Install 👟 for development.

```bash
$ make install
make install
```

4. Create a new branch with an informative name for your goal.

```bash
$ git checkout -b an_informative_name_for_my_branch
git checkout -b an_informative_name_for_my_branch
```

5. Implement your changes on your new branch.
Expand All @@ -62,42 +70,45 @@ The following steps are tested on an Ubuntu system.
8. Run the tests to see how your updates work with the rest of the project. You can repeat this step multiple times as you implement your changes to make sure you are on the right direction.

```bash
$ make test # stop at the first error
$ make test_all # run all the tests, report all the errors
make test # stop at the first error
make test_all # run all the tests, report all the errors
```

9. Format your code. We use ```ruff``` for code formatting.

```bash
$ make style
make style
```

10. Run the linter and correct the issues raised. We use ```ruff``` for linting. It helps to enforce a coding standard, offers simple refactoring suggestions.
10. Run the linter and correct the issues raised. We use ```ruff``` for linting.
It helps to enforce a coding standard, offers simple refactoring
suggestions. The formatter and linter are also run automatically via
pre-commit.

```bash
$ make lint
make lint
```

11. When things are good, add new files and commit your changes.

```bash
$ git add my_file1.py my_file2.py ...
$ git commit
git add my_file1.py my_file2.py ...
git commit
```

It's a good practice to regularly sync your local copy of the project with the upstream code to keep up with the recent updates.
```bash
$ git fetch upstream
$ git rebase upstream/main
git fetch upstream
git rebase upstream/main
```
12. Send a PR to ```main``` branch.
Push your branch to your fork.
```bash
$ git push -u origin an_informative_name_for_my_branch
git push -u origin an_informative_name_for_my_branch
```
Then go to your fork's Github page and click on 'Pull request' to send your ✨**PR**✨.
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include README.md
include LICENSE.txt
include requirements.dev.txt
recursive-include trainer *.json
recursive-include trainer *.html
recursive-include trainer *.png
Expand Down
18 changes: 8 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@ help:
target_dirs := bin examples tests trainer

test_all: ## run tests and don't stop on an error.
coverage run -m pytest trainer tests
uv run coverage run -m pytest trainer tests

test: ## run tests.
coverage run -m pytest -x trainer tests
uv run coverage run -m pytest -x trainer tests

test_failed: ## only run tests failed the last time.
coverage run -m pytest --ff trainer tests
uv run coverage run -m pytest --ff trainer tests

style: ## update code style.
ruff format ${target_dirs}
uv run --only-dev ruff format ${target_dirs}

lint: ## run linter.
ruff check ${target_dirs}

dev-deps: ## install development deps
pip install -r requirements.dev.txt
uv run --only-dev ruff check ${target_dirs}
uv run --only-dev ruff format --check ${target_dirs}

install: ## install 🐸 Trainer for development.
pip install -e .[dev,test]
pre-commit install
uv sync --all-extras
uv run pre-commit install
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ Fork of the [original, unmaintained repository](https://github.com/coqui-ai/Trai

## Installation

From Github:
From PyPI:

```console
git clone https://github.com/idiap/coqui-ai-Trainer
cd coqui-ai-Trainer
make install
pip install coqui-tts-trainer
```

From PyPI:
From Github:

```console
pip install coqui-tts-trainer
git clone https://github.com/idiap/coqui-ai-Trainer
cd coqui-ai-Trainer
pip install -e .
```

## Implementing a model
Expand Down
Loading

0 comments on commit 76c031e

Please sign in to comment.