def validate():
msg = Printer()<EOL>with msg.loading("<STR_LIT>"):<EOL><INDENT>r = requests.get(about.__compatibility__)<EOL>if r.status_code != <NUM_LIT:200>:<EOL><INDENT>msg.fail(<EOL>"<STR_LIT>".format(r.status_code),<EOL>"<STR_LIT>",<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT><DEDENT>msg.good("<STR_LIT>")<EOL>compat = r.json()["<STR_LIT>"]<EOL>version = about.__version__<EOL>version = version.rsplit("<STR_LIT>", <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>current_compat = compat.get(version)<EOL>if not current_compat:<EOL><INDENT>msg.fail(<EOL>"<STR_LIT>".format(version),<EOL>about.__compatibility__,<EOL>exits=<NUM_LIT:1>,<EOL>)<EOL><DEDENT>all_models = set()<EOL>for spacy_v, models in dict(compat).items():<EOL><INDENT>all_models.update(models.keys())<EOL>for model, model_vs in models.items():<EOL><INDENT>compat[spacy_v][model] = [reformat_version(v) for v in model_vs]<EOL><DEDENT><DEDENT>model_links = get_model_links(current_compat)<EOL>model_pkgs = get_model_pkgs(current_compat, all_models)<EOL>incompat_links = {l for l, d in model_links.items() if not d["<STR_LIT>"]}<EOL>incompat_models = {d["<STR_LIT:name>"] for _, d in model_pkgs.items() if not d["<STR_LIT>"]}<EOL>incompat_models.update(<EOL>[d["<STR_LIT:name>"] for _, d in model_links.items() if not d["<STR_LIT>"]]<EOL>)<EOL>na_models = [m for m in incompat_models if m not in current_compat]<EOL>update_models = [m for m in incompat_models if m in current_compat]<EOL>spacy_dir = Path(__file__).parent.parent<EOL>msg.divider("<STR_LIT>".format(about.__version__))<EOL>msg.info("<STR_LIT>".format(path2str(spacy_dir)))<EOL>if model_links or model_pkgs:<EOL><INDENT>header = ("<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>")<EOL>rows = []<EOL>for name, data in model_pkgs.items():<EOL><INDENT>rows.append(get_model_row(current_compat, name, data, msg))<EOL><DEDENT>for name, data in model_links.items():<EOL><INDENT>rows.append(get_model_row(current_compat, name, data, msg, "<STR_LIT>"))<EOL><DEDENT>msg.table(rows, header=header)<EOL><DEDENT>else:<EOL><INDENT>msg.text("<STR_LIT>", exits=<NUM_LIT:0>)<EOL><DEDENT>if update_models:<EOL><INDENT>msg.divider("<STR_LIT>")<EOL>msg.text("<STR_LIT>")<EOL>cmd = "<STR_LIT>"<EOL>print("<STR_LIT:\n>".join([cmd.format(pkg) for pkg in update_models]) + "<STR_LIT:\n>")<EOL><DEDENT>if na_models:<EOL><INDENT>msg.text(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(about.__version__, "<STR_LIT:U+002CU+0020>".join(na_models))<EOL>)<EOL><DEDENT>if incompat_links:<EOL><INDENT>msg.text(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(path=path2str(get_data_path()))<EOL>)<EOL><DEDENT>if incompat_models or incompat_links:<EOL><INDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>
Validate that the currently installed version of spaCy is compatible
with the installed models. Should be run after `pip install -U spacy`.