Context#
- class pharmpy.workflows.Context(name, ref=None)[source]#
Bases:
ABC
Context for runs
A database of results, metadata and run files for one tool run
- Parameters:
name (str) – Name of the context
ref (str) – A reference (path) to the context
Attributes Summary
ModelDatabase to store results of models run in context
Methods Summary
abort_workflow
(message)Ask the dispatcher to abort the currently running workflow directly
call_workflow
(workflow, unique_name)Ask the dispatcher to call a subworkflow
create_rng
(index)Create a random number generator
create_subcontext
(name)Create a new subcontext of this context
exists
(name[, ref])finalize
()Called after a tool has finished its run in a context can be implemented to do cleanup of the context
get_model_context_path
(model)Get number of cores for execution (using available cores among allocation)
Get the parent context of this context
get_subcontext
(name)Get one of the subcontexts of this context
Get the top level context of this context
Check if the tool running in the context has completed
Check if the tool running in the context has started
Retrieve a list of all model names in the context
Retrieve a list of the names of all subcontexts in the context
log_error
(message[, model])Add an error message to the log
log_info
(message[, model])Add an info message to the log
log_message
(severity, message[, model])Add a message to the log
log_warning
(message[, model])Add a warning message to the log
retrieve_annotation
(name)Retrieve an annotation for a model
Retrieve the ModelEntry of the model marked as final
Retrieve the ModelEntry of the model marked as input
retrieve_key
(name)Retrive the key corresponding to a model name
retrieve_log
([level])Retrieve the entire log all - the entire log current - only the current Context level lower - current and sub levels
Read tool metadata
retrieve_model_entry
(name)Retrieve tool results
spawn_seed
(rng[, n])Spawn a new seed using a random number generator
store_annotation
(name, annotation)Store an annotation string (description) for a model
store_key
(name, key)Associate a key with a model name
store_message
(severity, ctxpath, date, message)store_metadata
(metadata)Store tool metadata
store_results
(res)Store tool results
Attributes Documentation
- broadcaster#
- context_path#
- dispatcher#
- model_database#
ModelDatabase to store results of models run in context
- name#
- ref#
- seed#
Methods Documentation
- abort_workflow(message)[source]#
Ask the dispatcher to abort the currently running workflow directly
- create_rng(index)[source]#
Create a random number generator
Creating the generator will be using the seed common option, the index and the context path to get a unique sequence.
- abstractmethod finalize()[source]#
Called after a tool has finished its run in a context can be implemented to do cleanup of the context
- get_ncores_for_execution()[source]#
Get number of cores for execution (using available cores among allocation)
- abstractmethod list_all_subcontexts()[source]#
Retrieve a list of the names of all subcontexts in the context
- log_info(message, model=None)[source]#
Add an info message to the log
Currently with echo to stdout. In the future this could be changed or be configurable.
- abstractmethod retrieve_key(name)[source]#
Retrive the key corresponding to a model name
This key can be used to lookup the model in the model database
- abstractmethod retrieve_log(level='all')[source]#
Retrieve the entire log all - the entire log current - only the current Context level lower - current and sub levels
- abstractmethod retrieve_results()[source]#
Retrieve tool results
- Returns:
Results – Tool results object
- spawn_seed(rng, n=128)[source]#
Spawn a new seed using a random number generator
- Parameters:
rng (Random number generator) – Random number generator
n (int) – Size of seed to generate in number of bits
- Returns:
int – New random seed
- abstractmethod store_annotation(name, annotation)[source]#
Store an annotation string (description) for a model