provision: Avoid shelling out to clean caches.

Yes, it's slightly janky to create an
argparse.Namespace object like this, but it
saves us from shelling out to a script whose
only real value-add is parsing a single
`threshold_days` argument.

This saves about 130ms for a no-op provision.
This commit is contained in:
Steve Howell 2020-04-30 17:12:13 +00:00
parent 34191f2a56
commit adc0ed4206
2 changed files with 16 additions and 1 deletions

View File

@ -56,6 +56,7 @@ def overwrite_symlink(src: str, dst: str) -> None:
raise
def parse_cache_script_args(description: str) -> argparse.Namespace:
# Keep this in sync with clean_unused_caches in provision_inner.py
parser = argparse.ArgumentParser(description=description)
parser.add_argument(

View File

@ -168,6 +168,20 @@ def need_to_run_configure_rabbitmq(settings_list: List[str]) -> bool:
except Exception:
return True
def clean_unused_caches() -> None:
args = argparse.Namespace(
threshold_days=6,
# The defaults here should match parse_cache_script_args in zulip_tools.py
dry_run=False,
verbose=False,
no_headings=True,
)
from scripts.lib import clean_venv_cache, clean_node_cache, clean_emoji_cache
clean_venv_cache.main(args)
clean_node_cache.main(args)
clean_emoji_cache.main(args)
def main(options: argparse.Namespace) -> int:
setup_bash_profile()
setup_shell_profile('~/.zprofile')
@ -264,7 +278,7 @@ def main(options: argparse.Namespace) -> int:
if destroyed:
print("Dropped %s stale test databases!" % (destroyed,))
run(["scripts/lib/clean-unused-caches", "--threshold=6"])
clean_unused_caches()
# Keeping this cache file around can cause eslint to throw
# random TypeErrors when new/updated dependencies are added