From 4c5d2c80d5e273cdc2ed7be6eb378bb7fb3c0c31 Mon Sep 17 00:00:00 2001 From: ines Date: Fri, 10 Nov 2017 02:30:55 +0100 Subject: [PATCH] Re-add python -m to commands, too brittle :( (see #1536) --- README.rst | 2 +- spacy/cli/validate.py | 4 ++-- website/_includes/_page_models.jade | 2 +- website/api/cli.jade | 24 ++++++++++--------- website/assets/js/models.js | 2 +- website/index.jade | 2 +- website/usage/_install/_instructions.jade | 2 +- website/usage/_install/_quickstart.jade | 2 +- website/usage/_models/_install-basics.jade | 10 ++++---- website/usage/_models/_install.jade | 6 ++--- website/usage/_models/_quickstart.jade | 2 +- website/usage/_spacy-101/_lightning-tour.jade | 4 ++-- website/usage/_spacy-101/_word-vectors.jade | 2 +- website/usage/_training/_basics.jade | 4 ++-- website/usage/_training/_saving-loading.jade | 6 ++--- website/usage/_v2/_features.jade | 4 ++-- website/usage/_visualizers/_jupyter.jade | 2 +- website/usage/spacy-101.jade | 2 +- 18 files changed, 42 insertions(+), 40 deletions(-) diff --git a/README.rst b/README.rst index 4254a1a47..088cdbd47 100644 --- a/README.rst +++ b/README.rst @@ -159,7 +159,7 @@ them: .. code:: bash pip install -U spacy - spacy validate + python -m spacy validate If you've trained your own models, keep in mind that your training and runtime inputs must match. After updating spaCy, we recommend **retraining your models** diff --git a/spacy/cli/validate.py b/spacy/cli/validate.py index 1c645a554..2d8cba891 100644 --- a/spacy/cli/validate.py +++ b/spacy/cli/validate.py @@ -58,8 +58,8 @@ def validate(cmd): if incompat_links: prints("You may also want to overwrite the incompatible links using " - "the `spacy link` command with `--force`, or remove them from " - "the data directory. Data path: {}" + "the `python -m spacy link` command with `--force`, or remove " + "them from the data directory. Data path: {}" .format(path2str(get_data_path()))) diff --git a/website/_includes/_page_models.jade b/website/_includes/_page_models.jade index e0dcf2b1a..d0fe05a6c 100644 --- a/website/_includes/_page_models.jade +++ b/website/_includes/_page_models.jade @@ -14,7 +14,7 @@ for id in CURRENT_MODELS .u-padding-small Latest: #[code(data-tpl=id data-tpl-key="version") n/a] +aside-code("Installation", "bash", "$"). - spacy download #{id} + python -m spacy download #{id} - var comps = getModelComponents(id) diff --git a/website/api/cli.jade b/website/api/cli.jade index 12f5e8713..b0913e60c 100644 --- a/website/api/cli.jade +++ b/website/api/cli.jade @@ -18,7 +18,7 @@ p | model name to be specified with its version (e.g., #[code en_core_web_sm-1.2.0]). +code(false, "bash", "$"). - spacy download [model] [--direct] + python -m spacy download [model] [--direct] +table(["Argument", "Type", "Description"]) +row @@ -72,7 +72,7 @@ p | model package. +code(false, "bash", "$"). - spacy link [origin] [link_name] [--force] + python -m spacy link [origin] [link_name] [--force] +table(["Argument", "Type", "Description"]) +row @@ -110,8 +110,8 @@ p | markup to copy-paste into #[+a(gh("spacy") + "/issues") GitHub issues]. +code(false, "bash"). - spacy info [--markdown] - spacy info [model] [--markdown] + python -m spacy info [--markdown] + python -m spacy info [model] [--markdown] +table(["Argument", "Type", "Description"]) +row @@ -148,7 +148,7 @@ p | compatible version (if out of date) and the commands for updating. +code(false, "bash", "$"). - spacy validate + python -m spacy validate +table(["Argument", "Type", "Description"]) +row("foot") @@ -165,7 +165,7 @@ p | chosen based on the file extension of the input file. +code(false, "bash", "$", false, false, true). - spacy convert [input_file] [output_dir] [--converter] [--n-sents] + python -m spacy convert [input_file] [output_dir] [--converter] [--n-sents] [--morphology] +table(["Argument", "Type", "Description"]) @@ -234,7 +234,9 @@ p | #[+api("cli#package") #[code package]] command. +code(false, "bash", "$", false, false, true). - spacy train [lang] [output_dir] [train_data] [dev_data] [--n-iter] [--n-sents] [--use-gpu] [--meta-path] [--vectors] [--no-tagger] [--no-parser] [--no-entities] [--gold-preproc] + python -m spacy train [lang] [output_dir] [train_data] [dev_data] [--n-iter] + [--n-sents] [--use-gpu] [--meta-path] [--vectors] [--no-tagger] [--no-parser] + [--no-entities] [--gold-preproc] +table(["Argument", "Type", "Description"]) +row @@ -443,7 +445,7 @@ p | #[+api("cli#package") #[code package]] command. +code(false, "bash", "$"). - spacy vocab [lang] [output_dir] [lexemes_loc] [vectors_loc] + python -m spacy vocab [lang] [output_dir] [lexemes_loc] [vectors_loc] +table(["Argument", "Type", "Description"]) +row @@ -488,7 +490,7 @@ p | is present in the model's pipeline. +code(false, "bash", "$", false, false, true). - spacy evaluate [model] [data_path] [--displacy-path] [--displacy-limit] [--gpu-id] [--gold-preproc] + python -m spacy evaluate [model] [data_path] [--displacy-path] [--displacy-limit] [--gpu-id] [--gold-preproc] +table(["Argument", "Type", "Description"]) +row @@ -546,10 +548,10 @@ p | your model into an installable archive file. +code(false, "bash", "$", false, false, true). - spacy package [input_dir] [output_dir] [--meta-path] [--create-meta] [--force] + python -m spacy package [input_dir] [output_dir] [--meta-path] [--create-meta] [--force] +aside-code("Example", "bash"). - spacy package /input /output + python -m spacy package /input /output cd /output/en_model-0.0.0 python setup.py sdist pip install dist/en_model-0.0.0.tar.gz diff --git a/website/assets/js/models.js b/website/assets/js/models.js index 30fed344e..2f1771350 100644 --- a/website/assets/js/models.js +++ b/website/assets/js/models.js @@ -310,7 +310,7 @@ export class ModelComparer { const genre = name.split('_')[1]; // extract genre from model name this.tpl.fill(`table-head${i}`, `${lang}_${name}`); this.tpl.get(`link${i}`).setAttribute('href', `/models/${lang}#${lang}_${name}`); - this.tpl.fill(`download${i}`, `spacy download ${lang}_${name}\n`); + this.tpl.fill(`download${i}`, `python -m spacy download ${lang}_${name}\n`); this.tpl.fill(`lang${i}`, this.languages[lang] || lang); this.tpl.fill(`type${i}`, this.labels[type] || type); this.tpl.fill(`genre${i}`, this.labels[genre] || genre); diff --git a/website/index.jade b/website/index.jade index d9f5d2992..8a77ae5fe 100644 --- a/website/index.jade +++ b/website/index.jade @@ -54,7 +54,7 @@ include _includes/_mixins +grid +grid-col("two-thirds") +terminal("lightning_tour.py", "More examples", "/usage/spacy-101#lightning-tour"). - # Install: pip install spacy && spacy download en + # Install: pip install spacy && python -m spacy download en import spacy # Load English tokenizer, tagger, parser, NER and word vectors diff --git a/website/usage/_install/_instructions.jade b/website/usage/_install/_instructions.jade index 18cc53612..d325e0ff4 100644 --- a/website/usage/_install/_instructions.jade +++ b/website/usage/_install/_instructions.jade @@ -13,7 +13,7 @@ p Using pip, spaCy releases are currently only available as source packages. | and available models, see the #[+a("/usage/models") docs on models]. +code.o-no-block. - spacy download en + python -m spacy download en >>> import spacy >>> nlp = spacy.load('en') diff --git a/website/usage/_install/_quickstart.jade b/website/usage/_install/_quickstart.jade index b9f5956c2..b679d5a08 100644 --- a/website/usage/_install/_quickstart.jade +++ b/website/usage/_install/_quickstart.jade @@ -27,4 +27,4 @@ +qs({package: 'source'}) python setup.py build_ext --inplace for _, model in MODELS - +qs({model: model}) spacy download #{model} + +qs({model: model}) python -m spacy download #{model} diff --git a/website/usage/_models/_install-basics.jade b/website/usage/_models/_install-basics.jade index a8029cc10..7b32e3333 100644 --- a/website/usage/_models/_install-basics.jade +++ b/website/usage/_models/_install-basics.jade @@ -5,16 +5,16 @@ p | #[+api("cli#download") #[code download]] command. It takes care of | finding the best-matching model compatible with your spaCy installation. -- var models = Object.keys(MODELS).map(function(lang) { return "spacy download " + lang }) +- var models = Object.keys(MODELS).map(function(lang) { return "python -m spacy download " + lang }) +code(false, "bash"). # out-of-the-box: download best-matching default model - #{Object.keys(MODELS).map(function(l) {return "spacy download " + l}).join('\n')} + #{Object.keys(MODELS).map(function(l) {return "python -m spacy download " + l}).join('\n')} # download best-matching version of specific model for your spaCy installation - spacy download en_core_web_sm + python -m spacy download en_core_web_sm # download exact model version (doesn't create shortcut link) - spacy download en_core_web_sm-2.0.0 --direct + python -m spacy download en_core_web_sm-2.0.0 --direct p | The download command will #[+a("/usage/models#download-pip") install the model] via @@ -25,7 +25,7 @@ p +code(false, "bash"). pip install spacy - spacy download en + python -m spacy download en +code. import spacy diff --git a/website/usage/_models/_install.jade b/website/usage/_models/_install.jade index d8f097f7e..769d3f2d6 100644 --- a/website/usage/_models/_install.jade +++ b/website/usage/_models/_install.jade @@ -117,7 +117,7 @@ p | to mapping unicode aliases to file paths: symbolic links. +code(false, "bash", "$"). - spacy link [package name or path] [shortcut] [--force] + python -m spacy link [package name or path] [shortcut] [--force] p | The first argument is the #[strong package name] (if the model was @@ -127,10 +127,10 @@ p +code("Examples", "bash"). # set up shortcut link to load installed package as "en_default" - spacy link en_core_web_md en_default + python -m spacy link en_core_web_md en_default # set up shortcut link to load local model as "my_amazing_model" - spacy link /Users/you/model my_amazing_model + python -m spacy link /Users/you/model my_amazing_model +infobox("Important note") | In order to create a symlink, your user needs the #[strong required permissions]. diff --git a/website/usage/_models/_quickstart.jade b/website/usage/_models/_quickstart.jade index 37a090a8f..593f70272 100644 --- a/website/usage/_models/_quickstart.jade +++ b/website/usage/_models/_quickstart.jade @@ -4,7 +4,7 @@ +quickstart(QUICKSTART_MODELS, "Quickstart", "Install a default model, get the code to load it from within spaCy and an example to test it. For more options, see the section on available models below.") for models, lang in MODELS - var package = models[0] - +qs({lang: lang}) spacy download #{lang} + +qs({lang: lang}) python -m spacy download #{lang} +qs({lang: lang}, "divider") +qs({lang: lang, load: "module"}, "python") import #{package} +qs({lang: lang, load: "module"}, "python") nlp = #{package}.load() diff --git a/website/usage/_spacy-101/_lightning-tour.jade b/website/usage/_spacy-101/_lightning-tour.jade index 95a934aad..493c15d35 100644 --- a/website/usage/_spacy-101/_lightning-tour.jade +++ b/website/usage/_spacy-101/_lightning-tour.jade @@ -7,8 +7,8 @@ p +h(3, "lightning-tour-models") Install models and process text +code(false, "bash"). - spacy download en - spacy download de + python -m spacy download en + python -m spacy download de +code. import spacy diff --git a/website/usage/_spacy-101/_word-vectors.jade b/website/usage/_spacy-101/_word-vectors.jade index 3fcd93caa..576235612 100644 --- a/website/usage/_spacy-101/_word-vectors.jade +++ b/website/usage/_spacy-101/_word-vectors.jade @@ -119,7 +119,7 @@ p | you need to download a larger model: +code-wrapper - +code-new(false, "bash", "$") spacy download en_core_web_lg + +code-new(false, "bash", "$") python -m spacy download en_core_web_lg p | Models that come with built-in word vectors make them available as the diff --git a/website/usage/_training/_basics.jade b/website/usage/_training/_basics.jade index e4d9b0fa2..f78966ab1 100644 --- a/website/usage/_training/_basics.jade +++ b/website/usage/_training/_basics.jade @@ -209,8 +209,8 @@ p | installable Python package from your model. +code(false, "bash"). - spacy convert /tmp/train.conllu /tmp/data - spacy train en /tmp/model /tmp/data/train.json -n 5 + python -m spacy convert /tmp/train.conllu /tmp/data + python -m spacy train en /tmp/model /tmp/data/train.json -n 5 +h(3, "training-simple-style") Simple training style +tag-new(2) diff --git a/website/usage/_training/_saving-loading.jade b/website/usage/_training/_saving-loading.jade index b0318c9a8..cb65a5f48 100644 --- a/website/usage/_training/_saving-loading.jade +++ b/website/usage/_training/_saving-loading.jade @@ -44,7 +44,7 @@ p } +code(false, "bash"). - spacy package /home/me/data/en_example_model /home/me/my_models + python -m spacy package /home/me/data/en_example_model /home/me/my_models p This command will create a model package directory that should look like this: @@ -166,7 +166,7 @@ p | looks like this: +code(false, "bash", "$", false, false, true). - spacy train {lang} {models_dir}/{name} {train_data} {dev_data} -m meta/{name}.json -V {version} -g {gpu_id} -n {n_epoch} -ns {n_sents} + python -m spacy train {lang} {models_dir}/{name} {train_data} {dev_data} -m meta/{name}.json -V {version} -g {gpu_id} -n {n_epoch} -ns {n_sents} +aside-code("meta.json template", "json"). { @@ -185,7 +185,7 @@ p In a directory #[code meta], we keep #[code meta.json] templates for the indiv p On each epoch, the model is saved out with a #[code meta.json] using our template and added properties, like the #[code pipeline], #[code accuracy] scores and the #[code spacy_version] used to train the model. After training completion, the best model is selected automatically and packaged using the #[+api("cli#package") #[code package]] command. Since a full meta file is already present on the trained model, no further setup is required to build a valid model package. +code(false, "bash"). - spacy package -f {best_model} dist/ + python -m spacy package -f {best_model} dist/ cd dist/{model_name} python setup.py sdist diff --git a/website/usage/_v2/_features.jade b/website/usage/_v2/_features.jade index d31217747..1438d8486 100644 --- a/website/usage/_v2/_features.jade +++ b/website/usage/_v2/_features.jade @@ -12,8 +12,8 @@ p +aside-code("Example", "bash") for _, lang in MODELS if lang != "xx" - | spacy download #{lang} # default #{LANGUAGES[lang]} model!{'\n'} - | spacy download xx_ent_wiki_sm # multi-language NER + | python -m spacy download #{lang} # default #{LANGUAGES[lang]} model!{'\n'} + | python -m spacy download xx_ent_wiki_sm # multi-language NER p | spaCy v2.0 features new neural models for tagging, diff --git a/website/usage/_visualizers/_jupyter.jade b/website/usage/_visualizers/_jupyter.jade index f7227e4d1..c8528266b 100644 --- a/website/usage/_visualizers/_jupyter.jade +++ b/website/usage/_visualizers/_jupyter.jade @@ -7,7 +7,7 @@ p | notebook, the visualizations will be included as HTML. +code("Jupyter Example"). - # don't forget to install a model, e.g.: spacy download en + # don't forget to install a model, e.g.: python -m spacy download en import spacy from spacy import displacy diff --git a/website/usage/spacy-101.jade b/website/usage/spacy-101.jade index 1d3e792aa..81ed7a133 100644 --- a/website/usage/spacy-101.jade +++ b/website/usage/spacy-101.jade @@ -189,7 +189,7 @@ p | the website or company in a specific context. +aside-code("Loading models", "bash", "$"). - spacy download en + python -m spacy download en >>> import spacy >>> nlp = spacy.load('en')