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

migrate prototype CI to Nova #7037

Merged
merged 23 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 21 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
96 changes: 96 additions & 0 deletions .github/workflows/prototype-tests-linux-gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Prototype tests on Linux

on:
pull_request:

jobs:
tests:
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
gpu-arch-type: ["cpu"]
gpu-arch-version: [""]
runner: ["linux.2xlarge"]
include:
- python-version: "3.8"
gpu-arch-type: cuda
gpu-arch-version: "11.6"
runner: linux.4xlarge.nvidia.gpu
fail-fast: false
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
job-name: Python ${{ matrix.python-version }}, ${{ matrix.gpu-arch-type }}
repository: pytorch/vision
gpu-arch-type: ${{ matrix.gpu-arch-type }}
gpu-arch-version: ${{ matrix.gpu-arch-version }}
runner: ${{ matrix.runner }}
timeout: 45
script: |
# Mark Build Directory Safe
git config --global --add safe.directory /__w/vision/vision
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osalpekar we should probably just do this in the base linux_job.yml if everyone is having to recreate this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need it though? I've removed it in 119dc41 and the build is green: https://github.com/pytorch/vision/actions/runs/3731505086/jobs/6329814912. Under what circumstance do we need to? IIRC, this is only related to git submodules which we don't have. I guess it is not harmful, we can just do it by default.


echo '::group::Set PyTorch conda channel'
if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
POSTFIX=test
else
POSTFIX=nightly
fi
PYTORCH_CHANNEL=pytorch-"${POSTFIX}"
echo "${PYTORCH_CHANNEL}"
echo '::endgroup::'

echo '::group::Set PyTorch conda mutex'
if [[ ${{ matrix.gpu-arch-type }} = 'cuda' ]]; then
PYTORCH_MUTEX="pytorch-cuda=${{ matrix.gpu-arch-version }}"
else
PYTORCH_MUTEX=cpuonly
fi
echo "${PYTORCH_MUTEX}"
echo '::endgroup::'

echo '::group::Create conda environment'
conda create --prefix $PWD/ci \
--quiet --yes \
python=${{ matrix.python-version }} \
numpy libpng jpeg scipy
conda activate $PWD/ci
echo '::endgroup::'

echo '::group::Install PyTorch'
conda install \
--quiet --yes \
-c "${PYTORCH_CHANNEL}" \
-c nvidia \
pytorch \
"${PYTORCH_MUTEX}"
if [[ ${{ matrix.gpu-arch-type }} = 'cuda' ]]; then
python3 -c "import torch; exit(not torch.cuda.is_available())"
fi
echo '::endgroup::'

echo '::group::Install TorchVision'
python setup.py develop
echo '::endgroup::'

echo '::group::Collect PyTorch environment information'
python -m torch.utils.collect_env
echo '::endgroup::'

echo '::group::Install testing utilities'
pip install --progress-bar=off pytest pytest-mock pytest-cov
echo '::endgroup::'

echo '::group::Run prototype tests'
# We don't want to run the prototype datasets tests. Since the positional glob into `pytest`, i.e.
# `test/test_prototype*.py` takes the highest priority, neither `--ignore` nor `--ignore-glob` can help us here.
rm test/test_prototype_datasets*.py
pytest \
--durations=25 \
--cov=torchvision/prototype \
--cov-report=term-missing \
test/test_prototype*.py
echo '::endgroup::'
73 changes: 0 additions & 73 deletions .github/workflows/prototype-tests.yml

This file was deleted.

69 changes: 0 additions & 69 deletions .github/workflows/prototype-transforms-tests-linux-gpu.yml

This file was deleted.

15 changes: 12 additions & 3 deletions test/test_prototype_transforms_consistency.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import enum
import importlib.machinery
import importlib.util
import inspect
import random
import re
from collections import defaultdict
from importlib.machinery import SourceFileLoader
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -890,8 +891,16 @@ def test_aa(self, inpt, interpolation):


def import_transforms_from_references(reference):
ref_det_filepath = Path(__file__).parent.parent / "references" / reference / "transforms.py"
return SourceFileLoader(ref_det_filepath.stem, ref_det_filepath.as_posix()).load_module()
HERE = Path(__file__).parent
PROJECT_ROOT = HERE.parent

loader = importlib.machinery.SourceFileLoader(
"transforms", str(PROJECT_ROOT / "references" / reference / "transforms.py")
)
spec = importlib.util.spec_from_loader("transforms", loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
return module


det_transforms = import_transforms_from_references("detection")
Expand Down
8 changes: 4 additions & 4 deletions test/test_prototype_transforms_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,10 @@ def _compute_expected_bbox(bbox, angle_, expand_, center_):
)
transformed_points = np.matmul(points, affine_matrix.T)
out_bbox = [
np.min(transformed_points[:4, 0]),
np.min(transformed_points[:4, 1]),
np.max(transformed_points[:4, 0]),
np.max(transformed_points[:4, 1]),
float(np.min(transformed_points[:4, 0])),
float(np.min(transformed_points[:4, 1])),
float(np.max(transformed_points[:4, 0])),
float(np.max(transformed_points[:4, 1])),
]
if expand_:
tr_x = np.min(transformed_points[4:, 0])
Expand Down