Skip to content

Commit

Permalink
Mod: Update permission error on tmp files for SPICE metric. Also remo…
Browse files Browse the repository at this point in the history
…ve setting cache path for windows unitests.
  • Loading branch information
Labbeti committed Sep 18, 2023
1 parent 9f8b245 commit 092c72a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
19 changes: 10 additions & 9 deletions src/aac_metrics/functional/spice.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def spice(
except (CalledProcessError, PermissionError) as err:
pylog.error("Invalid SPICE call.")
pylog.error(f"Full command: '{' '.join(spice_cmd)}'")
pylog.error(f"Error: {err}")
if (
stdout is not None
and stderr is not None
Expand All @@ -223,15 +224,15 @@ def spice(
pylog.error(
f"For more information, see temp files '{stdout.name}' and '{stderr.name}'."
)
with open(stdout.name, "r") as file:
lines = file.readlines()
content = "\n".join(lines)
pylog.error(f"Content of '{stdout.name}':\n{content}")

with open(stderr.name, "r") as file:
lines = file.readlines()
content = "\n".join(lines)
pylog.error(f"Content of '{stderr.name}':\n{content}")

for fpath in (stdout.name, stderr.name):
try:
with open(fpath, "r") as file:
lines = file.readlines()
content = "\n".join(lines)
pylog.error(f"Content of '{fpath}':\n{content}")
except PermissionError:
pass
else:
pylog.info(
f"Note: No temp file recorded. (found {stdout=} and {stderr=})"
Expand Down
4 changes: 0 additions & 4 deletions tests/test_compare_cet.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def setUpClass(cls) -> None:
os.makedirs(tmp_path, exist_ok=True)
set_default_tmp_path(tmp_path)

cache_path = osp.join(".", "cache")
os.makedirs(cache_path, exist_ok=True)
set_default_cache_path(cache_path)

cls.evaluate_metrics_from_lists = cls._import_cet_eval_func()

@classmethod
Expand Down
4 changes: 0 additions & 4 deletions tests/test_doc_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ def setUpClass(cls) -> None:
os.makedirs(tmp_path, exist_ok=True)
set_default_tmp_path(tmp_path)

cache_path = osp.join(".", "cache")
os.makedirs(cache_path, exist_ok=True)
set_default_cache_path(cache_path)

def test_example_1(self) -> None:
candidates: list[str] = ["a man is speaking", "rain falls"]
mult_references: list[list[str]] = [
Expand Down

0 comments on commit 092c72a

Please sign in to comment.