dacapo.store.mongo_stats_store
Attributes
Classes
A MongoDB store for run statistics. Used to store and retrieve training |
Module Contents
- dacapo.store.mongo_stats_store.logger
- class dacapo.store.mongo_stats_store.MongoStatsStore(db_host, db_name)
A MongoDB store for run statistics. Used to store and retrieve training statistics and validation scores.
- db_host
The host of the MongoDB database.
- Type:
str
- db_name
The name of the MongoDB database.
- Type:
str
- client
The MongoDB client.
- Type:
MongoClient
- database
The MongoDB database.
- Type:
Database
- training_stats
The collection for training statistics.
- Type:
Collection
- validation_scores
The collection for validation scores.
- Type:
Collection
- store_training_stats(run_name, stats)
Store the training stats of a given run.
- retrieve_training_stats(run_name)
Retrieve the training stats for a given run.
- store_validation_iteration_scores(run_name, scores)
Store the validation iteration scores of a given run.
- retrieve_validation_iteration_scores(run_name)
Retrieve the validation iteration scores for a given run.
- delete_training_stats(run_name)
Delete the training stats associated with a specific run.
Notes
The MongoStatsStore uses the ‘training_stats’ and ‘validation_scores’ collections to store the statistics.
- db_host
- db_name
- client
- database
- store_training_stats(run_name: str, stats: dacapo.experiments.TrainingStats)
Store the training statistics for a specific run.
- Parameters:
run_name (str) – The name of the run.
stats (TrainingStats) – The training statistics to be stored.
- Raises:
ValueError – If the training statistics are already stored.
Examples
>>> store = MongoStatsStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> stats = TrainingStats() >>> store.store_training_stats(run_name, stats)
Notes
The training statistics are stored in the ‘training_stats’ collection.
- retrieve_training_stats(run_name: str, subsample: bool = False) dacapo.experiments.TrainingStats
Retrieve the training statistics for a given run.
- Parameters:
run_name (str) – The name of the run.
subsample (bool, optional) – Whether to subsample the training statistics. Defaults to False.
- Returns:
The training statistics for the specified run.
- Return type:
- Raises:
ValueError – If the training statistics are not available.
Examples
>>> store = MongoStatsStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> store.retrieve_training_stats(run_name)
Notes
The training statistics are retrieved from the ‘training_stats’ collection.
- store_validation_iteration_scores(run_name: str, scores: dacapo.experiments.ValidationScores)
Stores the validation iteration scores for a given run.
- Parameters:
run_name (str) – The name of the run.
scores (ValidationScores) – The validation scores to store.
Examples
>>> store = MongoStatsStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> scores = ValidationScores() >>> store.store_validation_iteration_scores(run_name, scores)
Notes
The validation iteration scores are stored in the ‘validation_scores’ collection.
- retrieve_validation_iteration_scores(run_name: str, subsample: bool = False, validation_interval: int | None = None) List[dacapo.experiments.ValidationIterationScores]
Retrieve the validation iteration scores for a given run.
- Parameters:
run_name (str) – The name of the run.
subsample (bool, optional) – Whether to subsample the scores. Defaults to False.
validation_interval (int, optional) – The interval at which to retrieve the scores. Defaults to None.
- Returns:
A list of validation iteration scores.
- Return type:
- Raises:
ValueError – If the validation iteration scores are not available.
Examples
>>> store = MongoStatsStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> store.retrieve_validation_iteration_scores(run_name)
Notes
The validation iteration scores are retrieved from the ‘validation_scores’ collection.
- delete_validation_scores(run_name: str) None
Deletes the validation scores for a given run.
- Parameters:
run_name (str) – The name of the run for which validation scores should be deleted.
- Raises:
ValueError – If the validation scores are not available.
Examples
>>> store = MongoStatsStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> store.delete_validation_scores(run_name)
Notes
The validation scores are deleted from the ‘validation_scores’ collection.
- delete_training_stats(run_name: str) None
Deletes the training stats for a given run.
- Parameters:
run_name (str) – The name of the run for which training stats should be deleted.
- Raises:
ValueError – If the training statistics are not available.
Examples
>>> store = MongoStatsStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> store.delete_training_stats(run_name)
Notes
The training statistics are deleted from the ‘training_stats’ collection.