mirror of https://github.com/explosion/spaCy.git
Pretty-print config validation errors
This commit is contained in:
parent
a3667394b4
commit
defe1e7213
|
@ -6,9 +6,11 @@ from pathlib import Path
|
||||||
from wasabi import msg
|
from wasabi import msg
|
||||||
import thinc
|
import thinc
|
||||||
import thinc.schedules
|
import thinc.schedules
|
||||||
|
from thinc.config import ConfigValidationError
|
||||||
from thinc.api import use_pytorch_for_gpu_memory, require_gpu, fix_random_seed
|
from thinc.api import use_pytorch_for_gpu_memory, require_gpu, fix_random_seed
|
||||||
import random
|
import random
|
||||||
import typer
|
import typer
|
||||||
|
import sys
|
||||||
|
|
||||||
from ._util import app, Arg, Opt, parse_config_overrides
|
from ._util import app, Arg, Opt, parse_config_overrides
|
||||||
from ..gold import Corpus, Example
|
from ..gold import Corpus, Example
|
||||||
|
@ -81,12 +83,17 @@ def train(
|
||||||
) -> None:
|
) -> None:
|
||||||
msg.info(f"Loading config from: {config_path}")
|
msg.info(f"Loading config from: {config_path}")
|
||||||
# Read the config first without creating objects, to get to the original nlp_config
|
# Read the config first without creating objects, to get to the original nlp_config
|
||||||
|
try:
|
||||||
config = util.load_config(
|
config = util.load_config(
|
||||||
config_path,
|
config_path,
|
||||||
create_objects=False,
|
create_objects=False,
|
||||||
schema=ConfigSchema,
|
schema=ConfigSchema,
|
||||||
overrides=config_overrides,
|
overrides=config_overrides,
|
||||||
)
|
)
|
||||||
|
except ConfigValidationError as e:
|
||||||
|
msg.fail("Config validation error")
|
||||||
|
print(str(e).replace("Config validation error", "").strip())
|
||||||
|
sys.exit(1)
|
||||||
use_gpu = config["training"]["use_gpu"]
|
use_gpu = config["training"]["use_gpu"]
|
||||||
if use_gpu >= 0:
|
if use_gpu >= 0:
|
||||||
msg.info(f"Using GPU: {use_gpu}")
|
msg.info(f"Using GPU: {use_gpu}")
|
||||||
|
|
Loading…
Reference in New Issue