diff --git a/spacy/de/download.py b/spacy/de/download.py index 4f02f0474..239d46884 100644 --- a/spacy/de/download.py +++ b/spacy/de/download.py @@ -1,14 +1,5 @@ -import plac -from ..download import download - - -@plac.annotations( - force=("Force overwrite", "flag", "f", bool), - data_path=("Path to download model", "option", "d", str) -) -def main(data_size='all', force=False, data_path=None): - download('de', force=force, data_path=data_path) +from ..deprecated import ModelDownload as download if __name__ == '__main__': - plac.call(main) + download.de() diff --git a/spacy/deprecated.py b/spacy/deprecated.py index 104259fb6..7394c5bf3 100644 --- a/spacy/deprecated.py +++ b/spacy/deprecated.py @@ -1,6 +1,7 @@ from pathlib import Path from . import about from . import util +from .download import download def read_lang_data(package): @@ -77,3 +78,27 @@ def fix_glove_vectors_loading(overrides): if vec_path is not None: overrides['add_vectors'] = lambda vocab: vocab.load_vectors_from_bin_loc(vec_path) return overrides + + +class ModelDownload(): + """Replace download modules within en and de with deprecation warning and + download default language model (using shortcut). Use classmethods to allow + importing ModelDownload as download and calling download.en() etc.""" + + @classmethod + def load(self, lang): + util.print_msg( + "The spacy.{l}.download command is now deprecated. Please use " + "spacy.download [model name or shortcut] instead. For more " + "info and available models, see the documentation: {d}. " + "Downloading default '{l}' model now...".format(d=about.__docs__, l=lang), + title="Warning: deprecated command") + download(lang) + + @classmethod + def en(cls, *args, **kwargs): + cls.load('en') + + @classmethod + def de(cls, *args, **kwargs): + cls.load('de') diff --git a/spacy/en/download.py b/spacy/en/download.py index 7a2d58234..6d0a8dd40 100644 --- a/spacy/en/download.py +++ b/spacy/en/download.py @@ -1,25 +1,5 @@ -import plac -import sputnik - -from ..download import download -from .. import about - - -@plac.annotations( - force=("Force overwrite", "flag", "f", bool), - data_path=("Path to download model", "option", "d", str) -) -def main(data_size='all', force=False, data_path=None): - if force: - sputnik.purge(about.__title__, about.__version__) - - if data_size in ('all', 'parser'): - print("Downloading parsing model") - download('en', force=False, data_path=data_path) - if data_size in ('all', 'glove'): - print("Downloading GloVe vectors") - download('en_glove_cc_300_1m_vectors', force=False, data_path=data_path) +from ..deprecated import ModelDownload as download if __name__ == '__main__': - plac.call(main) + download.en()