deephyper.core.analytics.DBManager
deephyper.core.analytics.DBManager#
-
class
deephyper.core.analytics.
DBManager
(user_name: Optional[str] = None, path: Optional[str] = None)[source]# Bases:
abc.ABC
Database Manager, for saving DeepHyper experiments and accessing/modifying the resulting databases.
Example Usage:
>>> dbm = DBManager(user_name="Bob", path="path/to/db.json")
- Parameters
Methods
Adds an experiment to the database.
Deletes an experiment from the database.
Retrieve the desired experiment from the database.
Returns an iterator over the records stored in the database.
-
add
(log_dir: str, label: Optional[str] = None, description: Optional[str] = None, pip_versions: Union[str, bool] = True, metadata: Optional[dict] = None)[source]# Adds an experiment to the database.
Example Usage:
>>> dbm = DBManager(user_name="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, andTrue
that we store the current pip version checkpoint ; or the path to a.json
file corresponding to the ouptut ofpip 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(user_name="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(user_name="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)