pytorch_pfn_extras.training.extensions.SlackWebhook#

class pytorch_pfn_extras.training.extensions.SlackWebhook(url, msg=None, *, start_msg='{default}', end_msg='{default}', error_msg='{default}', context=None)#

Bases: _SlackBase

An extension to communicate with Slack using Incoming Webhook.

Example

>>> ppe.training.extensions.SlackWebhook(
...     url="https://hooks.slack.com/services/Txxxxx.....",
...     msg="Epoch #{manager.epoch}: loss = {val/loss}",
...     end_msg="{default} \n <@username> Check out the result!",
... )

This extension posts a message when:

  • start_msg: The training has started

  • msg: The extension is triggered, usually at the end of each epoch

  • end_msg: The training has finished

  • error_msg: An exception has raised during the training

These messages can be specified as a format string, a callable that returns a string, or None to disable posting on that event.

When using a format string, the following variables are available for use:

  • manager: an ExtensionsManager object

  • default: the default message string

  • context: an arbitrary object passed to this extension

  • error: an Exception object (for error_msg only)

  • All reported values (manager.observations)

When using a callable, it should take (ExtensionsManager, context) or (ExtensionsManager, Exception, context) (for error_msg) and return a string.

Parameters:
  • url (str) – Incoming webhook URL to send messages.

  • msg (str, callable, or None) – A message to be sent when triggered. It can be a string to be formatted using .format or a callable that returns a string.

  • start_msg (str, callable, or None) – A message to be sent at the beginning of the experiment.

  • end_msg (str, callable, or None) – A message to be sent at the completion of the experiment.

  • error_msg (str, callable, or None) – A message to be sent when an exception is raised during the experiment.

  • context (object) – Any arbitrary user object you will need when generating a message.

Methods

__init__(url[, msg, start_msg, end_msg, ...])

default_end_msg(context)

default_error_msg(exc, context)

default_msg(context)

default_start_msg(context)

finalize(manager)

Finalizes the extension.

initialize(manager)

Initializes up the manager state.

load_state_dict(to_load)

on_error(manager, exc, tb)

Handles the error raised during training before finalization.

state_dict()

Serializes the extension state.

Attributes

default_name

Default name of the extension.

is_async

name

needs_model_state

priority

trigger

__init__(url, msg=None, *, start_msg='{default}', end_msg='{default}', error_msg='{default}', context=None)#
Parameters:
Return type:

None