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_name, filename)

Retrieve one file related to a model

retrieve_local_files(model_name, ...)

Retrieve all files related to a model

retrieve_model(model_name)

Read a model from the database

retrieve_model_entry(model_name)

Read model entry from the database

retrieve_modelfit_results(model_name)

Read modelfit results from the database

snapshot(model_name)

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(model_or_model_entry)

Creates a writable transaction context for a given model.

Methods Documentation

abstract retrieve_file(model_name, 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_name, 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_name)[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_name)[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_name)[source]#

Read modelfit results from the database

Parameters:

model_name (str) – Name of the model

Returns:

Results – Retrieved model results object

abstract snapshot(model_name)[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(model_or_model_entry)[source]#

Creates a writable transaction context for a given model.

Parameters:

model_or_model_entry (Model | ModelEntry) – Pharmpy model or ModelEntry object