From 95e3cf576bef4bf44a9736d3564fe87a1c742cc7 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Mon, 26 Apr 2021 16:53:21 +0200 Subject: [PATCH] Optionally append lang for packaged model name (#7417) * Add empty lines at the end of Python files * Only prepend the lang code if it's not there already * Update spacy/cli/package.py * fix whitespace stripping --- spacy/cli/package.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spacy/cli/package.py b/spacy/cli/package.py index eaffde1d7..5b8daf048 100644 --- a/spacy/cli/package.py +++ b/spacy/cli/package.py @@ -112,7 +112,9 @@ def package( msg.fail("Invalid pipeline meta.json") print("\n".join(errors)) sys.exit(1) - model_name = meta["lang"] + "_" + meta["name"] + model_name = meta["name"] + if not model_name.startswith(meta['lang'] + "_"): + model_name = f"{meta['lang']}_{model_name}" model_name_v = model_name + "-" + meta["version"] main_path = output_dir / model_name_v package_path = main_path / model_name @@ -294,7 +296,7 @@ def setup_package(): if __name__ == '__main__': setup_package() -""".strip() +""".lstrip() TEMPLATE_MANIFEST = """ @@ -314,4 +316,4 @@ __version__ = get_model_meta(Path(__file__).parent)['version'] def load(**overrides): return load_model_from_init_py(__file__, **overrides) -""".strip() +""".lstrip()