Skip to content

manage_cache

Description of the functions implemented to store and manage lib data in a local cache on the disk:

bnn_for_14C_calibration.manage_cache.download_cache_lib_data(overwrite=False)

Download and initialize the local cache directory for the library.

This function manages the creation (or re-creation) of the local cache directory used by the package to store pre-downloaded model and data files.
If overwrite is set to True, any existing cache will be removed before re-downloading.

Parameters:

Name Type Description Default
overwrite bool

Whether to force re-downloading and replace any existing cache directory (default is False).

False

Returns:

Type Description
None
Notes
  • The cache directory .bnn_for_14C_calibration is created in the user's home directory.
  • Requires an active internet connection for the first run.
  • Disk space usage remains below 1 GB.
  • This function internally calls the functions clear_cache and download_github_with_drive_map.

Examples:

>>> download_cache_lib_data(overwrite=False)
This may be the first time you need package functions that use 
local cache data to work. A local cache directory is going to be 
created and will be used after if needed without a new downloading
unless you delete the cache. To download this cache, network connection 
must be available; also some disk space is required (less than 1 GB total).
******************** Creating cache directory at: /home/user/.bnn_for_14C_calibration ********************
✅ Cache directory created at: /home/user/.bnn_for_14C_calibration, and filled with all the 
contents of the 'models' directory downloaded from GitHub and Google Drive.
>>> download_cache_lib_data(overwrite=True)
overwrite is True : the cache will be cleared before 
downloading it again...
🗑️ removing cache directory at : /home/user/.bnn_for_14C_calibration...
🗑️ cache removed!
******************** Creating cache directory at: /home/user/.bnn_for_14C_calibration ********************
✅ Cache directory created at: /home/user/.bnn_for_14C_calibration, and filled with all the 
contents of the 'models' directory downloaded from GitHub and Google Drive.

bnn_for_14C_calibration.manage_cache.clear_cache()

Remove the entire local cache directory used by the library.

This function deletes the cache directory and all its contents from the local filesystem. If the cache directory does not exist, a message is printed to indicate that there is no existing cache to remove.

Parameters:

Name Type Description Default
None
required

Returns:

Type Description
None
Notes
  • The cache directory path is set to /home/user/.bnn_for_14C_calibration.
  • This operation is irreversible; all cached data will be lost.
  • The cache data can be downloaded again by using the function download_cache_lib_data.

Examples:

>>> clear_cache()
🗑️ removing cache directory at: /home/user/.bnn_for_14C_calibration...
🗑️ cache removed!