Skip to content

Commit

Permalink
Show spinner while fetching or installing models
Browse files Browse the repository at this point in the history
  • Loading branch information
adetorcy authored and kamwoods committed Feb 4, 2022
1 parent 68d7f9e commit 7e06ae1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
click
pbr
requests
rich
spacy>=3.1
tabulate
17 changes: 13 additions & 4 deletions spacy_model_manager/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import requests
import spacy
from packaging.version import parse
from rich.console import Console
from spacy.util import run_command
from tabulate import tabulate

console = Console()

# Spacy trained model names
SPACY_MODEL_NAMES = [
"ca_core_news_lg",
Expand Down Expand Up @@ -155,7 +158,10 @@ def list_spacy_models() -> int:
Print installed spaCy models
"""

releases = get_spacy_models()
with console.status(
"[bold green]Fetching available model versions...", spinner="dots"
):
releases = get_spacy_models()

# Sort the results by version name
releases = list(releases.items())
Expand Down Expand Up @@ -203,9 +209,12 @@ def install_spacy_model(
version_suffix, direct_download = (f"-{version}", True) if version else ("", False)

try:
spacy.cli.download(
f"{model}{version_suffix}", direct_download, False, "--quiet"
)
with console.status(
f"[bold green]Installing {model}{version_suffix}...", spinner="dots"
):
spacy.cli.download(
f"{model}{version_suffix}", direct_download, False, "--quiet"
)
except SystemExit:
click.echo(
click.style(
Expand Down

0 comments on commit 7e06ae1

Please sign in to comment.