Skip to content

Commit

Permalink
Fix install spacy transformer model error(#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyzz committed Jul 24, 2023
1 parent cdbaeef commit bd77e87
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from calibre.customize import InterfaceActionBase

VERSION = (3, 29, 4)
VERSION = (3, 29, 5)


class WordDumbDumb(InterfaceActionBase):
Expand Down
3 changes: 2 additions & 1 deletion data/deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"thinc-apple-ops": "0.1.3",
"torch": "2.0.1",
"rapidfuzz": "3.1.2",
"spacy_model": "3.6.0"
"spacy_cpu_model": "3.6.0",
"spacy_trf_model": "3.6.1"
}
7 changes: 5 additions & 2 deletions deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def install_deps(pkg: str, notif: Any) -> None:
# Install X-Ray dependencies
pip_install("rapidfuzz", dep_versions["rapidfuzz"], notif=notif)

url = f"https://github.com/explosion/spacy-models/releases/download/{pkg}-{dep_versions['spacy_model']}/{pkg}-{dep_versions['spacy_model']}-py3-none-any.whl"
pip_install(pkg, dep_versions["spacy_model"], url=url, notif=notif)
model_version = dep_versions[
"spacy_trf_model" if pkg.endswith("_trf") else "spacy_cpu_model"
]
url = f"https://github.com/explosion/spacy-models/releases/download/{pkg}-{model_version}/{pkg}-{model_version}-py3-none-any.whl"
pip_install(pkg, model_version, url=url, notif=notif)
if pkg.endswith("_trf"):
from .config import prefs

Expand Down
7 changes: 6 additions & 1 deletion parse_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def create_files(
prefs: Prefs,
notif: Any,
) -> None:
"""
This function runs in system Python subprocess for official(frozen) calibre build.
"""
is_epub = not kfx_json and not mobi_codec
plugin_path = Path(plugin_path_str)
insert_installed_libs(plugin_path)
Expand Down Expand Up @@ -779,7 +782,9 @@ def create_spacy_matcher(

disabled_pipes = list(set(["ner", "parser", "senter"]) & set(nlp.pipe_names))
pkg_versions = load_plugin_json(plugin_path, "data/deps.json")
model_version = pkg_versions["spacy_model"]
model_version = model_version = pkg_versions[
"spacy_trf_model" if model.endswith("_trf") else "spacy_cpu_model"
]
phrase_matcher = PhraseMatcher(nlp.vocab, attr="LOWER")
phrases_doc_path = spacy_doc_path(
model, model_version, lemma_lang, is_kindle, True, plugin_path, prefs
Expand Down

0 comments on commit bd77e87

Please sign in to comment.