From 0b862c07457c9914840bd0ce87a90306fec37456 Mon Sep 17 00:00:00 2001 From: Aradhya Date: Fri, 25 Mar 2022 22:27:58 +0530 Subject: [PATCH] feat: Added support for mounted app in get_dependencies --- bench/app.py | 13 ++++++++++--- bench/utils/app.py | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/bench/app.py b/bench/app.py index 9463c106..790850b9 100755 --- a/bench/app.py +++ b/bench/app.py @@ -215,12 +215,19 @@ class App(AppMeta): self.bench.run(f"{self.bench.python} -m pip uninstall -y {self.repo}") def _get_dependencies(self): - from bench.utils.app import get_required_deps + from bench.utils.app import get_required_deps, required_apps_from_hooks + if self.on_disk: + required_deps = os.path.join(self.mount_path, self.repo,'hooks.py') + try: + print(required_apps_from_hooks(required_deps)) + except IndexError: + print(f"No dependencies for {self.repo}") + finally: + return try: required_deps = get_required_deps(self.org, self.repo, self.tag or self.branch) - lines = [x for x in required_deps.split("\n") if x.strip().startswith("required_apps")] - required_apps = eval(lines[0].strip("required_apps").strip().lstrip("=").strip()) + return required_apps_from_hooks(required_deps) except Exception: return [] diff --git a/bench/utils/app.py b/bench/utils/app.py index 98c53514..f04b0020 100644 --- a/bench/utils/app.py +++ b/bench/utils/app.py @@ -183,6 +183,14 @@ def get_required_deps(org, name, branch, deps="hooks.py"): return base64.decodebytes(res["content"].encode()).decode() +def required_apps_from_hooks(required_deps): + with open(required_deps) as f: + required_deps = f.read() + lines = [x for x in required_deps.split("\n") if x.strip().startswith("required_apps")] + required_apps = eval(lines[0].strip("required_apps").strip().lstrip("=").strip()) + return required_apps + + def get_remote(app, bench_path="."): repo_dir = get_repo_dir(app, bench_path=bench_path) contents = subprocess.check_output(