Skip to content

Commit

Permalink
Mod: Rework SPICE internal code and update SPICE download information…
Browse files Browse the repository at this point in the history
… shown.
  • Loading branch information
Labbeti committed Sep 25, 2023
1 parent 85d9e9b commit 30641b5
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 147 deletions.
18 changes: 11 additions & 7 deletions src/aac_metrics/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def _download_ptb_tokenizer(
url = info["url"]
fname = info["fname"]
fpath = osp.join(stanford_nlp_dpath, fname)

if not osp.isfile(fpath):
if verbose >= 1:
pylog.info(
Expand Down Expand Up @@ -212,9 +213,10 @@ def _download_spice(
pylog.info(f"Downloading SPICE ZIP file '{spice_zip_fpath}'...")
download_url_to_file(spice_zip_url, spice_zip_fpath, progress=verbose > 0)

script_path = osp.join(osp.dirname(__file__), "install_spice.sh")
if not osp.isfile(script_path):
raise FileNotFoundError(f"Cannot find script '{osp.basename(script_path)}'.")
script_fname = "install_spice.sh"
script_fpath = osp.join(osp.dirname(__file__), script_fname)
if not osp.isfile(script_fpath):
raise FileNotFoundError(f"Cannot find script '{osp.basename(script_fpath)}'.")

if verbose >= 1:
pylog.info(
Expand All @@ -224,16 +226,18 @@ def _download_spice(
if use_shell is None:
use_shell = platform.system() == "Windows"

command = ["bash", script_path, spice_jar_dpath]
command = ["bash", script_fpath, spice_jar_dpath]
try:
subprocess.check_call(
command,
stdout=None if verbose >= 2 else subprocess.DEVNULL,
stderr=None if verbose >= 2 else subprocess.DEVNULL,
stdout=None if verbose >= 1 else subprocess.DEVNULL,
stderr=None if verbose >= 1 else subprocess.DEVNULL,
shell=use_shell,
)
except (CalledProcessError, PermissionError) as err:
pylog.error("Cannot install SPICE java source code.")
pylog.error(
f"Cannot install SPICE java source code from '{script_fname}' script."
)
raise err


Expand Down
Loading

0 comments on commit 30641b5

Please sign in to comment.