From d8b9e1c82ddd31272104625d721a9efca1e43681 Mon Sep 17 00:00:00 2001
From: Yifan Zhao <yifanz16@illinois.edu>
Date: Tue, 23 Mar 2021 12:51:38 -0500
Subject: [PATCH] Install python packages in installer

---
 hpvm/scripts/automated_tests.sh | 31 -------------------------------
 hpvm/scripts/hpvm_installer.py  | 19 ++++++++++++++++++-
 2 files changed, 18 insertions(+), 32 deletions(-)
 delete mode 100644 hpvm/scripts/automated_tests.sh

diff --git a/hpvm/scripts/automated_tests.sh b/hpvm/scripts/automated_tests.sh
deleted file mode 100644
index aece74eaa0..0000000000
--- a/hpvm/scripts/automated_tests.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-CURRENT_DIR=`pwd`
-BUILD_DIR=$CURRENT_DIR/build
-HPVM_RT=hpvm-rt/hpvm-rt.bc
-
-if [ -f $BUILD_DIR/tools/hpvm/projects/$HPVM_RT ]; then
-    true
-else
-    echo $BUILD_DIR/tools/hpvm/projects/$HPVM_RT
-    echo HPVM not installed! Exiting without running tests!.
-    exit 0
-fi
-
-LIT_DIR=$BUILD_DIR/bin/
-
-LIT_TOOL=$LIT_DIR/llvm-lit
-
-TEST_DIR=$CURRENT_DIR/test
-REG_TEST_DIR=$TEST_DIR/regressionTests
-UNIT_TEST_DIR=$TEST_DIR/unitTests
-
-echo
-echo Running tests ...
-echo
-
-# Run regression tests
-$LIT_TOOL -v $REG_TEST_DIR
-
-# Run unit tests
-#$LIT_TOOL -v $UNIT_TEST_DIR
diff --git a/hpvm/scripts/hpvm_installer.py b/hpvm/scripts/hpvm_installer.py
index 4d1fefdc7a..cd6ef3bae0 100755
--- a/hpvm/scripts/hpvm_installer.py
+++ b/hpvm/scripts/hpvm_installer.py
@@ -31,8 +31,14 @@ LINKS = [
     "tools",
 ]
 MAKE_TARGETS = ["approxhpvm.py"]
-MAKE_TEST_TARGETS = ["hpvm-check"]
+MAKE_TEST_TARGETS = ["check-hpvm-dnn", "check-hpvm-pass"]
 
+# Relative to project root which is __file__.parent.parent
+PY_PACKAGES = [
+    "projects/predtuner",
+    "projects/torch2hpvm",
+    "projects/keras",
+]
 
 def parse_args():
     parser = ArgumentParser(
@@ -241,6 +247,16 @@ For more details refer to README.md.
     chdir(ROOT_DIR)
 
 
+def install_py_packages():
+    import sys
+
+    project_root = Path(__file__).parent.parent
+    for package in PY_PACKAGES:
+        package_home = project_root / package
+        print(f"Installing python package {package_home}")
+        check_call([sys.executable, "-m", "pip", "install", str(package_home)])
+
+
 def run_tests():
     chdir(BUILD_DIR)
     # Run regression tests
@@ -270,6 +286,7 @@ def main():
     if not args.no_params:
         check_download_model_params()
     maybe_build(not args.no_build, args.parallel, args.targets, args.run_tests)
+    install_py_packages()
     if args.run_tests:
         run_tests()
     else:
-- 
GitLab