mirror of https://github.com/zulip/zulip.git
clean-venv-cache: Directly import functions from 'hash_reqs.py'.
Instead of running the 'hash_reqs.py' as a script, directly import functions from it to calculate the hash. This will speed up the script.
This commit is contained in:
parent
ecbc75e00f
commit
5e2b54446f
|
@ -1,16 +1,14 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import Set, Text
|
from typing import Set, Text
|
||||||
|
|
||||||
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
sys.path.append(ZULIP_PATH)
|
sys.path.append(ZULIP_PATH)
|
||||||
|
from scripts.lib.hash_reqs import expand_reqs, hash_deps
|
||||||
from scripts.lib.zulip_tools import GENERIC_CACHE_SCRIPT_PARSER, \
|
from scripts.lib.zulip_tools import GENERIC_CACHE_SCRIPT_PARSER, \
|
||||||
get_caches_to_be_purged, get_environment, get_recent_deployments, \
|
get_caches_to_be_purged, get_environment, get_recent_deployments, \
|
||||||
purge_unused_caches
|
purge_unused_caches
|
||||||
|
@ -31,14 +29,17 @@ def get_caches_in_use(threshold_days):
|
||||||
# type: (int) -> Set[Text]
|
# type: (int) -> Set[Text]
|
||||||
setups_to_check = set([ZULIP_PATH, ])
|
setups_to_check = set([ZULIP_PATH, ])
|
||||||
caches_in_use = set()
|
caches_in_use = set()
|
||||||
|
|
||||||
if ENV == "prod":
|
if ENV == "prod":
|
||||||
setups_to_check |= get_recent_deployments(threshold_days)
|
setups_to_check |= get_recent_deployments(threshold_days)
|
||||||
hash_reqs = os.path.join(ZULIP_PATH, 'scripts', 'lib', 'hash_reqs.py')
|
|
||||||
for path in setups_to_check:
|
for path in setups_to_check:
|
||||||
for filename in os.listdir(os.path.join(path, "requirements")):
|
for filename in os.listdir(os.path.join(path, "requirements")):
|
||||||
requirements_file = os.path.join(path, "requirements", filename)
|
requirements_file = os.path.join(path, "requirements", filename)
|
||||||
hash_val = subprocess.check_output([hash_reqs, requirements_file]).strip()
|
deps = expand_reqs(requirements_file)
|
||||||
caches_in_use.add(os.path.join(VENV_CACHE_DIR, hash_val.decode('utf-8')))
|
hash_val = hash_deps(deps)
|
||||||
|
caches_in_use.add(os.path.join(VENV_CACHE_DIR, hash_val))
|
||||||
|
|
||||||
return caches_in_use
|
return caches_in_use
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in New Issue