Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

[Feat] Add Github Actions as main CI (#744)

Edgar Riba2e442b66a0b0
diff --git a/.circleci/config.yml b/.circleci/config.yml.old
similarity index 100%
rename from .circleci/config.yml
rename to .circleci/config.yml.old
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 000000000..bad71b443
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,29 @@
+name: test-docs
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ schedule:
+ - cron: "0 4 * * *"
+
+jobs:
+ test-docs:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup conda dependencies
+ uses: conda-incubator/setup-miniconda@v1
+ with:
+ auto-update-conda: true
+ python-version: 3.6
+ - name: Install dependencies
+ shell: bash -l {0}
+ run: |
+ conda install make -c conda-forge
+ pip install -r docs/requirements.txt
+ make install
+ - name: Build Documentation
+ shell: bash -l {0}
+ run: make build-docs
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
new file mode 100644
index 000000000..d45e764d6
--- /dev/null
+++ b/.github/workflows/format.yml
@@ -0,0 +1,54 @@
+name: code-format
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ schedule:
+ - cron: "0 4 * * *"
+
+jobs:
+ code-format:
+ runs-on: [ubuntu-latest]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup conda dependencies
+ uses: conda-incubator/setup-miniconda@v1
+ with:
+ auto-update-conda: true
+ python-version: 3.6
+ - name: Install dependencies
+ shell: bash -l {0}
+ run: |
+ conda install curl make -c conda-forge
+ conda install pytorch cpuonly -c pytorch
+ pip install -r requirements-dev.txt
+ make install
+
+ - name: Run linter
+ shell: bash -l {0}
+ run: make lint
+
+ static-check:
+ runs-on: [ubuntu-latest]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup conda dependencies
+ uses: conda-incubator/setup-miniconda@v1
+ with:
+ auto-update-conda: true
+ python-version: 3.6
+ - name: Install dependencies
+ shell: bash -l {0}
+ run: |
+ conda install curl make -c conda-forge
+ conda install pytorch cpuonly -c pytorch
+ pip install -r requirements-dev.txt
+ make install
+
+ - name: Run mypy
+ shell: bash -l {0}
+ run: make mypy
diff --git a/.github/workflows/python_package.yml b/.github/workflows/python_package.yml
new file mode 100644
index 000000000..a5e85ffed
--- /dev/null
+++ b/.github/workflows/python_package.yml
@@ -0,0 +1,27 @@
+name: Python package
+
+on:
+ schedule:
+ - cron: '0 4 * * *'
+
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ # You can use PyPy versions in python-version.
+ # For example, pypy2 and pypy3
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ python-version: [3.6, 3.7, 3.8]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Download Kornia binary
+ run: |
+ pip install torch -f https://download.pytorch.org/whl/torch_stable.html
+ pip install kornia
+ python -c "import kornia"
diff --git a/.github/workflows/tests_cpu.yml b/.github/workflows/tests_cpu.yml
new file mode 100644
index 000000000..0131e215f
--- /dev/null
+++ b/.github/workflows/tests_cpu.yml
@@ -0,0 +1,41 @@
+name: tests-cpu
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ schedule:
+ - cron: "0 4 * * *"
+
+jobs:
+ tests-cpu:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ python-version: [3.6, 3.7, 3.8]
+ pytorch-version: [1.6.0]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup conda dependencies
+ uses: conda-incubator/setup-miniconda@v1
+ with:
+ auto-update-conda: true
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies
+ shell: bash -l {0}
+ run: |
+ conda install curl make -c conda-forge
+ conda install pytorch=${{ matrix.pytorch-version }} cpuonly -c pytorch
+ pip install -r requirements-dev.txt
+ make install
+ - name: Run Tests
+ shell: bash -l {0}
+ run: pytest -v --device cpu --dtype float32,float64 --cov=kornia --cov-report xml ./test
+ - name: Upload coverage
+ uses: codecov/codecov-action@v1
+ with:
+ file: ./coverage.xml
diff --git a/.github/workflows/tests_cpu_versions.yml b/.github/workflows/tests_cpu_versions.yml
new file mode 100644
index 000000000..21ba13948
--- /dev/null
+++ b/.github/workflows/tests_cpu_versions.yml
@@ -0,0 +1,50 @@
+name: test-cpu-versions
+
+on:
+ #push:
+ # branches:
+ # - master
+ #pull_request:
+ schedule:
+ - cron: "0 4 * * *"
+
+jobs:
+ test-cpu-versions:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ python-version: [3.6, 3.7, 3.8]
+ pytorch-version: [1.5.1, 1.6.0, 1.7.0]
+ pytorch-channel: [pytorch]
+ include:
+ - os: ubuntu-latest
+ pytorch-channel: pytorch-nightly
+ include:
+ - os: macos-latest
+ pytorch-channel: pytorch-nightly
+ include:
+ - os: windows-latest
+ pytorch-channel: pytorch-nightly
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup conda dependencies
+ uses: conda-incubator/setup-miniconda@v1
+ with:
+ auto-update-conda: true
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies
+ shell: bash -l {0}
+ run: |
+ conda install curl make -c conda-forge
+ conda install pytorch=${{ matrix.pytorch-version }} cpuonly -c ${{ matrix.pytorch-channel }}
+ pip install -r requirements-dev.txt
+ make install
+ - name: Run Tests
+ shell: bash -l {0}
+ run: pytest -v --device cpu --dtype float32,float64 --cov=kornia --cov-report xml ./test --flake8 --mypy
+ - name: Upload coverage
+ uses: codecov/codecov-action@v1
+ with:
+ file: ./coverage.xml
diff --git a/.github/workflows/tests_cuda.yml b/.github/workflows/tests_cuda.yml
new file mode 100644
index 000000000..1ff252c67
--- /dev/null
+++ b/.github/workflows/tests_cuda.yml
@@ -0,0 +1,38 @@
+name: tests-cuda
+
+on:
+ #push:
+ # branches:
+ # - master
+ #pull_request:
+ schedule:
+ - cron: "0 4 * * *"
+
+jobs:
+ tests-cuda:
+ container:
+ image: nvcr.io/nvidia/pytorch:20.03-py3
+ options: --gpus all
+ runs-on: [self-hosted, Linux, x64]
+ strategy:
+ fail-fast: false
+ matrix:
+ python-version: [3.7]
+ cuda-version: [9.2, 10.1, 10.2, 11.0]
+ pytorch-channel: [pytorch, pytorch-nightly]
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup conda dependencies
+ uses: goanpeca/setup-miniconda@v1
+ with:
+ miniconda-version: "latest"
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies
+ shell: bash -l {0}
+ run: |
+ conda install pytorch cudatoolkit=${{ matrix.cuda-version }} -c ${{ matrix.pytorch-channel }}
+ pip install -r requirements-dev.txt
+ python setup.py install
+ - name: Run Tests
+ shell: bash -l {0}
+ run: pytest -v --device cuda --dtype float32,float64 ./test
diff --git a/docs/requirements.txt b/docs/requirements.txt
index d54f52b80..46978c3f0 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,5 +1,9 @@
--i https://pypi.python.org/simple
--f https://download.pytorch.org/whl/torch_stable.html
+# docs requirements
+torch>=1.6.0
+torchvision>=0.7.0
+opencv-python==4.2.0.34
+matplotlib==3.1.1
+# sphinx
sphinx==2.1.2
sphinx-gallery==0.4.0
sphinx_rtd_theme==0.4.3
@@ -7,7 +11,3 @@ sphinxcontrib-bibtex==0.4.2
nbsphinx==0.4.2
nbconvert==5.5.0
notebook==6.0.1
-matplotlib==3.1.1
-opencv-python==4.2.0.34
-torch==1.5.0+cpu
-torchvision==0.6+cpu
diff --git a/path.bash.inc b/path.bash.inc
index 9485d9f27..f88b97284 100644
--- a/path.bash.inc
+++ b/path.bash.inc
@@ -16,7 +16,7 @@ cmd="source $sdk_dir/.dev_env/bin/activate $sdk_dir/.dev_env/envs/venv"
if [ -z $CI ]; then
eval $cmd
else
- echo $cmd >> $BASH_ENV
+ echo $cmd >> "$BASH_ENV"
fi
export PYTHONPATH=$PYTHONPATH:$sdk_dir
diff --git a/requirements-dev.txt b/requirements-dev.txt
new file mode 100644
index 000000000..92d1c2118
--- /dev/null
+++ b/requirements-dev.txt
@@ -0,0 +1,7 @@
+# test
+pytest==5.4.2
+pytest-flake8==1.0.6
+pytest-cov==2.9.0
+pytest-mypy==0.7.0
+autopep8
+pydocstyle
diff --git a/test/geometry/epipolar/test_essential.py b/test/geometry/epipolar/test_essential.py
index 0b5749297..261a7cdc4 100644
--- a/test/geometry/epipolar/test_essential.py
+++ b/test/geometry/epipolar/test_essential.py
@@ -26,6 +26,7 @@ class TestEssentialFromFundamental:
E_mat = epi.essential_from_fundamental(F_mat, K1, K2)
assert E_mat.shape == (B, 3, 3)
+ @pytest.mark.xfail(reason="TODO: fix #685")
def test_from_to_fundamental(self, device, dtype):
F_mat = torch.rand(1, 3, 3, device=device, dtype=dtype)
K1 = torch.rand(1, 3, 3, device=device, dtype=dtype)
@@ -156,6 +157,7 @@ class TestEssentalFromRt:
E_mat = epi.essential_from_Rt(R1, t1, R2, t2)
assert E_mat.shape == (B, 3, 3)
+ @pytest.mark.xfail(reason="TODO: fix #685")
def test_from_fundamental_Rt(self, device, dtype):
scene = utils.generate_two_view_random_scene(device, dtype)
diff --git a/test/geometry/epipolar/test_fundamental.py b/test/geometry/epipolar/test_fundamental.py
index 9311f9866..03746ade8 100644
--- a/test/geometry/epipolar/test_fundamental.py
+++ b/test/geometry/epipolar/test_fundamental.py
@@ -153,6 +153,7 @@ class TestFindFundamental:
F_mat = epi.find_fundamental(points1, points2, weights)
assert_allclose(F_mat, Fm_expected, rtol=1e-4, atol=1e-4)
+ @pytest.mark.xfail(reason="TODO: fix #685")
def test_synthetic_sampson(self, device, dtype):
scene: Dict[str, torch.Tensor] = utils.generate_two_view_random_scene(device, dtype)
diff --git a/test/performance/test_project_points_speed.py b/test/performance/test_project_points_speed.py
index c1c3b5027..0412021e7 100644
--- a/test/performance/test_project_points_speed.py
+++ b/test/performance/test_project_points_speed.py
@@ -7,7 +7,10 @@ import kornia as kornia
points_shapes = [(64, 1024**2, 3), (8192, 8192, 3), (1024**2, 64, 3)]
+# TODO: remove xfail once we have enough gpu bandwith in the CI
+
[email protected](reason='May cause memory issues.')
def test_performance_speed(device, dtype):
if device.type != 'cuda' or not torch.cuda.is_available():
pytest.skip("Cuda not available in system,")