run_templated_modeller
Run a task from a templated yaml config file.
For Dev usage only. This is not intended to be used in production.
Usage:
python -m bitfount.scripts.run_templated_modeller `path-to-yaml-config` --pod_identifier='pod-id' --template_params='{"param_1": "value", "param2": ["v1", "v2"]}'
Module
Functions
dict_replace_value
def dict_replace_value( dictionary: dict[str, Any], old_value: str, new_value: Union[str, list[str], dict[str, Any]],) ‑> dict[str, typing.Any]:
Helper function to replace a value in a dictionary.
list_replace_value
def list_replace_value( lst: list[Any], old_value: str, new_value: Union[str, list[str], dict[str, Any]],) ‑> list[typing.Any]:
Helper function to replace a value in a list.
parse_defaults
def parse_defaults(defaults_str: Union[str, list]) ‑> Any:
Parse defaults from string or list input.
parse_template_params
def parse_template_params(params_str: Union[str, Dict]) ‑> Any:
Parse template parameters from string or dict input.
run
def run( path_to_config_yaml: Union[str, PathLike], defaults: Optional[Union[str, list]] = None, require_all_pods: bool = False, model_out: Path = PosixPath('output-model.pt'), pod_identifier: Optional[str] = None, template_params: Optional[Union[str, Dict[str, Any]]] = None,) ‑> None:
Runs a modeller from a config file.
Arguments
path_to_config_yaml
: Path to the config YAML file.defaults
: list of default values to use for templating the config.require_all_pods
: Whether to require all pods to accept the task before continuing.model_out
: Path to save the model to (if applicable).pod_identifier
: Optional pod identifier to use instead of the one in the config.template_params
: Optional dictionary mapping template parameter names to values.
setup_templated_modeller_from_config_file
def setup_templated_modeller_from_config_file( path_to_config_yaml: Union[str, PathLike], defaults: Optional[Union[str, list]] = None, pod_identifier: Optional[str] = None, template_params: Optional[Union[str, Dict[str, Any]]] = None,) ‑> tuple[bitfount.federated.modeller._Modeller, list[str], typing.Optional[str], bool, bool]:
Creates a modeller from a YAML config file.
Arguments
path_to_config_yaml
: the path to the config filedefaults
: list of default values to use for templating the configpod_identifier
: optional pod identifier to use instead of the one in the configtemplate_params
: dictionary of template parameter names to values
Returns A tuple of the created Modeller and the list of pod identifiers to run