facebookresearch / NeuralCompression

A collection of tools for neural compression enthusiasts.
MIT License
496 stars 43 forks source link

Add timeout to unit tests to catch flaky test_dense_image_warp #237

Closed mhavasi closed 5 months ago

mhavasi commented 5 months ago

The unit test test_dense_image_warp hangs sometimes. I ran it locally 1000 times and I wasn't able to reproduce the error.

This PR adds a timeout to the unit tests, so that we get a stack trace the next time it stalls. Also it doesn't waste 6 hours of compute.

The timeout is set to 5 minutes per test by default.

Changes

Testing

Tested locally, I saw a stack trace on a timeout:

  File "/private/home/marton/miniconda3/envs/waveenv/lib/python3.10/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/private/home/marton/miniconda3/envs/waveenv/lib/python3.10/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "/private/home/marton/.local/lib/python3.10/site-packages/_pytest/python.py", line 194, in pytest_pyfunc_call
    result = testfunction(**testargs)
  File "/private/home/marton/NeuralCompressionInternal/tests/functional/test_dense_image_warp.py", line 17, in test_dense_image_warp
    time.sleep(10)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Timeout +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++