dacapo.store.mongo_config_store
Attributes
Classes
A MongoDB store for configurations. Used to store and retrieve |
Module Contents
- dacapo.store.mongo_config_store.logger
- class dacapo.store.mongo_config_store.MongoConfigStore(db_host, db_name)
A MongoDB store for configurations. Used to store and retrieve configurations for runs, tasks, architectures, trainers, and datasets.
- 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
- users
The users collection.
- Type:
Collection
- runs
The runs collection.
- Type:
Collection
- tasks
The tasks collection.
- Type:
Collection
- datasplits
The datasplits collection.
- Type:
Collection
- datasets
The datasets collection.
- Type:
Collection
- arrays
The arrays collection.
- Type:
Collection
- architectures
The architectures collection.
- Type:
Collection
- trainers
The trainers collection.
- Type:
Collection
- store_run_config(run_config, ignore)
Store the run configuration.
- retrieve_run_config(run_name)
Retrieve the run configuration.
- delete_run_config(run_name)
Delete the run configuration.
- retrieve_run_config_names(task_names, datasplit_names, architecture_names, trainer_names)
Retrieve the names of the run configurations.
- store_task_config(task_config, ignore)
Store the task configuration.
- retrieve_task_config(task_name)
Retrieve the task configuration.
- retrieve_task_config_names()
Retrieve the names of the task configurations.
- store_architecture_config(architecture_config, ignore)
Store the architecture configuration.
- retrieve_architecture_config(architecture_name)
Retrieve the architecture configuration.
- retrieve_architecture_config_names()
Retrieve the names of the architecture configurations.
- store_trainer_config(trainer_config, ignore)
Store the trainer configuration.
- retrieve_trainer_config(trainer_name)
Retrieve the trainer configuration.
- retrieve_trainer_config_names()
Retrieve the names of the trainer configurations.
- store_datasplit_config(datasplit_config, ignore)
Store the datasplit configuration.
- retrieve_datasplit_config(datasplit_name)
Retrieve the datasplit configuration.
- retrieve_datasplit_config_names()
Retrieve the names of the datasplit configurations.
- store_dataset_config(dataset_config, ignore)
Store the dataset configuration.
- retrieve_dataset_config(dataset_name)
Retrieve the dataset configuration.
- retrieve_dataset_config_names()
Retrieve the names of the dataset configurations.
- store_array_config(array_config, ignore)
Store the array configuration.
- retrieve_array_config(array_name)
Retrieve the array configuration.
- retrieve_array_config_names()
Retrieve the names of the array configurations.
- __save_insert(collection, data, ignore)
Save or insert a document into a collection.
- __same_doc(a, b, ignore)
Check if two documents are the same.
- __init_db()
Initialize the database.
- __open_collections()
Open the collections.
Notes
The store is initialized with the host and database name.
- db_host
- db_name
- client
- database
- delete_config(database, config_name: str) None
Deletes a configuration from the database.
- Parameters:
database – The database object.
config_name – The name of the configuration to delete.
- Raises:
ValueError – If the configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> config_name = 'config_0' >>> store.delete_config(store.tasks, config_name)
- store_run_config(run_config, ignore=None)
Stores the run configuration in the MongoDB runs collection.
- Parameters:
run_config (dict) – The run configuration to be stored.
ignore (list, optional) – A list of fields to ignore during the storage process.
- Raises:
DuplicateNameError – If the run configuration is already stored.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> run_config = {'name': 'run_0'} >>> store.store_run_config(run_config)
- retrieve_run_config(run_name)
Retrieve the run configuration for a given run name.
- Parameters:
run_name (str) – The name of the run.
- Returns:
The run configuration for the given run name.
- Return type:
- Raises:
ValueError – If the run configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> store.retrieve_run_config(run_name)
- delete_run_config(run_name)
Delete a run configuration from the MongoDB collection.
- Parameters:
run_name (str) – The name of the run configuration to delete.
- Raises:
ValueError – If the run configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> run_name = 'run_0' >>> store.delete_run_config(run_name)
- retrieve_run_config_names(task_names=None, datasplit_names=None, architecture_names=None, trainer_names=None)
Retrieve the names of run configurations based on specified filters.
- Parameters:
task_names (list, optional) – List of task names to filter the run configurations. Defaults to None.
datasplit_names (list, optional) – List of datasplit names to filter the run configurations. Defaults to None.
architecture_names (list, optional) – List of architecture names to filter the run configurations. Defaults to None.
trainer_names (list, optional) – List of trainer names to filter the run configurations. Defaults to None.
- Returns:
A list of run configuration names that match the specified filters.
- Return type:
list
- Raises:
ValueError – If the run configurations are not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> task_names = ['task_0'] >>> datasplit_names = ['datasplit_0'] >>> architecture_names = ['architecture_0'] >>> trainer_names = ['trainer_0'] >>> store.retrieve_run_config_names(task_names, datasplit_names, architecture_names, trainer_names)
- store_task_config(task_config, ignore=None)
Store the task configuration in the MongoDB tasks collection.
- Parameters:
task_config (TaskConfig) – The task configuration to be stored.
ignore (list, optional) – A list of fields to ignore during the storage process.
- Raises:
DuplicateNameError – If the task configuration is already stored.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> task_config = TaskConfig(name='task_0') >>> store.store_task_config(task_config)
- retrieve_task_config(task_name)
Retrieve the task configuration for a given task name.
- Parameters:
task_name (str) – The name of the task.
- Returns:
The task configuration object.
- Return type:
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> task_name = 'task_0' >>> store.retrieve_task_config(task_name)
- retrieve_task_config_names()
Retrieve the names of all task configurations.
- Returns:
A list of task configuration names.
- Raises:
ValueError – If the task configurations are not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> store.retrieve_task_config_names()
- store_architecture_config(architecture_config, ignore=None)
Store the architecture configuration in the MongoDB.
- Parameters:
architecture_config (ArchitectureConfig) – The architecture configuration to be stored.
ignore (list, optional) – List of fields to ignore during storage. Defaults to None.
- Raises:
DuplicateNameError – If the architecture configuration is already stored.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> architecture_config = ArchitectureConfig(name='architecture_0') >>> store.store_architecture_config(architecture_config)
- retrieve_architecture_config(architecture_name)
Retrieve the architecture configuration for the given architecture name.
- Parameters:
architecture_name (str) – The name of the architecture.
- Returns:
The architecture configuration object.
- Return type:
- Raises:
ValueError – If the architecture configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> architecture_name = 'architecture_0' >>> store.retrieve_architecture_config(architecture_name)
- retrieve_architecture_config_names()
Retrieve the names of all architecture configurations.
- Returns:
A list of architecture configuration names.
- Raises:
ValueError – If the architecture configurations are not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> store.retrieve_architecture_config_names()
- store_trainer_config(trainer_config, ignore=None)
Store the trainer configuration in the MongoDB.
- Parameters:
trainer_config (TrainerConfig) – The trainer configuration to be stored.
ignore (list, optional) – List of fields to ignore during storage. Defaults to None.
- Returns:
If the trainer configuration is already stored.
- Return type:
- Raises:
DuplicateNameError – If the trainer configuration is already stored.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> trainer_config = TrainerConfig(name='trainer_0') >>> store.store_trainer_config(trainer_config)
- retrieve_trainer_config(trainer_name)
Retrieve the trainer configuration for the given trainer name.
- Parameters:
trainer_name (str) – The name of the trainer.
- Returns:
The trainer configuration object.
- Return type:
- Raises:
ValueError – If the trainer configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> trainer_name = 'trainer_0' >>> store.retrieve_trainer_config(trainer_name)
- retrieve_trainer_config_names()
Retrieve the names of all trainer configurations.
- Parameters:
trainer_name (str) – The name of the trainer.
- Returns:
The trainer configuration object.
- Return type:
- Raises:
ValueError – If the trainer configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> trainer_name = 'trainer_0' >>> store.retrieve_trainer_config(trainer_name)
- store_datasplit_config(datasplit_config, ignore=None)
Store the datasplit configuration in the MongoDB.
- Parameters:
datasplit_config (DataSplitConfig) – The datasplit configuration to be stored.
ignore (list, optional) – List of fields to ignore during storage. Defaults to None.
- Returns:
If the datasplit configuration is already stored.
- Return type:
- Raises:
DuplicateNameError – If the datasplit configuration is already stored.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> datasplit_config = DataSplitConfig(name='datasplit_0') >>> store.store_datasplit_config(datasplit_config)
- retrieve_datasplit_config(datasplit_name)
Retrieve the datasplit configuration for the given datasplit name.
- Parameters:
datasplit_name (str) – The name of the datasplit.
- Returns:
The datasplit configuration object.
- Return type:
- Raises:
ValueError – If the datasplit configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> datasplit_name = 'datasplit_0' >>> store.retrieve_datasplit_config(datasplit_name)
- retrieve_datasplit_config_names()
Retrieve the names of all datasplit configurations.
- Returns:
A list of datasplit configuration names.
- Raises:
ValueError – If the datasplit configurations are not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> store.retrieve_datasplit_config_names()
- store_dataset_config(dataset_config, ignore=None)
Store the dataset configuration in the MongoDB.
- Parameters:
dataset_config (DatasetConfig) – The dataset configuration to be stored.
ignore (list, optional) – List of fields to ignore during storage. Defaults to None.
- Returns:
If the dataset configuration is already stored.
- Return type:
- Raises:
DuplicateNameError – If the dataset configuration is already stored.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> dataset_config = DatasetConfig(name='dataset_0') >>> store.store_dataset_config(dataset_config)
- retrieve_dataset_config(dataset_name)
Retrieve the dataset configuration for the given dataset name.
- Parameters:
dataset_name (str) – The name of the dataset.
- Returns:
The dataset configuration object.
- Return type:
- Raises:
ValueError – If the dataset configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> dataset_name = 'dataset_0' >>> store.retrieve_dataset_config(dataset_name)
- retrieve_dataset_config_names()
Retrieve the names of all dataset configurations.
- Returns:
A list of dataset configuration names.
- Raises:
ValueError – If the dataset configurations are not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> store.retrieve_dataset_config_names()
- store_array_config(array_config, ignore=None)
Store the array configuration in the MongoDB.
- Parameters:
array_config (ArrayConfig) – The array configuration to be stored.
ignore (list, optional) – List of fields to ignore during storage. Defaults to None.
- Returns:
If the array configuration is already stored.
- Return type:
- Raises:
DuplicateNameError – If the array configuration is already stored.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> array_config = ArrayConfig(name='array_0') >>> store.store_array_config(array_config)
- retrieve_array_config(array_name)
Retrieve the array configuration for the given array name.
- Parameters:
array_name (str) – The name of the array.
- Returns:
The array configuration object.
- Return type:
- Raises:
ValueError – If the array configuration is not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> array_name = 'array_0' >>> store.retrieve_array_config(array_name)
- retrieve_array_config_names()
Retrieve the names of all array configurations.
- Returns:
A list of array configuration names.
- Raises:
ValueError – If the array configurations are not available.
Examples
>>> store = MongoConfigStore('localhost', 'dacapo') >>> store.retrieve_array_config_names()