MCPcopy
hub / github.com/explosion/spaCy / validate

Function validate

spacy/cli/validate.py:33–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31
32
33def validate() -> None:
34 model_pkgs, compat = get_model_pkgs()
35 spacy_version = get_minor_version(about.__version__)
36 current_compat = compat.get(spacy_version, {})
37 if not current_compat:
38 msg.warn(f"No compatible packages found for v{spacy_version} of spaCy")
39 incompat_models = {d["name"] for _, d in model_pkgs.items() if not d["compat"]}
40 na_models = [m for m in incompat_models if m not in current_compat]
41 update_models = [m for m in incompat_models if m in current_compat]
42 spacy_dir = Path(__file__).parent.parent
43
44 msg.divider(f"Installed pipeline packages (spaCy v{about.__version__})")
45 msg.info(f"spaCy installation: {spacy_dir}")
46
47 if model_pkgs:
48 header = ("NAME", "SPACY", "VERSION", "")
49 rows = []
50 for name, data in model_pkgs.items():
51 if data["compat"]:
52 comp = msg.text("", color="green", icon="good", no_print=True)
53 version = msg.text(data["version"], color="green", no_print=True)
54 else:
55 version = msg.text(data["version"], color="yellow", no_print=True)
56 comp = f"--> {current_compat.get(data['name'], ['n/a'])[0]}"
57 rows.append((data["name"], data["spacy"], version, comp))
58 msg.table(rows, header=header)
59 else:
60 msg.text("No pipeline packages found in your current environment.", exits=0)
61 if update_models:
62 msg.divider("Install updates")
63 msg.text("Use the following commands to update the packages:")
64 cmd = "python -m spacy download {}"
65 print("\n".join([cmd.format(pkg) for pkg in update_models]) + "\n")
66 if na_models:
67 msg.info(
68 f"The following packages are custom spaCy pipelines or not "
69 f"available for spaCy v{about.__version__}:",
70 ", ".join(na_models),
71 )
72 if incompat_models:
73 sys.exit(1)
74
75
76def get_model_pkgs(silent: bool = False) -> Tuple[dict, dict]:

Callers 2

validate_cliFunction · 0.70
packageFunction · 0.70

Calls 4

get_model_pkgsFunction · 0.85
get_minor_versionFunction · 0.85
appendMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…