Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

circleci and github actions #800

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
72 changes: 52 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,46 @@
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
version: 2.1

# -------------------------------------------------------------------------------------
# Environments to run the jobs in
# -------------------------------------------------------------------------------------
cpu: &cpu
environment:
TERM: xterm
machine:
image: default
resource_class: medium

gpu: &gpu
environment:
CUDA_VERSION: "10.2"
TERM: xterm
machine:
image: ubuntu-1604:202104-01
image: linux-cuda-11:2023.02.1
resource_class: gpu.nvidia.small.multi # NVIDIA Tesla T4 2 GPU 4 vCPUs 15 GB RAM (2 GPUs)



version_parameters: &version_parameters
parameters:
pytorch_index:
type: string
# use test wheels index to have access to RC wheels
# https://download.pytorch.org/whl/test/torch_test.html
default: "https://download.pytorch.org/whl/torch_stable.html"
python_version: # NOTE: only affects linux
type: string
default: '3.10.6'
cuda_version:
type: string
default: '11.6'
TERM:
type: string
default: 'xterm'

environment:
PYTORCH_INDEX: << parameters.pytorch_index >>
PYTHON_VERSION: << parameters.python_version>>
CUDA_VERSION: << parameters.cuda_version >>
TERM: << parameters.TERM >>

# -------------------------------------------------------------------------------------
# Re-usable commands
# -------------------------------------------------------------------------------------
Expand All @@ -41,8 +61,8 @@ install_python: &install_python
name: Install Python
working_directory: ~/
command: |
pyenv install 3.6.2
pyenv global 3.6.2
pyenv install << parameters.python_version >>
pyenv global << parameters.python_version >>
which python
which pip

Expand Down Expand Up @@ -75,6 +95,12 @@ setup_cuda: &setup_cuda
time sudo dpkg -i ~/nvidia-downloads/cuda-repo-ubuntu1604-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
nvidia-smi

select_cuda: &select_cuda
- run:
name: Select CUDA
command: |
sudo update-alternatives --set cuda /usr/local/cuda-<< parameters.cuda_version >>

check_cuda_available: &check_cuda_available
- run:
name: Check CUDA Available
Expand Down Expand Up @@ -115,6 +141,7 @@ run_tests: &run_tests
jobs:
cpu_tests:
<<: *cpu
<<: *version_parameters

working_directory: ~/ClassyVision

Expand All @@ -130,9 +157,9 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v9-cpu-dependencies-{{ checksum "requirements.txt" }}
- v10-cpu-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v9-cpu-dependencies-
- v10-cpu-dependencies-

- <<: *install_dev_dep

Expand All @@ -143,7 +170,7 @@ jobs:
- save_cache:
paths:
- ~/venv
key: v9-cpu-dependencies-{{ checksum "requirements.txt" }}
key: v10-cpu-dependencies-{{ checksum "requirements.txt" }}

- <<: *run_tests

Expand All @@ -166,13 +193,16 @@ jobs:

gpu_tests:
<<: *gpu
<<: *version_parameters


working_directory: ~/ClassyVision

steps:
- checkout

- <<: *setup_cuda
# - <<: *setup_cuda
- <<: *select_cuda

- <<: *install_python

Expand All @@ -183,9 +213,9 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v6-gpu-dependencies-{{ checksum "requirements.txt" }}
- v7-gpu-dependencies-{{ checksum "requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v6-gpu-dependencies-
- v7-gpu-dependencies-

- <<: *install_dev_dep

Expand All @@ -198,20 +228,22 @@ jobs:
- save_cache:
paths:
- ~/venv
key: v6-gpu-dependencies-{{ checksum "requirements.txt" }}
key: v7-gpu-dependencies-{{ checksum "requirements.txt" }}

- <<: *run_tests


gpu_tests_bc:
<<: *gpu
<<: *version_parameters

working_directory: ~/ClassyVision

steps:
- checkout

- <<: *setup_cuda
# - <<: *setup_cuda
- <<: *select_cuda

- <<: *install_python

Expand All @@ -222,9 +254,9 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v3-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }}
- v4-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }}
# fallback to using the latest cache if no exact match is found
- v3-gpu-bc-dependencies-
- v4-gpu-bc-dependencies-

- <<: *install_dev_dep

Expand All @@ -237,7 +269,7 @@ jobs:
- save_cache:
paths:
- ~/venv
key: v3-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }}
key: v4-gpu-bc-dependencies-{{ checksum "requirements_test_bc.txt" }}

- <<: *run_tests

Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI
on: [push, pull_request]

# Run linter with github actions for quick feedbacks.
# Run macos tests with github actions. Linux (CPU & GPU) tests currently runs on CircleCI
jobs:
linter:
runs-on: ubuntu-latest
# run on PRs, or commits to facebookresearch (not internal)
if: ${{ github.repository_owner == 'facebookresearch' || github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10
- name: Install dependencies
# flake8-bugbear flake8-comprehensions are useful but not available internally
run: |
python -m pip install --upgrade pip
python -m pip install flake8==6.0.0 isort==5.12.0
python -m pip install black==23.1.0
flake8 --version
- name: Lint
run: |
echo "Running isort"
isort -c -sp .
echo "Running black"
black -l 100 --check .
echo "Running flake8"
flake8 .
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: stable
hooks:
- id: black
language_version: python3.6
language_version: python3.10

- repo: https://github.com/timothycrosley/isort
rev: stable
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Classy Vision is beta software. The project is under active development and our
## Installation

#### Installation Requirements
Make sure you have an up-to-date installation of PyTorch (1.6), Python (3.6) and torchvision (0.7). If you want to use GPUs, then a CUDA installation (10.1) is also required.
Make sure you have an up-to-date installation of PyTorch (1.12), Python (3.8) and torchvision (0.13). If you want to use GPUs, then a CUDA installation (11.6) is also required.

#### Installing the latest stable release
To install Classy Vision via pip:
Expand Down
4 changes: 2 additions & 2 deletions classy_vision/dataset/transforms/autoaugment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# https://github.com/DeepVoltaire/AutoAugment/blob/master/autoaugment.py

import random
from enum import auto, Enum
from enum import Enum, auto
from functools import partial
from typing import Any, Callable, NamedTuple, Sequence, Tuple

Expand Down Expand Up @@ -165,7 +165,7 @@ def get_image_op_settings(
ImageOp.ROTATE: ImageOpSetting(np.linspace(0, 30, 10), rotate_with_fill),
ImageOp.COLOR: ImageOpSetting(np.linspace(0.0, 0.9, 10), color),
ImageOp.POSTERIZE: ImageOpSetting(
np.round(np.linspace(8, 4, 10), 0).astype(np.int), posterize
np.round(np.linspace(8, 4, 10), 0).astype(np.int64), posterize
),
ImageOp.SOLARIZE: ImageOpSetting(np.linspace(256, 0, 10), solarize),
ImageOp.CONTRAST: ImageOpSetting(np.linspace(0.0, 0.9, 10), contrast),
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fvcore>=0.1.3
setuptools<58
setuptools>=67.5.0
torch>=1.6
torchvision>=0.7
wheel
wheel
6 changes: 3 additions & 3 deletions requirements_test_bc.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
torch==1.6
torchvision==0.7
fvcore>=0.1.3
torch>=1.13.1
torchvision>=0.14.1
fvcore>=0.1.5.post20221221
18 changes: 10 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


if __name__ == "__main__":
if sys.version_info < (3, 6):
sys.exit("Sorry, Python >=3.6 is required for Classy Vision.")
if sys.version_info < (3, 8):
sys.exit("Sorry, Python >=3.8 is required for Classy Vision.")

# get version string from module
with open(
Expand Down Expand Up @@ -43,21 +43,21 @@
"Source": "https://github.com/facebookresearch/ClassyVision",
},
license="MIT License",
python_requires=">=3.6",
python_requires=">=3.8",
packages=find_packages(exclude=("tests",))
+ find_namespace_packages(include=["hydra_plugins.*"]),
install_requires=reqs.strip().split("\n"),
extras_require={
"dev": [
"GitPython",
"black==19.3b0",
"black>=23.1.0",
"sphinx",
"isort==5.2.2",
"isort>=5.12.0",
"bs4",
"nbconvert==6.0.7",
"nbconvert>=7.2.9",
"pre-commit",
"parameterized",
"fairscale==0.3.7",
"fairscale>=0.4.13",
]
},
package_data={"classy_vision": ["configs/*.json", "templates"]},
Expand All @@ -68,7 +68,9 @@
keywords=["deep learning", "pytorch", "AI"],
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
Expand Down
6 changes: 3 additions & 3 deletions test/hooks_profiler_hook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import unittest
import unittest.mock as mock

from classy_vision.hooks import ProfilerHook
from test.generic.config_utils import get_test_classy_task, get_test_classy_video_task
from test.generic.hook_test_utils import HookTestBase

from classy_vision.hooks import ProfilerHook


class TestProfilerHook(HookTestBase):
def test_constructors(self) -> None:
Expand All @@ -23,7 +23,7 @@ def test_constructors(self) -> None:
config=config, hook_type=ProfilerHook, hook_registry_name="profiler"
)

@mock.patch("torch.autograd.profiler.profile", auto_spec=True)
@mock.patch("torch.autograd.profiler.profile", autospec=True)
@mock.patch("classy_vision.hooks.profiler_hook.summarize_profiler_info")
def test_profiler(
self,
Expand Down
2 changes: 1 addition & 1 deletion tutorials/classy_dataset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -599,4 +599,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}