deephyper.core.analytics.DBManager#

class deephyper.core.analytics.DBManager(username: str = None, path: str = None)[source]#

Bases: ABC

Database Manager, for saving DeepHyper experiments and accessing/modifying the resulting databases.

Example Usage:

>>> dbm = DBManager(username="Bob", path="path/to/db.json")
Parameters:
  • username (str, optional) – the name of the user accessing the database. Defaults to os.getlogin().

  • path (str, optional) – the path to the database. Defaults to "~/.deephyper/local_db.json".

Methods

add

Adds an experiment to the database.

delete

Deletes an experiment from the database.

get

Retrieve the desired experiment from the database.

list

Returns an iterator over the records stored in the database.

add(log_dir: str, label: str = None, description: str = None, pip_versions: str | bool = True, metadata: dict = None) int[source]#

Adds an experiment to the database.

Example Usage:

>>> dbm = DBManager(username="Bob", path="path/to/db.json")
>>> metadata = {"machine": "ThetaGPU", "n_nodes": 4, "num_gpus_per_node": 8}
>>> dbm.add("path/to/search/log_dir/", label="exp_101", description="The experiment 101", metadata=metadata)
Parameters:
  • log_dir (str) – the path to the search’s logging directory.

  • label (str, optional) – the label wished for the experiment. Defaults to None.

  • description (str, optional) – the description wished for the experiment. Defaults to None.

  • pip_versions (str or bool, optional) – a boolean for which False means that we don’t store any pip version checkpoint, and True that we store the current pip version checkpoint ; or the path to a .json file corresponding to the ouptut of pip list --format json. Defaults to True.

  • metadata (dict, optional) – a dictionary of metadata. When the same key is found in the default default_metadata and the passed metadata then the values from default_metadata are overriden by metadata values. Defaults to None.

delete(ids: list)[source]#

Deletes an experiment from the database.

Example Usage:

>>> dbm = DBManager(username="Bob", path="path/to/db.json")
>>> dbm.delete([23, 16])
Parameters:

ids (list) – indexes of the records to delete.

get(cond=None, exp_id=None)[source]#

Retrieve the desired experiment from the database.

Example Usage:

>>> dbm = DBManager(username="Bob", path="path/to/db.json")
>>> dbm.get(23)
Parameters:
  • cond (tinydb.Query) – a search condition.

  • exp_id (int) – index of the record to delete.

Returns:

the retrieved documents in the database.

Return type:

(list|dict)

list()[source]#

Returns an iterator over the records stored in the database.

Example Usage:

>>> dbm = DBManager(username="Bob", path="path/to/db.json")
>>> experiments = dbm.list()
>>> for exp in experiments:
>>>     ...