From 6b5ef45bdffac99e9aa2aaf2b31a2ad7fd2ecd9d Mon Sep 17 00:00:00 2001 From: Jason Wen <47793918+sunnyhaibin@users.noreply.github.com> Date: Tue, 21 Feb 2023 17:30:43 -0500 Subject: [PATCH] mapd: cache downloaded dependencies --- selfdrive/manager/custom_dep.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/selfdrive/manager/custom_dep.py b/selfdrive/manager/custom_dep.py index 5157b289b2..00ed914630 100755 --- a/selfdrive/manager/custom_dep.py +++ b/selfdrive/manager/custom_dep.py @@ -14,12 +14,13 @@ import importlib.util from common.spinner import Spinner -sys.path.append(os.path.join(BASEDIR, "third_party")) +sys.path.append(os.path.join(BASEDIR, "third_party/mapd")) OPSPLINE_SPEC = importlib.util.find_spec('scipy') OVERPY_SPEC = importlib.util.find_spec('overpy') MAX_BUILD_PROGRESS = 100 TMP_DIR = '/data/tmp' -THIRD_PARTY_DIR = '/data/openpilot/third_party' +THIRD_PARTY_DIR = '/data/openpilot/third_party/mapd' +THIRD_PARTY_DIR_SP = '/data/third_party_community' def wait_for_internet_connection(return_on_failure=False): @@ -77,10 +78,21 @@ def install_dep(spinner): if OPSPLINE_SPEC is None: for directory in glob(f'{THIRD_PARTY_DIR}/numpy*'): shutil.rmtree(directory) - shutil.rmtree(f'{THIRD_PARTY_DIR}/bin') + if os.path.exists(f'{THIRD_PARTY_DIR}/bin'): + shutil.rmtree(f'{THIRD_PARTY_DIR}/bin') + + dup = f'cp -rf {THIRD_PARTY_DIR} {THIRD_PARTY_DIR_SP}' + process_dup = subprocess.Popen(dup, stdout=subprocess.PIPE, shell=True) if __name__ == "__main__" and (OPSPLINE_SPEC is None or OVERPY_SPEC is None): spinner = Spinner() - spinner.update_progress(0, 100) - install_dep(spinner) + if os.path.exists(THIRD_PARTY_DIR_SP): + spinner.update("Loading dependencies") + command = f'rm -rf {THIRD_PARTY_DIR}; cp -rf {THIRD_PARTY_DIR_SP} {THIRD_PARTY_DIR}' + process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) + print(f"SP_LOG: Removed directory {THIRD_PARTY_DIR}") + print(f"SP_LOG: Copied {THIRD_PARTY_DIR_SP} to {THIRD_PARTY_DIR}") + else: + spinner.update("Waiting for internet") + install_dep(spinner)