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

Add CI via Github actions #107

Merged
merged 4 commits into from
Mar 16, 2024
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
41 changes: 41 additions & 0 deletions .github/workflows/tests_full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Full set of tests for PRs and master branch"
on:
push:
branches:
- "master"
pull_request:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Nox
run: pip install nox==2024.03.02
- name: Run tests
run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}"

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Nox
run: pip install nox==2024.03.02
- name: Lint
run: nox --non-interactive --error-on-missing-interpreter --session "lint"
40 changes: 40 additions & 0 deletions .github/workflows/tests_reduced.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Reduced set of tests for push events"
on:
push:
branches-ignore:
- master

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Nox
run: pip install nox==2024.03.02
- name: Run tests
run: nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python-version }}"

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Nox
run: pip install nox==2024.03.02
- name: Lint
run: nox --non-interactive --error-on-missing-interpreter --session "lint"
7 changes: 6 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ def lint(session):
session.run('flake8', *args)


@nox.session
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
def tests(session):
session.install(
'torch==2.2.1',
'torchvision',
'--index-url', 'https://download.pytorch.org/whl/cpu'
)
session.install('.')
session.install('pytest')
session.install('pytest-mock')
Expand Down
11 changes: 8 additions & 3 deletions src/pytorch_fid/fid_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def tqdm(x):
help=('Dimensionality of Inception features to use. '
'By default, uses pool3 features'))
parser.add_argument('--save-stats', action='store_true',
help=('Generate an npz archive from a directory of samples. '
'The first path is used as input and the second as output.'))
help=('Generate an npz archive from a directory of '
'samples. The first path is used as input and the '
'second as output.'))
parser.add_argument('path', type=str, nargs=2,
help=('Paths to the generated images or '
'to .npz statistic files'))
Expand Down Expand Up @@ -307,7 +308,11 @@ def main():
num_workers = args.num_workers

if args.save_stats:
save_fid_stats(args.path, args.batch_size, device, args.dims, num_workers)
save_fid_stats(args.path,
args.batch_size,
device,
args.dims,
num_workers)
return

fid_value = calculate_fid_given_paths(args.path,
Expand Down