mirror of https://github.com/explosion/spaCy.git
Fix and simplify info
This commit is contained in:
parent
fca3907d4e
commit
189ed56777
|
@ -8,7 +8,7 @@ warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
|
||||||
from thinc.api import prefer_gpu, require_gpu
|
from thinc.api import prefer_gpu, require_gpu
|
||||||
|
|
||||||
from . import pipeline
|
from . import pipeline
|
||||||
from .cli.info import info as cli_info
|
from .cli.info import info
|
||||||
from .glossary import explain
|
from .glossary import explain
|
||||||
from .about import __version__
|
from .about import __version__
|
||||||
from .errors import Errors, Warnings
|
from .errors import Errors, Warnings
|
||||||
|
@ -34,7 +34,3 @@ def load(name, **overrides):
|
||||||
def blank(name, **kwargs):
|
def blank(name, **kwargs):
|
||||||
LangClass = util.get_lang_class(name)
|
LangClass = util.get_lang_class(name)
|
||||||
return LangClass(**kwargs)
|
return LangClass(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
def info(model=None, markdown=False, silent=False):
|
|
||||||
return cli_info(model, markdown, silent)
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ from wasabi import Printer
|
||||||
import srsly
|
import srsly
|
||||||
|
|
||||||
from ._app import app, Arg, Opt
|
from ._app import app, Arg, Opt
|
||||||
from .validate import get_model_pkgs
|
|
||||||
from .. import util
|
from .. import util
|
||||||
from .. import about
|
from .. import about
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ def info_cli(
|
||||||
|
|
||||||
|
|
||||||
def info(
|
def info(
|
||||||
model: Optional[str], *, markdown: bool = False, silent: bool = True
|
model: Optional[str] = None, *, markdown: bool = False, silent: bool = True
|
||||||
) -> Union[str, dict]:
|
) -> Union[str, dict]:
|
||||||
msg = Printer(no_print=silent, pretty=not silent)
|
msg = Printer(no_print=silent, pretty=not silent)
|
||||||
if model:
|
if model:
|
||||||
|
@ -43,7 +42,7 @@ def info(
|
||||||
return markdown_data
|
return markdown_data
|
||||||
if not silent:
|
if not silent:
|
||||||
msg.table(data, title=title)
|
msg.table(data, title=title)
|
||||||
return data
|
return {k.lower().replace(" ", "_"): v for k, v in data.items()}
|
||||||
|
|
||||||
|
|
||||||
def info_spacy(*, silent: bool = True) -> Dict[str, any]:
|
def info_spacy(*, silent: bool = True) -> Dict[str, any]:
|
||||||
|
@ -52,8 +51,11 @@ def info_spacy(*, silent: bool = True) -> Dict[str, any]:
|
||||||
silent (bool): Don't print anything, just return.
|
silent (bool): Don't print anything, just return.
|
||||||
RETURNS (dict): The spaCy info.
|
RETURNS (dict): The spaCy info.
|
||||||
"""
|
"""
|
||||||
all_models, _ = get_model_pkgs(silent=silent)
|
all_models = {}
|
||||||
models = ", ".join(f"{m['name']} ({m['version']})" for m in all_models.values())
|
for pkg_name in util.get_installed_models():
|
||||||
|
package = pkg_name.replace("-", "_")
|
||||||
|
all_models[package] = util.get_package_version(pkg_name)
|
||||||
|
models = ", ".join(f"{name} ({version})" for name, version in all_models.items())
|
||||||
return {
|
return {
|
||||||
"spaCy version": about.__version__,
|
"spaCy version": about.__version__,
|
||||||
"Location": str(Path(__file__).parent.parent),
|
"Location": str(Path(__file__).parent.parent),
|
||||||
|
|
Loading…
Reference in New Issue