ModelDatabase#
- class pharmpy.workflows.ModelDatabase[source]#
Bases:
ABC
Baseclass for databases for models and results of model runs
Primary key is the model name, which means that models with the same name will be counted as the same model.
Currently the model database is centered around storing and retrieving files belonging to the model or results from fitting the model. This doesn’t mean that implementations have to use a file system to store the files.
Methods Summary
list_all_files
(model)Lists all file names related to a model run
retrieve_all_files
(model, destination_path)Retrieve all files related to a model run
retrieve_file
(model, filename, destination_path)Retrieve one file related to a model run
retrieve_model
(model)Read a model from the database
retrieve_model_entry
(model)Read model entry from the database
retrieve_modelfit_results
(model)Read modelfit results from the database
snapshot
(model)Creates a readable snapshot context for a given model.
store_local_file
(model, path[, new_filename])Store a file from the local machine
store_metadata
(model, metadata)Store metadata
store_model
(model)Store a model object
store_model_entry
(model_entry)Store model entry of the model entry bound to this transaction
store_modelfit_results
(model)Store modelfit results
transaction
(obj)Creates a writable transaction context for a given model.
Methods Documentation
- abstractmethod list_all_files(model)[source]#
Lists all file names related to a model run
Note that this will not return a list of full paths, only the name of the files
- Parameters:
model (Model, ModelHash) – Model object or ModelHash
- Returns:
list[str] – List of file names
- abstractmethod retrieve_all_files(model, destination_path, force=False)[source]#
Retrieve all files related to a model run
- Parameters:
model (Model, ModelHash) – Model object or ModelHash
destination_path (Path) – Destination path
force (bool) – Force overwrite of files (default False)
- abstractmethod retrieve_file(model, filename, destination_path, force=False)[source]#
Retrieve one file related to a model run
- Parameters:
model (Model, ModelHash) – Model object or ModelHash
filename (str) – Name of file
destination_path (Path) – Destination path
force (bool) – Force overwrite of file (default False)
- abstractmethod retrieve_model(model)[source]#
Read a model from the database
- Parameters:
model_name (str) – Name of the model
- Returns:
Model – Retrieved model object
- abstractmethod retrieve_model_entry(model)[source]#
Read model entry from the database
- Parameters:
model_name (str) – Name of the model
- Returns:
ModelEntry – Retrieved model entry object
- abstractmethod retrieve_modelfit_results(model)[source]#
Read modelfit results from the database
- Parameters:
model_name (str) – Name of the model
- Returns:
Results – Retrieved model results object
- abstractmethod snapshot(model)[source]#
Creates a readable snapshot context for a given model.
- Parameters:
model_name (str) – Name of the Pharmpy model object
- abstractmethod store_local_file(model, path, new_filename=None)[source]#
Store a file from the local machine
- Parameters:
model (Model) – Pharmpy model object
path (Path) – Path to file
new_filename (str|None) – Filename to give to the file. Optional, defaults to original filename given by path.
- abstractmethod store_metadata(model, metadata)[source]#
Store metadata
- Parameters:
model (Model) – Pharmpy model object
metadata (Dict) – A dictionary with metadata
- abstractmethod store_model(model)[source]#
Store a model object
- Parameters:
model (Model) – Pharmpy model object
- abstractmethod store_model_entry(model_entry)[source]#
Store model entry of the model entry bound to this transaction
- Parameters:
model_entry (ModelEntry) – Pharmpy ModelEntry object