From e46812a06d800182e025c54ddfdc8b98df782f6f Mon Sep 17 00:00:00 2001 From: Jonathan Prokos Date: Tue, 7 Mar 2023 20:14:08 +0000 Subject: [PATCH 1/2] Adding verbose error message when trying to import armory.metrics without the proper dependencies installed --- armory/metrics/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/armory/metrics/__init__.py b/armory/metrics/__init__.py index 4588c1590..0703142c3 100644 --- a/armory/metrics/__init__.py +++ b/armory/metrics/__init__.py @@ -1,7 +1,13 @@ import importlib from typing import Callable -from armory.metrics import compute, perturbation, statistical, task +try: + from armory.metrics import compute, perturbation, statistical, task +except ImportError as e: + raise ImportError( + "armory engine dependencies are not installed. " + "Please install armory-testbed[engine] to use metrics." + ) from armory.metrics.common import get_result_formatter, result_formatter, supported From 9696dbeeda6cef4292d08131ad5a35d98e339bb0 Mon Sep 17 00:00:00 2001 From: Jonathan Prokos Date: Tue, 7 Mar 2023 20:23:53 +0000 Subject: [PATCH 2/2] Fixing flake8 error --- armory/metrics/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/armory/metrics/__init__.py b/armory/metrics/__init__.py index 0703142c3..e696a10bf 100644 --- a/armory/metrics/__init__.py +++ b/armory/metrics/__init__.py @@ -3,7 +3,7 @@ try: from armory.metrics import compute, perturbation, statistical, task -except ImportError as e: +except ImportError: raise ImportError( "armory engine dependencies are not installed. " "Please install armory-testbed[engine] to use metrics."