Make validate command fail more gracefully if version not found

Mostly relevant during develoment when working with .dev versions
This commit is contained in:
ines 2018-01-31 22:06:28 +01:00
parent 2e73d66a35
commit 3c1fb9d02d

View File

@ -20,13 +20,16 @@ def validate():
prints("Couldn't fetch compatibility table.", prints("Couldn't fetch compatibility table.",
title="Server error (%d)" % r.status_code, exits=1) title="Server error (%d)" % r.status_code, exits=1)
compat = r.json()['spacy'] compat = r.json()['spacy']
current_compat = compat.get(about.__version__)
if not current_compat:
prints(about.__compatibility__, exits=1,
title="Can't find spaCy v{} in compatibility table"
.format(about.__version__))
all_models = set() all_models = set()
for spacy_v, models in dict(compat).items(): for spacy_v, models in dict(compat).items():
all_models.update(models.keys()) all_models.update(models.keys())
for model, model_vs in models.items(): for model, model_vs in models.items():
compat[spacy_v][model] = [reformat_version(v) for v in model_vs] compat[spacy_v][model] = [reformat_version(v) for v in model_vs]
current_compat = compat[about.__version__]
model_links = get_model_links(current_compat) model_links = get_model_links(current_compat)
model_pkgs = get_model_pkgs(current_compat, all_models) model_pkgs = get_model_pkgs(current_compat, all_models)
incompat_links = {l for l, d in model_links.items() if not d['compat']} incompat_links = {l for l, d in model_links.items() if not d['compat']}