From a9e845426f63f1f8ae0200945fbea3f4852383d5 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Tue, 5 Jan 2021 13:49:59 +1100 Subject: [PATCH] Use --force for consistency and add docs --- spacy/cli/init_config.py | 11 +++++++---- website/docs/api/cli.md | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spacy/cli/init_config.py b/spacy/cli/init_config.py index 55bdacd30..65d90fc79 100644 --- a/spacy/cli/init_config.py +++ b/spacy/cli/init_config.py @@ -32,7 +32,7 @@ def init_config_cli( optimize: Optimizations = Opt(Optimizations.efficiency.value, "--optimize", "-o", help="Whether to optimize for efficiency (faster inference, smaller model, lower memory consumption) or higher accuracy (potentially larger and slower model). This will impact the choice of architecture, pretrained weights and related hyperparameters."), gpu: bool = Opt(False, "--gpu", "-G", help="Whether the model can run on GPU. This will impact the choice of architecture, pretrained weights and related hyperparameters."), pretraining: bool = Opt(False, "--pretraining", "-pt", help="Include config for pretraining (with 'spacy pretrain')"), - overwrite: bool = Opt(False, "--overwrite", "-W", help="Whether or not to overwrite the file if it already exists."), + force_overwrite: bool = Opt(False, "--force", "-F", help="Force overwriting the output file"), # fmt: on ): """ @@ -47,9 +47,12 @@ def init_config_cli( optimize = optimize.value pipeline = string_to_list(pipeline) is_stdout = str(output_file) == "-" - if not is_stdout and output_file.exists() and not overwrite: - msg = Printer(no_print=False) - msg.fail("The provided output file already exists. To overwrite, set the flag -W", exits=1) + if not is_stdout and output_file.exists() and not force_overwrite: + msg = Printer() + msg.fail( + "The provided output file already exists. To force overwriting the config file, set the --force or -F flag.", + exits=1, + ) config = init_config( lang=lang, pipeline=pipeline, diff --git a/website/docs/api/cli.md b/website/docs/api/cli.md index 5a6143a38..c0e344e4e 100644 --- a/website/docs/api/cli.md +++ b/website/docs/api/cli.md @@ -121,7 +121,7 @@ customize those settings in your config file later. > ``` ```cli -$ python -m spacy init config [output_file] [--lang] [--pipeline] [--optimize] [--gpu] [--pretraining] +$ python -m spacy init config [output_file] [--lang] [--pipeline] [--optimize] [--gpu] [--pretraining] [--force] ``` | Name | Description | @@ -132,6 +132,7 @@ $ python -m spacy init config [output_file] [--lang] [--pipeline] [--optimize] [ | `--optimize`, `-o` | `"efficiency"` or `"accuracy"`. Whether to optimize for efficiency (faster inference, smaller model, lower memory consumption) or higher accuracy (potentially larger and slower model). This will impact the choice of architecture, pretrained weights and related hyperparameters. Defaults to `"efficiency"`. ~~str (option)~~ | | `--gpu`, `-G` | Whether the model can run on GPU. This will impact the choice of architecture, pretrained weights and related hyperparameters. ~~bool (flag)~~ | | `--pretraining`, `-pt` | Include config for pretraining (with [`spacy pretrain`](/api/cli#pretrain)). Defaults to `False`. ~~bool (flag)~~ | +| `--force`, `-f` | Force overwriting the output file if it already exists. ~~bool (flag)~~ | | `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ | | **CREATES** | The config file for training. |