From 79346853aac5ccc86496fe1ea87b5034b3a94ae5 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Sun, 12 Jul 2020 12:31:17 +0200 Subject: [PATCH] Add debug-config command --- spacy/cli/debug_data.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/spacy/cli/debug_data.py b/spacy/cli/debug_data.py index 4563f96f0..a4bc16828 100644 --- a/spacy/cli/debug_data.py +++ b/spacy/cli/debug_data.py @@ -3,7 +3,7 @@ from pathlib import Path from collections import Counter import sys import srsly -from wasabi import Printer, MESSAGES +from wasabi import Printer, MESSAGES, msg import typer from ._util import app, Arg, Opt, show_validation_error, parse_config_overrides @@ -24,6 +24,27 @@ BLANK_MODEL_MIN_THRESHOLD = 100 BLANK_MODEL_THRESHOLD = 2000 +@app.command( + "debug-config", + context_settings={"allow_extra_args": True, "ignore_unknown_options": True}, +) +def debug_config_cli( + # fmt: off + ctx: typer.Context, # This is only used to read additional arguments + config_path: Path = Arg(..., help="Path to config file", exists=True), + code_path: Optional[Path] = Opt(None, "--code-path", "-c", help="Path to Python file with additional code (registered functions) to be imported"), + # fmt: on +): + """Debug a config file and show validation errors.""" + overrides = parse_config_overrides(ctx.args) + import_code(code_path) + with show_validation_error(): + util.load_config( + config_path, create_objects=False, schema=ConfigSchema, overrides=overrides, + ) + msg.good("Config is valid") + + @app.command( "debug-data", context_settings={"allow_extra_args": True, "ignore_unknown_options": True},