beat.web.backend.utils module

Utilities for backend management

beat.web.backend.utils.cleanup_cache(path, age_in_minutes=0, delete=False)[source]

Removes files which are older than a certain threshold from a directory

This function can be used for cache maintenance. It allows the the user to remove all files under a certain directory which are older than a number of minutes. It also save some files from being erased (if they belong to experiments which are running or scheduled).

Parameters:
  • path (str) – The path to the cache root (typically, settings.CACHE_ROOT)
  • age_in_minutes (int, Optional) – The mininum access time of files (in minutes) that will be erased from the disk. All files older than this cut-off value will be erased. All others will be kept.
  • delete (bool, Optional) – If set (defaults to False), then we really delete the marked files. Otherwise, we just return the list of files which we would delete.
Returns:

A list of filenames that will be/were removed

Return type:

list

beat.web.backend.utils.setup_backend(d)[source]

Configures or re-configures the internal queue setup

This method is called to re-configure the current backend architecture. It is guaranteed to be called only if no experiments are currently running on resources that will disappear (this is checked). The reason for this present restriction goes through difficulties in handling “disappearing” queues and/or environments.

Parameters:d (dict) – A JSON generated directory that defines the queue and slots available at the backend farm.
Raises:RuntimeError – If an error is detected and the re-configuration cannot take place. In this case, it is safe to assume nothing has changed.
beat.web.backend.utils.dump_backend()[source]

Returns a dictionary that represents the current backend configuration