Runner

class health_ml.Runner(project_root)[source]

Bases: object

This class contains the high-level logic to start a training run: choose a model configuration by name, submit to AzureML if needed, or otherwise start the actual training and test loop.

Parameters

project_root (Path) – The root folder that contains all of the source code that should be executed.

Methods Summary

additional_environment_variables()

rtype

Dict[str, str]

additional_run_tags(script_params)

Gets the set of tags that will be added to the AzureML run as metadata.

parse_and_load_model()

Parses the command line arguments, and creates configuration objects for the model itself, and for the Azure-related parameters.

run()

The main entry point for training and testing models from the commandline.

run_in_situ(azure_run_info)

Actually run the AzureML job; this method will typically run on an Azure VM.

submit_to_azureml_if_needed()

Submit a job to AzureML, returning the resulting Run object, or exiting if we were asked to wait for completion and the Run did not succeed.

validate()

Runs sanity checks on the whole experiment.

Methods Documentation

additional_environment_variables()[source]
Return type

Dict[str, str]

additional_run_tags(script_params)[source]

Gets the set of tags that will be added to the AzureML run as metadata.

Parameters

script_params (List[str]) – The commandline arguments used to invoke the present script.

Return type

Dict[str, str]

parse_and_load_model()[source]

Parses the command line arguments, and creates configuration objects for the model itself, and for the Azure-related parameters. Sets self.experiment_config to its proper values. Returns the parser output from parsing the model commandline arguments.

Return type

ParserResult

Returns

ParserResult object containing args, overrides and settings

run()[source]

The main entry point for training and testing models from the commandline. This chooses a model to train via a commandline argument, runs training or testing, and writes all required info to disk and logs.

Return type

Tuple[LightningContainer, AzureRunInfo]

Returns

a tuple of the LightningContainer object and an AzureRunInfo containing all information about the present run (whether running in AzureML or not)

run_in_situ(azure_run_info)[source]

Actually run the AzureML job; this method will typically run on an Azure VM.

Parameters

azure_run_info (AzureRunInfo) – Contains all information about the present run in AzureML, in particular where the

datasets are mounted.

Return type

None

submit_to_azureml_if_needed()[source]

Submit a job to AzureML, returning the resulting Run object, or exiting if we were asked to wait for completion and the Run did not succeed.

Return type

AzureRunInfo

Returns

an AzureRunInfo object containing all of the details of the present run. If AzureML is not specified, the attribute ‘run’ will None, but the object still contains helpful information about datasets etc

validate()[source]

Runs sanity checks on the whole experiment.

Return type

None

additional_run_tags(script_params)[source]

Gets the set of tags that will be added to the AzureML run as metadata.

Parameters

script_params (List[str]) – The commandline arguments used to invoke the present script.

Return type

Dict[str, str]

parse_and_load_model()[source]

Parses the command line arguments, and creates configuration objects for the model itself, and for the Azure-related parameters. Sets self.experiment_config to its proper values. Returns the parser output from parsing the model commandline arguments.

Return type

ParserResult

Returns

ParserResult object containing args, overrides and settings

run()[source]

The main entry point for training and testing models from the commandline. This chooses a model to train via a commandline argument, runs training or testing, and writes all required info to disk and logs.

Return type

Tuple[LightningContainer, AzureRunInfo]

Returns

a tuple of the LightningContainer object and an AzureRunInfo containing all information about the present run (whether running in AzureML or not)

run_in_situ(azure_run_info)[source]

Actually run the AzureML job; this method will typically run on an Azure VM.

Parameters

azure_run_info (AzureRunInfo) – Contains all information about the present run in AzureML, in particular where the

datasets are mounted.

Return type

None

submit_to_azureml_if_needed()[source]

Submit a job to AzureML, returning the resulting Run object, or exiting if we were asked to wait for completion and the Run did not succeed.

Return type

AzureRunInfo

Returns

an AzureRunInfo object containing all of the details of the present run. If AzureML is not specified, the attribute ‘run’ will None, but the object still contains helpful information about datasets etc

validate()[source]

Runs sanity checks on the whole experiment.

Return type

None