From d4f2baf7dd7f0136916aa54c5d2af3ce12a43495 Mon Sep 17 00:00:00 2001 From: ines Date: Sat, 12 Aug 2017 21:44:15 +0200 Subject: [PATCH] Add create_meta option to package command Re-create meta.json in model directory, even if it exists. Especially useful when updating existing spaCy models or training with Prodigy. Ensures user won't end up with multiple "en_core_web_sm" models, and offers easy way to change the model's name and settings without having to edit the meta.json file. --- spacy/cli/package.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/cli/package.py b/spacy/cli/package.py index 1c720c2b5..9be28d4aa 100644 --- a/spacy/cli/package.py +++ b/spacy/cli/package.py @@ -15,10 +15,11 @@ from .. import about @plac.annotations( input_dir=("directory with model data", "positional", None, str), output_dir=("output parent directory", "positional", None, str), - meta=("path to meta.json", "option", "m", str), + meta_path=("path to meta.json", "option", "m", str), + create_meta=("create meta.json, even if one exists in directory", "flag", "c", bool), force=("force overwriting of existing folder in output directory", "flag", "f", bool) ) -def package(cmd, input_dir, output_dir, meta=None, force=False): +def package(cmd, input_dir, output_dir, meta_path=None, create_meta=False, force=False): """ Generate Python package for model data, including meta and required installation files. A new directory will be created in the specified @@ -26,7 +27,7 @@ def package(cmd, input_dir, output_dir, meta=None, force=False): """ input_path = util.ensure_path(input_dir) output_path = util.ensure_path(output_dir) - meta_path = util.ensure_path(meta) + meta_path = util.ensure_path(meta_path) if not input_path or not input_path.exists(): prints(input_path, title="Model directory not found", exits=1) if not output_path or not output_path.exists(): @@ -38,7 +39,7 @@ def package(cmd, input_dir, output_dir, meta=None, force=False): template_manifest = get_template('MANIFEST.in') template_init = get_template('xx_model_name/__init__.py') meta_path = meta_path or input_path / 'meta.json' - if meta_path.is_file(): + if not create_meta and meta_path.is_file(): prints(meta_path, title="Reading meta.json from file") meta = util.read_json(meta_path) else: