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

retrieve_file(model, filename)

Retrieve one file related to a model

retrieve_local_files(model, destination_path)

Retrieve all files related to a model

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

abstract retrieve_file(model, filename)[source]#

Retrieve one file related to a model

Note that if the database is implemented in the local filesystem it is allowed to return a path directly to the file in the database.

Parameters:
  • model_name (str) – Name of the model

  • filename (str) – Name of file

Returns:

Path – Path to local file

abstract retrieve_local_files(model, destination_path)[source]#

Retrieve all files related to a model

Parameters:
  • model_name (str) – Name of the model

  • destination_path (Path) – Local destination path

abstract retrieve_model(model)[source]#

Read a model from the database

Parameters:

model_name (str) – Name of the model

Returns:

Model – Retrieved model object

abstract 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

abstract 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

abstract snapshot(model)[source]#

Creates a readable snapshot context for a given model.

Parameters:

model_name (str) – Name of the Pharmpy model object

abstract 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.

abstract store_metadata(model, metadata)[source]#

Store metadata

Parameters:
  • model (Model) – Pharmpy model object

  • metadata (Dict) – A dictionary with metadata

abstract store_model(model)[source]#

Store a model object

Parameters:

model (Model) – Pharmpy model object

abstract store_model_entry(model_entry)[source]#

Store model entry of the model entry bound to this transaction

Parameters:

model_entry (ModelEntry) – Pharmpy ModelEntry object

abstract store_modelfit_results(model)[source]#

Store modelfit results

Parameters:

model (Model) – Pharmpy model object

abstract transaction(obj)[source]#

Creates a writable transaction context for a given model.

Parameters:

obj (Model | ModelEntry | ModelHash) – Pharmpy model, ModelEntry or ModelHash object