Skip to content

Commit

Permalink
release notes and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gt2345 committed Sep 17, 2024
1 parent b559467 commit f4ceffd
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 14 deletions.
Binary file modified docs/assets/images/webhook_modal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 51 additions & 5 deletions docs/integrations/notification/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ Below is an example of handling a signed payload in Python.
signed payload. For example "{"key_one": "value_one"}" will fail authentication, while
"{"key_one":"value_one"}" will yield the correct signed payload value.

.. _supported-webhook-triggers:

Supported Triggers
==================

``Completed`` or ``Error`` will be triggered when an experiment in scope is completed or errored.

``Tasklog`` will be triggered when a task matching regex is detected.

``Custom`` will only be triggered from experiment code.

.. code::
# Here is an example code to trigger a custom trigger.
# config.yaml
integrations:
webhooks:
webhook_name:
- <webhook_name>
# code.py
with det.core.init() as core_context:
core_context.alert(title="some title", description="some description", level="info")
*******************
Creating Webhooks
*******************
Expand All @@ -140,19 +165,33 @@ To create a webhook:
If you do not have sufficient permissions to view and create webhooks, consult with a systems
admin.

- Workspace: You can only select from workspaces you have the permission to create webhook in.
- Name: Identifier to reference webhook in experiment configuration.
- URL: Supply the webhook URL.
- Type: Select a type, either ``Default`` or ``Slack``. The ``Slack`` type can automatically format
message content for better readability on Slack.
- Trigger: Select the experiment state change you want to monitor, either ``Completed``, ``Error``,
or ``Tasklog``.
- Trigger: Select the event you want to monitor, see :ref:`supported-webhook-triggers`.
- Trigger by: Select whether you want to monitor all experiments within the workspace. ``Custom``
trigger can only be triggered by specific experiments.

.. code::
# Here is an example experiment config associated with specific webhooks
integrations:
webhooks:
webhook_name:
- <webhook_name>
- Regex: If the webhook is configured to trigger on Tasklog, define a regex using `Golang Regex
Syntax <https://pkg.go.dev/regexp/syntax>`_.

.. image:: /assets/images/webhook_modal.png
:width: 100%
:alt: Webhook user interface showing the fields you will interact with.

Once created, your webhook will begin executing for the selected events.
Once created, your webhook will begin executing for the selected events for experiments within
scope.

******************
Testing Webhooks
Expand Down Expand Up @@ -189,10 +228,17 @@ payload as stated below:
To delete a webhook, select the more-options menu to the right of the webhook record to expand
available actions.

******************
Editing Webhooks
******************

To edit a webhook, select the more-options menu to the right of the webhook record to expand
available actions.

.. note::

Determined does not support editing webhooks. Instead, you should delete and recreate the
webhook.
Determined only support editing the URL of webhooks. To edit other attributes, you should delete
and recreate the webhook.

.. toctree::
:caption: Notification
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes/workload-alerting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:orphan:

**New Features**

- Webhooks: Add support for monitoring experiment by workspaces, editing webhook URL and triggering webhook from code. For more details, refer to :ref:`supported-webhook-triggers`.

5 changes: 3 additions & 2 deletions master/internal/webhooks/postgres_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func getWebhookByName(ctx context.Context, webhookName string, workspaceID int)
Model(&webhook).
Relation("Triggers").
Where("name = ?", webhookName).
Where("workspace_id = ?", workspaceID).
Where("workspace_id = ? OR workspace_id IS NULL", workspaceID).
Scan(ctx)
if err != nil {
if err == sql.ErrNoRows {
Expand Down Expand Up @@ -780,6 +780,7 @@ func generateSlackPayload(
} else {
eURL = fmt.Sprintf("%v (#%v)", activeConfig.Name(), e.ID)
}
c = "#009bde"
mStatus = string(e.State)
}

Expand Down Expand Up @@ -863,7 +864,7 @@ func generateSlackPayload(
}
messageBlock = SlackBlock{
Text: SlackField{
Text: "Event Data",
Text: status,
Type: "plain_text",
},
Type: "section",
Expand Down
14 changes: 8 additions & 6 deletions webui/react/src/components/WebhookCreateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Select, { Option } from 'hew/Select';
import { useToast } from 'hew/Toast';
import React, { useCallback, useEffect, useId, useMemo, useState } from 'react';

import Link from 'components/Link';
import useFeature from 'hooks/useFeature';
import usePermissions from 'hooks/usePermissions';
import { paths } from 'routes/utils';
Expand All @@ -15,6 +16,7 @@ import { RunState, Workspace } from 'types';
import handleError, { DetError, ErrorLevel, ErrorType } from 'utils/error';
import { useObservable } from 'utils/observable';
import { routeToReactUrl } from 'utils/routes';

interface Props {
onSuccess?: () => void;
}
Expand Down Expand Up @@ -68,7 +70,7 @@ const triggerOptions = [
];
const modeOptions = [
{
label: 'All experiments in Workspace',
label: 'All experiments',
value: V1WebhookMode.WORKSPACE,
},
{
Expand Down Expand Up @@ -188,11 +190,8 @@ const WebhookCreateModalComponent: React.FC<Props> = ({ onSuccess }: Props) => {
onFieldsChange={onChange}>
{f_webhook && (
<>
<Form.Item
label="Workspace"
name="workspaceId"
rules={[{ message: 'Workspace is required', required: true }]}>
<Select allowClear placeholder="Workspace (required)">
<Form.Item label="Workspace" name="workspaceId">
<Select allowClear placeholder="Workspace">
{permWorkspace.map((workspace: Workspace) => (
<Option key={workspace.id} value={workspace.id}>
{workspace.name}
Expand Down Expand Up @@ -255,6 +254,9 @@ const WebhookCreateModalComponent: React.FC<Props> = ({ onSuccess }: Props) => {
/>
</Form.Item>
)}
<Link external path={paths.docs('/integrations/notification/_index.html')} popout>
Learn more
</Link>
</Form>
</Modal>
);
Expand Down
2 changes: 1 addition & 1 deletion webui/react/src/hooks/useFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const FEATURES: Record<ValidFeature, FeatureDescription> = {
friendlyName: 'Manage Templates',
},
webhook_improvement: {
defaultValue: false,
defaultValue: true,
description: 'Allow webhooks to monitor experiments by workspace',
friendlyName: 'Webhook Improvement',
},
Expand Down

0 comments on commit f4ceffd

Please sign in to comment.