From 608fc1d62315e384ba4cfd1a7eaf12d5b03fa315 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Tue, 6 Jul 2021 19:08:08 +0200 Subject: [PATCH] avoid msg var impliciteness (#8619) * avoid msg var impliciteness * rename local msg * Add CI tests for debug data and train * Adjust debug data CLI test Co-authored-by: Adriane Boyd --- .github/azure-steps.yml | 11 +++++++++++ spacy/cli/_util.py | 12 +++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/azure-steps.yml b/.github/azure-steps.yml index 7ffdf6e61..50e81799e 100644 --- a/.github/azure-steps.yml +++ b/.github/azure-steps.yml @@ -78,6 +78,17 @@ steps: displayName: 'Test debug config CLI' condition: eq(variables['python_version'], '3.8') + - script: | + # will have errors due to sparse data, check for summary in output + python -m spacy debug data ner.cfg --paths.train ner-token-per-line-conll2003.spacy --paths.dev ner-token-per-line-conll2003.spacy | grep -q Summary + displayName: 'Test debug data CLI' + condition: eq(variables['python_version'], '3.8') + + - script: | + python -m spacy train ner.cfg --paths.train ner-token-per-line-conll2003.spacy --paths.dev ner-token-per-line-conll2003.spacy --training.max_steps 10 --gpu-id -1 + displayName: 'Test train CLI' + condition: eq(variables['python_version'], '3.8') + - script: | python -c "import spacy; config = spacy.util.load_config('ner.cfg'); config['components']['ner'] = {'source': 'ca_core_news_sm'}; config.to_disk('ner_source_sm.cfg')" PYTHONWARNINGS="error,ignore::DeprecationWarning" python -m spacy assemble ner_source_sm.cfg output_dir diff --git a/spacy/cli/_util.py b/spacy/cli/_util.py index c5b3c0de4..ed1e840a5 100644 --- a/spacy/cli/_util.py +++ b/spacy/cli/_util.py @@ -506,12 +506,14 @@ def string_to_list(value: str, intify: bool = False) -> Union[List[str], List[in 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 silent is None: + local_msg = Printer() + else: + local_msg = Printer(no_print=silent, pretty=not silent) if use_gpu >= 0: - msg.info(f"Using GPU: {use_gpu}") + local_msg.info(f"Using GPU: {use_gpu}") require_gpu(use_gpu) else: - msg.info("Using CPU") + local_msg.info("Using CPU") if has_cupy and gpu_is_available(): - msg.info("To switch to GPU 0, use the option: --gpu-id 0") + local_msg.info("To switch to GPU 0, use the option: --gpu-id 0")