hiv_workflow.lib.utils.builders.general module

exception hiv_workflow.lib.utils.builders.general.InvalidFunctionArgumentError

Bases: BaseException

hiv_workflow.lib.utils.builders.general.get_available_parameters(parameter_setting_functions: List[Callable], expected_first_argument: str) → Dict[Callable, List]

Detects and returns the available custom parameters provided/consumed by a set of functions. The read/detection part of the custom parameter API.

Parameters
  • parameter_setting_functions – a list of function references that provide/consume custom model parameters

  • expected_first_argument – the first argument of all provided functions. This will be the object that custom parameters will eventually be set on (not in get_available_parameters). get_available_parameters needs this to know what is NOT a custom parameter in the signature of the provided functions.

Returns

A dict, keyed by function references, with values being the list of arguments/custom parameters that the function accepts (e.g. keyword arguments that define available model parameters consumed by the function).

hiv_workflow.lib.utils.builders.general.set_parameters(on: Any, parameters_to_set: dict, setting_functions: List[Callable], function_arguments: Dict[Callable, List])None

Consumes user-exposed parameters and sets their values on the given object. This function is the write/execution component of the custom parameter API.

Parameters
  • on – object to set parameter values on (type depends on context)

  • parameters_to_set – a dict of key/value user-exposed model parameters that need to be set. Not all will necessarilly be set during this invocation of set_parameters depending on the behavior of the model input building function(s) calling this method.

  • setting_functions – a list of function references that consume custom model parameters. All will be called.

  • function_arguments – This is a dict, keyed by function references, with values being the list of arguments/custom parameters that the function accepts (e.g. keyword arguments that define available model parameters consumed by the function).

Returns

None