Skip to content

Commit

Permalink
perf: caching deps and orgs, repos to avoid time taking checks & adde…
Browse files Browse the repository at this point in the history
…d slower version to check org and repo
  • Loading branch information
Aradhya-Tripathi committed Mar 28, 2022
1 parent 4441528 commit bd105a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bench/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from glob import glob
from shlex import split
from typing import List, Tuple
from functools import lru_cache

# imports - third party imports
import click
Expand Down Expand Up @@ -421,13 +422,16 @@ def clear_command_cache(bench_path="."):
print("Bench command cache doesn't exist in this folder!")


@lru_cache(maxsize=5)
def find_org(org_repo):
import requests

org_repo = org_repo[0]

for org in ["frappe", "erpnext"]:
res = requests.head(f"https://api.github.com/repos/{org}/{org_repo}")
if "message" in res.json():
res = requests.head(f"https://github.com/{org}/{org_repo}")
if res.ok:
return org, org_repo

Expand Down
2 changes: 2 additions & 0 deletions bench/utils/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
VersionNotFound,
)
from bench.app import get_repo_dir
from functools import lru_cache


def is_version_upgrade(app="frappe", bench_path=".", branch=None):
Expand Down Expand Up @@ -168,6 +169,7 @@ def get_current_branch(app, bench_path="."):
return get_cmd_output("basename $(git symbolic-ref -q HEAD)", cwd=repo_dir)


@lru_cache(maxsize=5)
def get_required_deps(org, name, branch, deps="hooks.py"):
import requests
import base64
Expand Down

0 comments on commit bd105a6

Please sign in to comment.