-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
761 additions
and
684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
|
||
name: Python package | ||
|
||
on: [push] | ||
name: Test with pytest | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
- sd3 | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
- sd3 | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: ["3.10"] | ||
python-version: ["3.10"] # Python versions to test | ||
pytorch-version: ["2.4.0"] # PyTorch versions to test | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: python -m pip install --upgrade pip setuptools wheel | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
|
||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
cache: 'pip' # caching pip dependencies | ||
- name: Install and update pip, setuptools, wheel | ||
run: | | ||
# Setuptools, wheel for compiling some packages | ||
python -m pip install --upgrade pip setuptools wheel | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install dadaptation==3.2 torch==2.4.0 torchvision==0.19.0 accelerate==0.33.0 | ||
# Pre-install torch to pin version (requirements.txt has dependencies like transformers which requires pytorch) | ||
pip install dadaptation==3.2 torch==${{ matrix.pytorch-version }} torchvision==0.19.0 pytest==8.3.4 | ||
pip install -r requirements.txt | ||
- name: Test with pytest | ||
run: | | ||
pip install pytest | ||
pytest | ||
run: pytest # See pytest.ini for configuration | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Tests | ||
|
||
## Install | ||
|
||
``` | ||
pip install pytest | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
pytest | ||
``` | ||
|
||
## Contribution | ||
|
||
Pytest is configured to run tests in this directory. It might be a good idea to add tests closer in the code, as well as doctests. | ||
|
||
Tests are functions starting with `test_` and files with the pattern `test_*.py`. | ||
|
||
``` | ||
def test_x(): | ||
assert 1 == 2, "Invalid test response" | ||
``` | ||
|
||
## Resources | ||
|
||
### pytest | ||
|
||
- https://docs.pytest.org/en/stable/index.html | ||
- https://docs.pytest.org/en/stable/how-to/assert.html | ||
- https://docs.pytest.org/en/stable/how-to/doctest.html | ||
|
||
### PyTorch testing | ||
|
||
- https://circleci.com/blog/testing-pytorch-model-with-pytest/ | ||
- https://pytorch.org/docs/stable/testing.html | ||
- https://github.com/pytorch/pytorch/wiki/Running-and-writing-tests | ||
- https://github.com/huggingface/pytorch-image-models/tree/main/tests | ||
- https://github.com/pytorch/pytorch/tree/main/test | ||
|
Oops, something went wrong.