Skip to content

Commit 18db92d

Browse files
authored
[testing] add timeout_decorator (#3543)
1 parent b868617 commit 18db92d

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ known_third_party =
2323
tensorboardX
2424
tensorflow
2525
tensorflow_datasets
26+
timeout_decorator
2627
torch
2728
torchtext
2829
torchvision

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
extras["serving"] = ["pydantic", "uvicorn", "fastapi", "starlette"]
7373
extras["all"] = extras["serving"] + ["tensorflow", "torch"]
7474

75-
extras["testing"] = ["pytest", "pytest-xdist"]
75+
extras["testing"] = ["pytest", "pytest-xdist", "timeout-decorator"]
7676
extras["docs"] = ["recommonmark", "sphinx", "sphinx-markdown-tables", "sphinx-rtd-theme"]
7777
extras["quality"] = [
7878
"black",

tests/test_modeling_bart.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
1716
import tempfile
1817
import unittest
1918

19+
import timeout_decorator # noqa
20+
2021
from transformers import is_torch_available
2122

2223
from .test_configuration_common import ConfigTester
@@ -357,6 +358,7 @@ def test_sequence_classification_forward(self):
357358
loss = outputs[0]
358359
self.assertIsInstance(loss.item(), float)
359360

361+
@timeout_decorator.timeout(1)
360362
def test_lm_forward(self):
361363
config, input_ids, batch_size = self._get_config_and_data()
362364
lm_labels = ids_tensor([batch_size, input_ids.shape[1]], self.vocab_size).to(torch_device)

0 commit comments

Comments
 (0)