From b9f59118bf8782e97ce71c472152f46d52b1f501 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Tue, 6 Jul 2021 14:16:19 +0200 Subject: [PATCH] Fix silent evaluation (#8581) * fix silentness * sneak in docs typo fix * pass silent boolean instead --- spacy/cli/_util.py | 6 ++++-- spacy/cli/evaluate.py | 2 +- website/docs/usage/processing-pipelines.md | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spacy/cli/_util.py b/spacy/cli/_util.py index 228cc622a..c5b3c0de4 100644 --- a/spacy/cli/_util.py +++ b/spacy/cli/_util.py @@ -2,7 +2,7 @@ from typing import Dict, Any, Union, List, Optional, Tuple, Iterable, TYPE_CHECK import sys import shutil from pathlib import Path -from wasabi import msg +from wasabi import msg, Printer import srsly import hashlib import typer @@ -504,8 +504,10 @@ def string_to_list(value: str, intify: bool = False) -> Union[List[str], List[in return result -def setup_gpu(use_gpu: int) -> None: +def setup_gpu(use_gpu: int, silent=None) -> None: """Configure the GPU and log info.""" + if silent is not None: + msg = Printer(no_print=silent, pretty=not silent) if use_gpu >= 0: msg.info(f"Using GPU: {use_gpu}") require_gpu(use_gpu) diff --git a/spacy/cli/evaluate.py b/spacy/cli/evaluate.py index 35915096e..378911a20 100644 --- a/spacy/cli/evaluate.py +++ b/spacy/cli/evaluate.py @@ -64,7 +64,7 @@ def evaluate( ) -> Dict[str, Any]: msg = Printer(no_print=silent, pretty=not silent) fix_random_seed() - setup_gpu(use_gpu) + setup_gpu(use_gpu, silent=silent) data_path = util.ensure_path(data_path) output_path = util.ensure_path(output) displacy_path = util.ensure_path(displacy_path) diff --git a/website/docs/usage/processing-pipelines.md b/website/docs/usage/processing-pipelines.md index 87feee54a..0109f24c9 100644 --- a/website/docs/usage/processing-pipelines.md +++ b/website/docs/usage/processing-pipelines.md @@ -1105,10 +1105,10 @@ While you could use a registered function or a file loader like [`srsly.read_json.v1`](/api/top-level#file_readers) as an argument of the component factory, this approach is problematic: the component factory runs **every time the component is created**. This means it will run when creating -the `nlp` object before training, but also every a user loads your pipeline. So -your runtime pipeline would either depend on a local path on your file system, -or it's loaded twice: once when the component is created, and then again when -the data is by `from_disk`. +the `nlp` object before training, but also every time a user loads your +pipeline. So your runtime pipeline would either depend on a local path on your +file system, or it's loaded twice: once when the component is created, and then +again when the data is by `from_disk`. > ```ini > ### config.cfg