Skip to content

Commit

Permalink
feat: Added support for mounted app in get_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Aradhya-Tripathi committed Mar 25, 2022
1 parent 8230ba6 commit 0b862c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,19 @@ def uninstall(self):
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 []

Expand Down
8 changes: 8 additions & 0 deletions bench/utils/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 0b862c0

Please sign in to comment.