Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ed761db
Create and test pysyft package on various Pythons
karlhigley Jan 18, 2020
0b2f14a
Rework build script to run tests like Travis
karlhigley Jan 18, 2020
85c8dc3
Update Python versions to 3.6+
karlhigley Jan 18, 2020
5b84e78
Remove Python 3.8 since Torch doesn't support it
karlhigley Jan 18, 2020
414683a
Only run the tutorial translation tests when the tutorials change
karlhigley Jan 18, 2020
96d30f1
Measure process time instead of wall time in efficiency tests
karlhigley Jan 19, 2020
9375d3d
Increase `max_time` for `test_inv_sym` closer to original value
karlhigley Jan 19, 2020
9596572
Rework "test all notebooks" tests to split off translation tests
karlhigley Jan 19, 2020
a3aef8f
Create a separate section in the action logs for coverage reports
karlhigley Jan 19, 2020
78d292b
Exclude translation tests from coverage checks
karlhigley Jan 19, 2020
91d9712
Bump `test_inv_sym` execution time limit to 30
karlhigley Jan 20, 2020
12d4485
Omit `.github` directory from code coverage checking
karlhigley Jan 20, 2020
a9e2729
Fix translation notebooks test to account for excluded notebooks
karlhigley Jan 20, 2020
84db3eb
Move coverage exclusions into setup.cfg instead of .travis.yml
karlhigley Jan 20, 2020
a423b4f
Merge branch 'master' into package-testing-action
karlhigley Jan 20, 2020
3a59a7e
Omit the efficiency tests from Github Action check suite
karlhigley Jan 22, 2020
a2233ef
Unwind changes to the efficiency tests (now skipped in check suite)
karlhigley Jan 22, 2020
c8f5ee6
Merge branch 'master' into package-testing-action
karlhigley Jan 22, 2020
b75981f
Stop using efficiency test time assertions outside the efficiency tests
karlhigley Jan 22, 2020
e20506d
Standardize the name of the efficiency tests module
karlhigley Jan 22, 2020
7be058f
Fix efficiency assertion imports
karlhigley Jan 22, 2020
44780cd
Fix a missing wildcard in the coverage omission flag
karlhigley Jan 22, 2020
874e99d
Apply testing workflow to PR creation, synchronization, and reopening
karlhigley Jan 23, 2020
587a80d
Clean up coverage check inclusions and exclusions
karlhigley Jan 23, 2020
4000921
Fix triggering events section
karlhigley Jan 23, 2020
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
60 changes: 60 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Run tests

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
hash -r
pip3 install -r pip-dep/requirements.txt
pip3 install -r pip-dep/requirements_dev.txt
pip3 install -r pip-dep/requirements_udacity.txt
pip3 install -r pip-dep/requirements_notebooks.txt
pip3 install scikit-learn
python setup.py install
- name: Lint, format, and type-check
Copy link
Member

@vvmnnnkv vvmnnnkv Jan 23, 2020

Choose a reason for hiding this comment

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

Not sure this will help to speed up things much, but what if we run linting tools before deps installation?
Turnaround for formatting errors would be faster, in theory :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree!

Copy link
Contributor

Choose a reason for hiding this comment

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

You might need to keep pip3 install -r pip-dep/requirements_dev.txt however

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was considering running linting as a completely separate action, since the first failure will cancel other actions in progress. Let's leave that for a future issue/PR though?

run: |
pip3 install flake8
#- pip3 install flake8-docstrings
pip3 install flake8-comprehensions
pip3 install pep8-naming
# stop the build if there are Python syntax errors or undefined names
flake8 --config=.flake8 .
black --check --verbose .
# exit-zero treats all errors as warnings.
# diverting from the standard 79 character line length in
# accordance with this:
# https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds
flake8 . --count --exit-zero --statistics --select=E,F,W,C90
# Run type checker in CI such that type errors can be identified and gradually addressed.
# Once all existing type errors are addressed, the `|| echo` after the mypy call can be removed.
mypy syft || echo "Type errors found, continuing build..."
- name: Test with pytest
run: |
coverage run -m pytest test --deselect=test/notebooks/test_notebooks.py::test_notebooks_basic_translations --deselect=test/notebooks/test_notebooks.py::test_all_translation_notebooks --deselect=test/efficiency
- name: Coverage reports
run: |
coverage report --ignore-errors --fail-under 95 -m
# ensuring coverage of tests stays at 100 until entire coverage can be 100
coverage report --ignore-errors --fail-under 100 -m --include="test/*"
36 changes: 36 additions & 0 deletions .github/workflows/run-translation-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run notebook translation tests

on:
push:
paths:
- 'examples/tutorials/**'

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
hash -r
pip3 install -r pip-dep/requirements.txt
pip3 install -r pip-dep/requirements_dev.txt
pip3 install -r pip-dep/requirements_udacity.txt
pip3 install -r pip-dep/requirements_notebooks.txt
pip3 install scikit-learn
python setup.py install
- name: Test with pytest
run: |
pytest test test/notebooks/test_notebooks.py::test_notebooks_basic_translations
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ before_script:
- mypy syft || echo "Type errors found, continuing build..."
script:
- coverage run -m pytest test
- coverage report --omit="syft/grid/*","syft/frameworks/torch/nn/rnn.py" --ignore-errors --fail-under 95 -m
- coverage report --ignore-errors --fail-under 95 -m
# ensuring coverage of tests stays at 100 until entire coverage can be 100
- coverage report --ignore-errors --fail-under 100 -m --include="test/*"
# - bash scripts/execute_notebooks.sh
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ omit =
*/venv/*
setup.py
.eggs/*
.github/*
*__init__.py
*tf_encrypted*
syft/grid/*
syft/frameworks/torch/nn/rnn.py
syft/workers/websocket_server.py
test/efficiency/*

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import torch
import syft as sy
from test.efficiency_tests.assertions import assert_time
from test.efficiency.assertions import assert_time


@pytest.mark.parametrize("activation", ["tanh", "sigmoid"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import syft as sy
from syft.frameworks.torch.linalg import inv_sym
from syft.frameworks.torch.linalg.operations import _norm_mpc
from test.efficiency_tests.assertions import assert_time
from test.efficiency.assertions import assert_time


@assert_time(max_time=40)
Expand Down
12 changes: 6 additions & 6 deletions test/notebooks/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_notebooks_basic(isolated_filesystem, notebook):
@pytest.mark.parametrize(
"translated_notebook", sorted(set(translated_notebooks) - set(excluded_notebooks))
)
def test_notebooks_basic_translations(isolated_filesystem, translated_notebook):
def test_notebooks_basic_translations(isolated_filesystem, translated_notebook): # pragma: no cover
"""Test Notebooks in the tutorial translations folder."""
notebook = "/".join(translated_notebook.split("/")[-2:])
notebook = f"translations/{notebook}"
Expand Down Expand Up @@ -174,11 +174,6 @@ def test_fl_with_websockets_and_averaging(


### These tests must always be last
def test_all_non_excluded_notebooks():
untested_notebooks = set(all_notebooks) - set(excluded_notebooks) - set(tested_notebooks)
assert len(untested_notebooks) == 0, untested_notebooks


def test_all_notebooks_except_translations():
untested_notebooks = (
set(all_notebooks)
Expand All @@ -187,3 +182,8 @@ def test_all_notebooks_except_translations():
- set(tested_notebooks)
)
assert len(untested_notebooks) == 0, untested_notebooks


def test_all_translation_notebooks(): # pragma: no cover
untested_notebooks = set(translated_notebooks) - set(excluded_notebooks) - set(tested_notebooks)
assert len(untested_notebooks) == 0, untested_notebooks
2 changes: 0 additions & 2 deletions test/torch/linalg/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from syft.frameworks.torch.linalg import qr
from syft.frameworks.torch.linalg.operations import _norm_mpc
from syft.frameworks.torch.linalg.lr import DASH
from test.efficiency_tests.assertions import assert_time


def test_inv_sym(hook, workers):
Expand All @@ -31,7 +30,6 @@ def test_inv_sym(hook, workers):
assert (diff < 1e-3).all()


@assert_time(max_time=20)
def test_norm_mpc(hook, workers):
"""
Testing computation of vector norm on an AdditiveSharedTensor
Expand Down
5 changes: 0 additions & 5 deletions test/torch/tensors/test_precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import torch.nn as nn
import torch.nn.functional as F

from test.efficiency_tests.assertions import assert_time
from syft.frameworks.torch.tensors.interpreters.precision import FixedPrecisionTensor


Expand Down Expand Up @@ -388,7 +387,6 @@ def test_torch_dot(workers):
assert torch.dot(x, y).float_prec() == 45


@assert_time(max_time=6)
def test_torch_inverse_approx(workers):
"""
Test the approximate inverse with different tolerance depending on
Expand Down Expand Up @@ -416,7 +414,6 @@ def test_torch_inverse_approx(workers):
assert (diff / (tolerance * norm)) < 1


@assert_time(max_time=10)
def test_torch_exp_approx(workers):
"""
Test the approximate exponential with different tolerance depending on
Expand Down Expand Up @@ -444,7 +441,6 @@ def test_torch_exp_approx(workers):
assert (cumsum < 1).all()


@assert_time(max_time=40)
def test_torch_sigmoid_approx(workers):
"""
Test the approximate sigmoid with different tolerance depending on
Expand Down Expand Up @@ -472,7 +468,6 @@ def test_torch_sigmoid_approx(workers):
assert (diff / (tolerance * norm)) < 1


@assert_time(max_time=45)
def test_torch_log_approx(workers):
"""
Test the approximate logarithm with different tolerance depending on
Expand Down