diff --git a/.azure/gpu-tests-pytorch.yml b/.azure/gpu-tests-pytorch.yml index d3c4951a22336..888272d80012a 100644 --- a/.azure/gpu-tests-pytorch.yml +++ b/.azure/gpu-tests-pytorch.yml @@ -1,8 +1,3 @@ -# Python package -# Create and test a Python package on multiple Python versions. -# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/python - trigger: tags: include: ["*"] @@ -24,18 +19,18 @@ pr: - "examples/run_pl_examples.sh" - "examples/pytorch/basics/backbone_image_classifier.py" - "examples/pytorch/basics/autoencoder.py" + - "requirements/fabric/**" - "requirements/pytorch/**" - "src/lightning/__init__.py" - "src/lightning/__setup__.py" - "src/lightning/__version__.py" - - "src/lightning/pytorch/**" + - "src/lightning_fabric/*" + - "src/lightning/fabric/**" - "src/pytorch_lightning/*" + - "src/lightning/pytorch/**" - "tests/tests_pytorch/**" - "tests/run_standalone_*.sh" - "pyproject.toml" # includes pytest config - - "requirements/fabric/**" - - "src/lightning/fabric/**" - - "src/lightning_fabric/*" exclude: - "requirements/*/docs.txt" - "*.md" diff --git a/pyproject.toml b/pyproject.toml index b4d5d0b1638f5..e6d08411b0f35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,7 +120,6 @@ ignore = [ "S607", # todo: Starting a process with a partial executable path "RET504", # todo:Unnecessary variable assignment before `return` statement "PT004", # todo: Fixture `tmpdir_unittest_fixture` does not return anything, add leading underscore - "PT011", # todo: `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception "PT012", # todo: `pytest.raises()` block should contain a single simple statement "PT019", # todo: Fixture `_` without value is injected as parameter, use `@pytest.mark.usefixtures` instead ] diff --git a/tests/tests_pytorch/loggers/test_neptune.py b/tests/tests_pytorch/loggers/test_neptune.py index 6dc3816fac858..572b85715da86 100644 --- a/tests/tests_pytorch/loggers/test_neptune.py +++ b/tests/tests_pytorch/loggers/test_neptune.py @@ -121,19 +121,19 @@ def test_online_with_wrong_kwargs(neptune_mock): init.""" run = neptune_mock.init_run() - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="Run parameter expected to be of type `neptune.Run`*"): NeptuneLogger(run="some string") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="When an already initialized run object is provided*"): NeptuneLogger(run=run, project="redundant project") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="When an already initialized run object is provided*"): NeptuneLogger(run=run, api_key="redundant api key") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="When an already initialized run object is provided*"): NeptuneLogger(run=run, name="redundant api name") - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="When an already initialized run object is provided*"): NeptuneLogger(run=run, foo="random **kwarg") # this should work diff --git a/tests/tests_pytorch/models/test_hparams.py b/tests/tests_pytorch/models/test_hparams.py index 575bcadadc404..92a07f0a3d05e 100644 --- a/tests/tests_pytorch/models/test_hparams.py +++ b/tests/tests_pytorch/models/test_hparams.py @@ -527,7 +527,7 @@ def __init__(self, arg1, arg2): ) def test_single_config_models_fail(tmp_path, cls, config): """Test fail on passing unsupported config type.""" - with pytest.raises(ValueError): + with pytest.raises(ValueError, match=r"Primitives \(*"): _ = cls(**config) diff --git a/tests/tests_pytorch/profilers/test_profiler.py b/tests/tests_pytorch/profilers/test_profiler.py index 2059141ad9d63..5423c8ab0e89d 100644 --- a/tests/tests_pytorch/profilers/test_profiler.py +++ b/tests/tests_pytorch/profilers/test_profiler.py @@ -86,12 +86,12 @@ def test_simple_profiler_overhead(simple_profiler): def test_simple_profiler_value_errors(simple_profiler): """Ensure errors are raised where expected.""" action = "test" - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="Attempting to stop recording an action*"): simple_profiler.stop(action) simple_profiler.start(action) - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="Attempted to start test*"): simple_profiler.start(action) simple_profiler.stop(action) @@ -325,7 +325,7 @@ def test_advanced_profiler_dump_states(tmp_path): def test_advanced_profiler_value_errors(advanced_profiler): """Ensure errors are raised where expected.""" action = "test" - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="Attempting to stop recording*"): advanced_profiler.stop(action) advanced_profiler.start(action) diff --git a/tests/tests_pytorch/test_cli.py b/tests/tests_pytorch/test_cli.py index 70aaac32d9661..95124854a8fd5 100644 --- a/tests/tests_pytorch/test_cli.py +++ b/tests/tests_pytorch/test_cli.py @@ -339,7 +339,7 @@ def test_lightning_cli_save_config_seed_everything(cleandir): def test_save_to_log_dir_false_error(): - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="`save_to_log_dir=False` only makes sense*"): SaveConfigCallback( LightningArgumentParser(), Namespace(),