From 2387802ee79d68db8cc70ffe1f4a44aa9737f2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danie=CC=88l=20de=20Kok?= Date: Thu, 12 Jan 2023 09:26:25 +0100 Subject: [PATCH] Fail with an error message when trying to speed bench empty corpus --- spacy/cli/benchmark_speed.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spacy/cli/benchmark_speed.py b/spacy/cli/benchmark_speed.py index 0d1015103..4eb20a5fa 100644 --- a/spacy/cli/benchmark_speed.py +++ b/spacy/cli/benchmark_speed.py @@ -6,6 +6,7 @@ from pathlib import Path import time from tqdm import tqdm import typer +from wasabi import msg from .. import util from ..language import Language @@ -41,6 +42,9 @@ def benchmark_speed_cli( corpus = Corpus(data_path) docs = [eg.predicted for eg in corpus(nlp)] + if len(docs) == 0: + msg.fail("Cannot benchmark speed using an empty corpus.", exits=1) + print(f"Warming up for {warmup_epochs} epochs...") warmup(nlp, docs, warmup_epochs, batch_size)