From 39ae9b53e3ac386ad2a8ac7b335bee3404c81810 Mon Sep 17 00:00:00 2001 From: Jakob Date: Thu, 15 Feb 2024 10:54:00 +0100 Subject: [PATCH 1/5] add pytest ini options sow mark --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 39fe25a9..afb81498 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] # See configuration details in https://github.com/pypa/setuptools_scm version_scheme = "no-guess-dev" + +[tool.pytest.ini_options] +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "serial", +] From 4aacea56babdeb3f6490273252e40996ab890bd7 Mon Sep 17 00:00:00 2001 From: Jakob Date: Thu, 15 Feb 2024 11:53:17 +0100 Subject: [PATCH 2/5] mark slow tests as slow --- tests/operators/test_deeponet.py | 2 ++ tests/operators/test_neuraloperator.py | 2 ++ tests/test_optuna.py | 3 +++ 3 files changed, 7 insertions(+) diff --git a/tests/operators/test_deeponet.py b/tests/operators/test_deeponet.py index 9ce7c1cc..7db57cc4 100644 --- a/tests/operators/test_deeponet.py +++ b/tests/operators/test_deeponet.py @@ -1,5 +1,6 @@ import torch import matplotlib.pyplot as plt +import pytest from continuity.plotting import plot, plot_evaluation from torch.utils.data import DataLoader @@ -40,6 +41,7 @@ def test_output_shape(): assert v_other_pred.shape == v_other.shape +@pytest.mark.slow def test_deeponet(): # Parameters num_sensors = 16 diff --git a/tests/operators/test_neuraloperator.py b/tests/operators/test_neuraloperator.py index 715efe4e..0b077cc0 100644 --- a/tests/operators/test_neuraloperator.py +++ b/tests/operators/test_neuraloperator.py @@ -1,3 +1,4 @@ +import pytest import torch import matplotlib.pyplot as plt from continuity.data import Sine @@ -9,6 +10,7 @@ torch.manual_seed(0) +@pytest.mark.slow def test_neuraloperator(): # Parameters num_sensors = 16 diff --git a/tests/test_optuna.py b/tests/test_optuna.py index ea602e9e..75cfd394 100644 --- a/tests/test_optuna.py +++ b/tests/test_optuna.py @@ -6,10 +6,13 @@ from continuity.operators import DeepONet import optuna +import pytest + # Set random seed torch.manual_seed(0) +@pytest.mark.slow def test_optuna(): def objective(trial): trunk_width = trial.suggest_int("trunk_width", 4, 16) From c8367307caefc1df6c73a7e3fdaff167f7148348 Mon Sep 17 00:00:00 2001 From: Samuel Burbulla Date: Thu, 15 Feb 2024 13:34:29 +0100 Subject: [PATCH 3/5] Move import to top. --- tests/test_optuna.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_optuna.py b/tests/test_optuna.py index 75cfd394..ef2c313e 100644 --- a/tests/test_optuna.py +++ b/tests/test_optuna.py @@ -1,3 +1,4 @@ +import pytest import torch from torch.utils.data import DataLoader from continuity.benchmarks.sine import SineBenchmark @@ -6,8 +7,6 @@ from continuity.operators import DeepONet import optuna -import pytest - # Set random seed torch.manual_seed(0) From 6813a4bc16c70105b93476eaa3bbf57129e27a2c Mon Sep 17 00:00:00 2001 From: Samuel Burbulla Date: Thu, 15 Feb 2024 13:34:41 +0100 Subject: [PATCH 4/5] Simplify markers. --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index afb81498..e449db52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,5 @@ version_scheme = "no-guess-dev" [tool.pytest.ini_options] markers = [ - "slow: marks tests as slow (deselect with '-m \"not slow\"')", - "serial", + "slow: marks tests as slow (> 5s)", ] From 18a1f2c55e9167bbb22e1923dc390a7ae5429dea Mon Sep 17 00:00:00 2001 From: Samuel Burbulla Date: Thu, 15 Feb 2024 13:35:16 +0100 Subject: [PATCH 5/5] Add comment on slow tests to CONTRIBUTING. --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index abbbb781..a19c7521 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,13 @@ by [CI pipelines](#CI). Before pushing your changes to the remote we recommend to execute `pytest` locally in order to detect mistakes early on and to avoid failing pipelines. +Slow tests (> 5s) are marked by the `@pytest.mark.slow` decorator. +To run all tests except the slow ones, use: + +```shell +pytest -m "not slow" +``` + ## Notebooks We use notebooks both as documentation (copied over to `docs/examples`) and as