mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
Add meta validation to check for required settings
Complain if no "lang", "name" or "version" is found (those settings are used in directory / package names). Package will still build without, but it'll inevitably fail somewhere down the line.
This commit is contained in:
parent
a7574b7572
commit
e3de035814
|
@ -26,6 +26,7 @@ def package(input_dir, output_dir, meta_path, force):
|
||||||
else:
|
else:
|
||||||
meta = generate_meta()
|
meta = generate_meta()
|
||||||
|
|
||||||
|
validate_meta(meta, ['lang', 'name', 'version'])
|
||||||
model_name = meta['lang'] + '_' + meta['name']
|
model_name = meta['lang'] + '_' + meta['name']
|
||||||
model_name_v = model_name + '-' + meta['version']
|
model_name_v = model_name + '-' + meta['version']
|
||||||
main_path = output_path / model_name_v
|
main_path = output_path / model_name_v
|
||||||
|
@ -89,6 +90,14 @@ def generate_meta():
|
||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
|
def validate_meta(meta, keys):
|
||||||
|
for key in keys:
|
||||||
|
if key not in meta or meta[key] == '':
|
||||||
|
util.sys_exit(
|
||||||
|
"This setting is required to build your package.",
|
||||||
|
title='No "{k}" setting found in meta.json'.format(k=key))
|
||||||
|
|
||||||
|
|
||||||
def get_template(filepath):
|
def get_template(filepath):
|
||||||
url = 'https://raw.githubusercontent.com/explosion/spacy-dev-resources/master/templates/model/'
|
url = 'https://raw.githubusercontent.com/explosion/spacy-dev-resources/master/templates/model/'
|
||||||
r = requests.get(url + filepath)
|
r = requests.get(url + filepath)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user