diff --git a/spacy/language.py b/spacy/language.py index 14b9f4eb0..d76741da3 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -972,8 +972,9 @@ class Language: raise ValueError(Errors.E003.format(component=type(proc), name=name)) try: doc = proc(doc, **component_cfg.get(name, {})) - except KeyError: - raise ValueError(Errors.E109.format(name=name)) from None + except KeyError as e: + # This typically happens if a component is not initialized + raise ValueError(Errors.E109.format(name=name)) from e if doc is None: raise ValueError(Errors.E005.format(name=name)) return doc diff --git a/spacy/ml/models/tok2vec.py b/spacy/ml/models/tok2vec.py index 120e9b02c..2870de1b9 100644 --- a/spacy/ml/models/tok2vec.py +++ b/spacy/ml/models/tok2vec.py @@ -93,7 +93,7 @@ def build_Tok2Vec_model( @registry.architectures.register("spacy.MultiHashEmbed.v1") def MultiHashEmbed( width: int, rows: int, also_embed_subwords: bool, also_use_static_vectors: bool -): +) -> Model[List[Doc], List[Floats2d]]: """Construct an embedding layer that separately embeds a number of lexical attributes using hash embedding, concatenates the results, and passes it through a feed-forward subnetwork to build a mixed representations. @@ -167,7 +167,7 @@ def MultiHashEmbed( def CharacterEmbed( width: int, rows: int, nM: int, nC: int, also_use_static_vectors: bool, feature: Union[int, str]="LOWER" -): +) -> Model[List[Doc], List[Floats2d]]: """Construct an embedded representation based on character embeddings, using a feed-forward network. A fixed number of UTF-8 byte characters are used for each word, taken from the beginning and end of the word equally. Padding is diff --git a/spacy/util.py b/spacy/util.py index f234927d6..4d68e829c 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -1065,7 +1065,6 @@ def import_file(name: str, loc: Union[str, Path]) -> ModuleType: loc (str / Path): Path to the file. RETURNS: The loaded module. """ - loc = str(loc) spec = importlib.util.spec_from_file_location(name, str(loc)) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) diff --git a/website/docs/api/cli.md b/website/docs/api/cli.md index 436582780..32d73d762 100644 --- a/website/docs/api/cli.md +++ b/website/docs/api/cli.md @@ -287,7 +287,7 @@ fixed. To auto-fill a partial config and save the result, you can use the [`init fill-config`](/api/cli#init-fill-config) command. ```cli -$ python -m spacy debug config [config_path] [--code-path] [--show-functions] [--show-variables] [overrides] +$ python -m spacy debug config [config_path] [--code] [--show-functions] [--show-variables] [overrides] ``` > #### Example @@ -430,7 +430,7 @@ File /path/to/thinc/thinc/schedules.py (line 91) | Name | Description | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `config_path` | Path to [training config](/api/data-formats#config) file containing all settings and hyperparameters. ~~Path (positional)~~ | -| `--code-path`, `-c` | Path to Python file with additional code to be imported. Allows [registering custom functions](/usage/training#custom-functions) for new architectures. ~~Optional[Path] \(option)~~ | +| `--code`, `-c` | Path to Python file with additional code to be imported. Allows [registering custom functions](/usage/training#custom-functions) for new architectures. ~~Optional[Path] \(option)~~ | | `--show-functions`, `-F` | Show an overview of all registered function blocks used in the config and where those functions come from, including the module name, Python file and line number. ~~bool (flag)~~ | | `--show-variables`, `-V` | Show an overview of all variables referenced in the config, e.g. `${paths.train}` and their values that will be used. This also reflects any config overrides provided on the CLI, e.g. `--paths.train /path`. ~~bool (flag)~~ | | `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ | @@ -1194,7 +1194,7 @@ examples, see the usage guide on [integration](/usage/projects#ray). ```cli -$ python -m spacy ray train [config_path] [--code-path] [--output] [--n-workers] [--address] [--gpu-id] [--verbose] [overrides] +$ python -m spacy ray train [config_path] [--code] [--output] [--n-workers] [--address] [--gpu-id] [--verbose] [overrides] ``` > #### Example