LocalDirectoryDatabase#

class pharmpy.workflows.LocalDirectoryDatabase(path='.', file_extension='.mod')[source]#

Bases: NonTransactionalModelDatabase

ModelDatabase implementation for single local directory

All files will be stored in the same directory. It is assumed that all files connected to a model are named modelname + extension. This means that care must be taken to keep filenames unique. Clashing filenames will be overwritten. It is recommended to use the LocalModelDirectoryDatabase instead.

Parameters:
  • path (str or Path) – Path to the database directory. Will be created if it does not exist.

  • file_extension (str) – File extension to use for model files.

Methods Summary

retrieve_file(name, filename)

Retrieve one file related to a model

retrieve_local_files(name, destination_path)

Retrieve all files related to a model

retrieve_model(name)

Read a model from the database

retrieve_model_entry(name)

Read model entry from the database

retrieve_modelfit_results(name)

Read modelfit results from the database

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

Methods Documentation

retrieve_file(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

retrieve_local_files(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

retrieve_model(name)[source]#

Read a model from the database

Parameters:

model_name (str) – Name of the model

Returns:

Model – Retrieved model object

retrieve_model_entry(name)[source]#

Read model entry from the database

Parameters:

model_name (str) – Name of the model

Returns:

ModelEntry – Retrieved model entry object

retrieve_modelfit_results(name)[source]#

Read modelfit results from the database

Parameters:

model_name (str) – Name of the model

Returns:

Results – Retrieved model results object

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.

store_metadata(model, metadata)[source]#

Store metadata

Parameters:
  • model (Model) – Pharmpy model object

  • metadata (Dict) – A dictionary with metadata

store_model(model)[source]#

Store a model object

Parameters:

model (Model) – Pharmpy model object

store_model_entry(model_entry)[source]#

Store model entry of the model entry bound to this transaction

Parameters:

model_entry (ModelEntry) – Pharmpy ModelEntry object

store_modelfit_results(model)[source]#

Store modelfit results

Parameters:

model (Model) – Pharmpy model object