From f1c2bc275ef60aefeba944146b84663d71339450 Mon Sep 17 00:00:00 2001 From: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Date: Wed, 2 Mar 2022 11:46:24 -0800 Subject: [PATCH 1/5] Fix re-run smart build bug --- smartsim/_core/_cli/build.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/smartsim/_core/_cli/build.py b/smartsim/_core/_cli/build.py index 11d999f03..1d0382b83 100644 --- a/smartsim/_core/_cli/build.py +++ b/smartsim/_core/_cli/build.py @@ -1,4 +1,5 @@ import argparse +import os import sys from pathlib import Path @@ -9,6 +10,8 @@ from smartsim._core._install import builder from smartsim._core._install.buildenv import BuildEnv, SetupError, Version_, Versioner from smartsim._core._install.builder import BuildError +from smartsim._core.config import CONFIG +from smartsim._core.utils.helpers import installed_redisai_backends from smartsim.log import get_logger smart_logger_format = "[%(name)s] %(levelname)s %(message)s" @@ -97,6 +100,13 @@ def __init__(self): str(args.device), pt, tf, onnx, args.torch_dir, args.libtensorflow_dir ) + backends = [ + backend.capitalize() for backend in installed_redisai_backends() + ] + logger.info( + (", ".join(backends) if backends else "No") + " backend(s) built" + ) + except (SetupError, BuildError) as e: logger.error(str(e)) exit(1) @@ -144,6 +154,12 @@ def build_redis_ai( print(f" ONNX {self.versions.ONNX}: {color_bool(onnx)}\n") print(f"Building for GPU support: {color_bool(device == 'gpu')}\n") + if os.path.isdir(CONFIG.lib_path) and os.listdir(CONFIG.lib_path): + logger.error( + "If you wish to re-run `smart build`, you must first run `smart clean`." + ) + exit(1) + # Check for onnx and tf in user python environemnt and prompt user # to download them if they are not installed. this should not break # the build however, as we use onnx and tf directly from RAI instead From c52c83c3165a079980117e3470db2b62bce83f98 Mon Sep 17 00:00:00 2001 From: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Date: Fri, 18 Mar 2022 15:05:00 -0700 Subject: [PATCH 2/5] Account for RAI_PATH being set --- smartsim/_core/_cli/build.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/smartsim/_core/_cli/build.py b/smartsim/_core/_cli/build.py index 1d0382b83..0ed0b8b54 100644 --- a/smartsim/_core/_cli/build.py +++ b/smartsim/_core/_cli/build.py @@ -154,11 +154,7 @@ def build_redis_ai( print(f" ONNX {self.versions.ONNX}: {color_bool(onnx)}\n") print(f"Building for GPU support: {color_bool(device == 'gpu')}\n") - if os.path.isdir(CONFIG.lib_path) and os.listdir(CONFIG.lib_path): - logger.error( - "If you wish to re-run `smart build`, you must first run `smart clean`." - ) - exit(1) + self.check_backends_install() # Check for onnx and tf in user python environemnt and prompt user # to download them if they are not installed. this should not break @@ -314,3 +310,23 @@ def check_tf_install(self): ) except SetupError as e: logger.warning(str(e)) + + + def check_backends_install(self): + """Checks if backends have already been installed. + Logs details on how to proceed forward + if the RAI_PATH environment variable is set or if + backends have already been installed. + """ + if os.environ.get("RAI_PATH"): + if installed_redisai_backends(): + logger.error(f"Backends are already built and loaded at {CONFIG.redisai}. There is no need to build.") + else: + logger.error(f"Before running 'smart build', unset your RAI_PATH environment variable with 'unset RAI_PATH'.") + exit(1) + else: + if installed_redisai_backends(): + logger.error( + "If you wish to re-run `smart build`, you must first run `smart clean`." + ) + exit(1) \ No newline at end of file From 4ea8fe94361b87c131bc5b376fb451acb5718e1f Mon Sep 17 00:00:00 2001 From: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Date: Fri, 18 Mar 2022 15:06:10 -0700 Subject: [PATCH 3/5] Style --- smartsim/_core/_cli/build.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/smartsim/_core/_cli/build.py b/smartsim/_core/_cli/build.py index 0ed0b8b54..d705d6249 100644 --- a/smartsim/_core/_cli/build.py +++ b/smartsim/_core/_cli/build.py @@ -311,7 +311,6 @@ def check_tf_install(self): except SetupError as e: logger.warning(str(e)) - def check_backends_install(self): """Checks if backends have already been installed. Logs details on how to proceed forward @@ -320,13 +319,17 @@ def check_backends_install(self): """ if os.environ.get("RAI_PATH"): if installed_redisai_backends(): - logger.error(f"Backends are already built and loaded at {CONFIG.redisai}. There is no need to build.") + logger.error( + f"Backends are already built and loaded at {CONFIG.redisai}. There is no need to build." + ) else: - logger.error(f"Before running 'smart build', unset your RAI_PATH environment variable with 'unset RAI_PATH'.") + logger.error( + f"Before running 'smart build', unset your RAI_PATH environment variable with 'unset RAI_PATH'." + ) exit(1) else: if installed_redisai_backends(): logger.error( "If you wish to re-run `smart build`, you must first run `smart clean`." ) - exit(1) \ No newline at end of file + exit(1) From de3a4e592d80aa40bfac1889c98568d00db42b65 Mon Sep 17 00:00:00 2001 From: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Date: Fri, 18 Mar 2022 15:37:23 -0700 Subject: [PATCH 4/5] Small readability change --- smartsim/_core/_cli/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smartsim/_core/_cli/build.py b/smartsim/_core/_cli/build.py index d705d6249..8459db15c 100644 --- a/smartsim/_core/_cli/build.py +++ b/smartsim/_core/_cli/build.py @@ -320,7 +320,7 @@ def check_backends_install(self): if os.environ.get("RAI_PATH"): if installed_redisai_backends(): logger.error( - f"Backends are already built and loaded at {CONFIG.redisai}. There is no need to build." + f"Backends are already built and loaded at '{CONFIG.redisai}'. There is no need to build." ) else: logger.error( From 92187b944398d48a698b336de58f3551c339b77b Mon Sep 17 00:00:00 2001 From: Eric Gustin <34000337+EricGustin@users.noreply.github.com> Date: Sat, 19 Mar 2022 14:38:10 -0700 Subject: [PATCH 5/5] Address Sam's comment --- smartsim/_core/_cli/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smartsim/_core/_cli/build.py b/smartsim/_core/_cli/build.py index d705d6249..89df6bf40 100644 --- a/smartsim/_core/_cli/build.py +++ b/smartsim/_core/_cli/build.py @@ -320,7 +320,7 @@ def check_backends_install(self): if os.environ.get("RAI_PATH"): if installed_redisai_backends(): logger.error( - f"Backends are already built and loaded at {CONFIG.redisai}. There is no need to build." + f"There is no need to build. Backends are already built and specified in the environment at 'RAI_PATH': {CONFIG.redisai}" ) else: logger.error(