AzureMLApplicationInsightsNotebookHandler Class

Represents an Application Insights-based notebook execution handler.

Construct PapermillExecutionHandler object.

Inheritance
azureml.contrib.notebook._notebook_handler.NotebookExecutionHandler
AzureMLApplicationInsightsNotebookHandler

Constructor

AzureMLApplicationInsightsNotebookHandler(appinsights_key, tag, payload=None, history=True, timeout=None, **kwargs)

Parameters

appinsights_key
str
Required

The Application Insights key.

tag
str
Required

The event name.

payload
dict
default value: None

The event payload.

history
bool
default value: True

Whether to enable metrics logs to run history. The default is True.

timeout
int
default value: None

Cell execution timeout in seconds.

kwargs
dict
Required

A dictionary of optional parameters. See supported_options.

Remarks


   # Import dependencies
   from azureml.core import Workspace, Experiment, RunConfiguration
   from azureml.contrib.notebook import NotebookRunConfig, AzureMLApplicationInsightsNotebookHandler

   # Create new experiment
   workspace = Workspace.from_config()
   experiment_name = "azureml_notebook_experiment"
   exp = Experiment(workspace, experiment_name)

   # Customize run configuration to execute in user managed environment
   run_config_user_managed = RunConfiguration()
   run_config_user_managed.environment.python.user_managed_dependencies = True

   # Instante AzureML Application Insights notebook handler
   handler = AzureMLApplicationInsightsNotebookHandler(appinsights_key=_appinsights_key,
                                                       tag="notebook-test",
                                                       payload={"experiment_name": experiment_name},
                                                       timeout=600)

   # Create notebook run configuration
   cfg = NotebookRunConfig(source_directory="./notebooks",
                           notebook="notebook-sample.ipynb",
                           handler=handler,
                           parameters={"arg2": "Universe"},
                           run_config=run_config_user_managed)

   # Submit experiment and wait for completion
   run = exp.submit(cfg)
   run.wait_for_completion(show_output=True)

This handler logs notebook execution status as an event named as tag to ApplicationInsights. CustomDimensions payload contains:

  • notebook metadata from papermill execution

  • user specified payload

  • status - one of failed, completed or timeout

In case of a failure, CustomDimensions is extended with the following properties:

  • cell_index - execution count of a failed cell

  • source - source code of the cell

  • error_type - exception type

  • error_message - exception message

  • traceback - stack trace

Attributes

supported_options

supported_options = ['progress_bar', 'log_output', 'kernel_name', 'cwd']