# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_cli.ipynb.

# %% auto 0
__all__ = ['update_cache']

# %% ../nbs/01_cli.ipynb 2
from fastcore.script import call_parse
from fastcore.utils import *
from nbdev.test import nbdev_test

# %% ../nbs/01_cli.ipynb 4
def _clean_cache():
    "Remove stale requests by replacing the old cache with the updated cache."
    cache_dir = Path(Config.find('settings.ini').config_path)
    cpth = cache_dir / 'reclm.json'
    ucpth = cache_dir / 'updated_reclm.json'
    ucpth.rename(cpth)

@call_parse
def update_cache(n_workers:int=None):
    "Update the reclm cache"
    os.environ['CLEAN_RECLM_CACHE']='1'
    print('Updating cache...')
    nbdev_test(n_workers=n_workers)
    _clean_cache()
    print('Cache is up to date.')
    return
