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
list_all_files
(name)Lists all file names related to a model run
retrieve_all_files
(name, destination_path[, ...])Retrieve all files related to a model run
retrieve_file
(name, filename, destination_path)Retrieve one file related to a model run
retrieve_model
(name)Read a model from the database
retrieve_model_entry
(name)Read model entry from the database
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
- list_all_files(name)[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
- retrieve_all_files(name, 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)
- retrieve_file(name, 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)
- 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