AzureMLApplicationInsightsNotebookHandler class

Definition

Papermill-based notebook execution handler.

AzureMLApplicationInsightsNotebookHandler(appinsights_key, tag, payload=None, history=True, timeout=None, **kwargs)
Inheritance
builtins.object
azureml.contrib.notebook._notebook_handler.NotebookExecutionHandler
AzureMLApplicationInsightsNotebookHandler

Parameters

appinsights_key
str

ApplicationInsights key

tag
str

Event name

payload
dict

Event payload

history
int

Enable metrics logs to run history. Enabled by default

timeout

Cell execution timeout in seconds

kwargs

Dictionary of optional parameters. See :attr: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)

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 a case of a failure CustomDimensions 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']