Skip to content

Promote warnings to errors in CI #1007

Description

@penelopeysm

In CI, it would probably be good hygiene to promote warnings to errors (if the intention is that tests should never warn).

This could be done quite easily with

diff --git a/pyproject.toml b/pyproject.toml
index d2e5adff..4e11d3aa 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -116,6 +116,7 @@ source = [".", "/tmp"]
 addopts = "--ignore=v0"
 # These suppress only test output; runtime warnings still reach users.
 filterwarnings = [
+    "error",
     # Raised by PyTorch (via gpytorch) - not actionable here.
     # Remove if dependencies no longer calling `torch.jit.script`.
     "ignore:`torch\\.jit\\.script` is deprecated\\..*:DeprecationWarning",

There is one problem, though, which is that we can't actually suppress this warning, which is still seen in CI logs

.venv/lib/python3.10/site-packages/pyro/ops/stats.py:514
  /home/runner/work/autoemulate/autoemulate/.venv/lib/python3.10/site-packages/pyro/ops/stats.py:514: DeprecationWarning: invalid escape sequence '\g'
    """

In #1000 a filter was added to suppress this, but it doesn't seem to actually suppress it. I think this is because it happens at the point where pyro is imported, which is before pytest has even loaded. This tallies with some pytest issues, most notably pytest-dev/pytest#13145.

The suggested workaround is to launch Python itself with a -Wignore... flag so that the warning is suppressed at the highest level. I've tested locally and can confirm that this works.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions