mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-12 17:22:25 +03:00
Move error to spacy.cli.download
Add extra message for Jupyter sessions
This commit is contained in:
parent
b99d2236ed
commit
92ebb931bf
|
@ -7,7 +7,13 @@ from wasabi import msg
|
||||||
|
|
||||||
from .. import about
|
from .. import about
|
||||||
from ..errors import OLD_MODEL_SHORTCUTS
|
from ..errors import OLD_MODEL_SHORTCUTS
|
||||||
from ..util import get_minor_version, is_package, is_prerelease_version, run_command
|
from ..util import (
|
||||||
|
get_minor_version,
|
||||||
|
is_in_jupyter,
|
||||||
|
is_package,
|
||||||
|
is_prerelease_version,
|
||||||
|
run_command,
|
||||||
|
)
|
||||||
from ._util import SDIST_SUFFIX, WHEEL_SUFFIX, Arg, Opt, app
|
from ._util import SDIST_SUFFIX, WHEEL_SUFFIX, Arg, Opt, app
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,6 +84,22 @@ def download(
|
||||||
f"You can now load the package via spacy.load('{model_name}')",
|
f"You can now load the package via spacy.load('{model_name}')",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
reload_deps_msg = (
|
||||||
|
"If you have one or more instances of the Python runtime executing "
|
||||||
|
"in the background, you'll need to restart them to correctly load "
|
||||||
|
"the dependencies of the newly downloaded model. "
|
||||||
|
)
|
||||||
|
if is_in_jupyter():
|
||||||
|
reload_deps_msg = (
|
||||||
|
f"{reload_deps_msg}This includes the current Jupyter session: "
|
||||||
|
"You can do this clicking on the 'Restart Kernel' button (or "
|
||||||
|
"'Restart Runtime' button in the case of Google Colab)"
|
||||||
|
)
|
||||||
|
msg.info(
|
||||||
|
"Reloading dependencies",
|
||||||
|
reload_deps_msg,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_model_filename(model_name: str, version: str, sdist: bool = False) -> str:
|
def get_model_filename(model_name: str, version: str, sdist: bool = False) -> str:
|
||||||
dl_tpl = "{m}-{v}/{m}-{v}{s}"
|
dl_tpl = "{m}-{v}/{m}-{v}{s}"
|
||||||
|
|
|
@ -229,10 +229,8 @@ class Errors(metaclass=ErrorsWithCodes):
|
||||||
"If you're using a Transformer, make sure to install 'spacy-transformers'. "
|
"If you're using a Transformer, make sure to install 'spacy-transformers'. "
|
||||||
"If you're using a custom component, make sure you've added the "
|
"If you're using a custom component, make sure you've added the "
|
||||||
"decorator `@Language.component` (for function components) or "
|
"decorator `@Language.component` (for function components) or "
|
||||||
"`@Language.factory` (for class components). If you installed the model "
|
"`@Language.factory` (for class components).\n\nAvailable "
|
||||||
"during the current Python/Jupyter session, you'll need to restart Python (or "
|
"factories: {opts}")
|
||||||
"reload your Jupyter notebook) to correctly load the dependencies.\n\n"
|
|
||||||
"Available factories: {opts}")
|
|
||||||
E003 = ("Not a valid pipeline component. Expected callable, but "
|
E003 = ("Not a valid pipeline component. Expected callable, but "
|
||||||
"got {component} (name: '{name}'). If you're using a custom "
|
"got {component} (name: '{name}'). If you're using a custom "
|
||||||
"component factory, double-check that it correctly returns your "
|
"component factory, double-check that it correctly returns your "
|
||||||
|
|
Loading…
Reference in New Issue
Block a user