> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

> Python 코드에서 트리거되는 알림을 Slack 또는 이메일로 보내기

# 알림 보내기

export const ColabLink = ({url}) => <a href={url} target="_blank" rel="noopener noreferrer" className="colab-link">
    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
      <path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01.21.03zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z" />
    </svg>
    Try in Colab
  </a>;

<ColabLink url="https://wandb.me/alerts-colab" />

Slack이나 이메일로 run이 크래시되거나 맞춤형 트리거로 알림을 만드세요. 예를 들어, 트레이닝 루프의 그라디언트가 폭발하기 시작하면(NaN을 보고) 알림을 만들 수 있습니다. 또는 ML 파이프라인의 단계가 완료되면 알림을 만들 수 있습니다. 알림은 run을 초기화하는 모든 프로젝트에 적용되며, 개인 및 팀 프로젝트를 모두 포함합니다.

그리고 Slack(또는 이메일)에서 W\&B 알림 메시지를 확인하세요:

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/_media/send_alerts_slack.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=3739fea03fd05adb2a76cbd8d20514b0" alt="Slack alert setup" width="567" height="331" data-path="products/wandb/_media/send_alerts_slack.png" />
</Frame>

<Note>
  W\&B 알림을 사용하려면 코드에 `run.alert()`를 추가해야 합니다. 코드를 수정하지 않으면 [Automations](/ko/products/wandb/automations)에서 W\&B의 이벤트(예: [artifact](/ko/products/wandb/artifacts) 아티팩트 버전이 생성되거나 [run metric](/ko/products/wandb/runs)이 임계값을 충족하거나 변경될 때)를 기반으로 Slack에 알림을 보내는 또 다른 방법을 제공합니다.

  예를 들어, 자동화는 새 버전이 생성될 때 Slack 채널에 알림을 보내거나, 아티팩트에 `production` 별칭이 추가될 때 자동화된 테스트 웹훅을 실행하거나, run의 `loss`가 허용 범위 내에 있을 때만 검증 작업을 시작할 수 있습니다.

  [Automations 개요](/ko/products/wandb/automations)를 읽거나 [자동화 만들기](/ko/products/wandb/automations/create-automations)를 확인하세요.
</Note>

<Note>
  다음 가이드는 Multi-tenant Cloud의 알림에만 적용됩니다.

  Private Cloud 또는 W\&B Dedicated Cloud에서 [W\&B Server](/ko/products/wandb/platform/hosting)를 사용하는 경우 Slack 알림을 설정하려면 [W\&B Server에서 Slack 알림 구성](/ko/products/wandb/platform/hosting/monitoring-usage/slack-alerts)을 참고하세요.
</Note>

<h2 id="automated-run-lifecycle-alerts">
  자동화된 run 라이프사이클 알림
</h2>

W\&B는 코드 변경 없이 run이 완료되거나 크래시될 때 알림을 보낼 수 있습니다. [User Settings](https://forge.coreweave.com/settings)에서 **Alerts** 섹션으로 스크롤한 다음 다음을 켜세요:

* **Run finished**: run이 성공적으로 완료되면 알림을 받습니다.
* **Run crashed**: [`run.finish()`](/ko/products/wandb/ref/python/experiments/run#finish)를 호출하지 않고 run이 종료될 때 알림을 받습니다.

이 토글은 사용자별입니다. **Run finished** 알림은 Jupyter 노트북의 run에는 적용되지 않습니다. 노트북에서는 완료 알림을 위해 `run.alert()`를 사용하세요.

알림은 이메일 또는 Slack으로 전달되며, 동일한 사용자 설정 패널에서 구성합니다. 전달 설정은 scriptable alerts와 공유되며, 다음 섹션에서 다루는 내용으로 metric 임계값이나 NaN loss와 같은 맞춤형 조건에서 알림을 트리거할 수 있게 합니다.

`run.alert()`로 scriptable alerts를 설정하려면 다음 단계를 따르세요. 이 단계는 다음 섹션에서 자세히 설명합니다:

1. W\&B [User Settings](https://forge.coreweave.com/settings)에서 Alerts를 켜세요.
2. 코드에 `run.alert()`를 추가하세요.
3. 구성을 테스트하세요.

<h3 id="1-turn-on-alerts-in-your-wb-user-settings">
  1) W\&B User Settings에서 알림 켜기
</h3>

[User Settings](https://forge.coreweave.com/settings)에서 다음을 수행하세요.

* **Alerts** 섹션까지 스크롤하세요.
* `run.alert()`에서 보내는 알림을 받으려면 **Scriptable run alerts**를 켜세요.
* **Connect Slack**을 사용하여 알림을 게시할 Slack 채널을 선택하세요. 알림을 비공개로 유지할 수 있는 **Slackbot** 채널을 권장합니다.
* **Email** 알림은 W\&B에 가입할 때 사용한 이메일 주소로 전송됩니다. 알림으로 받은편지함이 가득 차지 않도록 이메일 필터를 설정해 모든 알림이 한 폴더로 들어가게 하는 것이 좋습니다.

이 작업은 W\&B Alerts를 처음 설정할 때나 알림 수신 방식을 변경하려는 경우에만 하면 됩니다.

<Frame>
  <img src="https://mintcdn.com/coreweave-dbfa0e8d/3Dv_sw2eg8feUJlx/products/wandb/_media/demo_connect_slack.png?fit=max&auto=format&n=3Dv_sw2eg8feUJlx&q=85&s=447031fea4fc850c58c6910d1aa6059d" alt="W&B User Settings의 Alerts 설정" width="1420" height="900" data-path="products/wandb/_media/demo_connect_slack.png" />
</Frame>

<h3 id="2-add-runalert-to-your-code">
  2. 코드에 `run.alert()` 추가하기
</h3>

코드에 `run.alert()`를 추가하세요(노트북 또는 Python 스크립트에서). 트리거되기를 원하는 위치에

```python theme={"system"}
import wandb

with wandb.init() as run:
    run.alert(title="High Loss", text="Loss is increasing rapidly")
```

<h3 id="3-test-the-configuration">
  3. 설정 테스트
</h3>

Slack이나 이메일에서 알림 메시지를 확인하세요. 받지 못했다면 [User Settings](https://forge.coreweave.com/settings)에서 **Scriptable Alerts**에 대한 이메일이나 Slack 알림이 켜져 있는지 확인하세요.

<h2 id="example">
  예시
</h2>

이 단순한 알림은 정확도가 임계값 미만으로 떨어지면 경고를 보냅니다. 이 예제에서는 최소 5분 간격으로만 알림을 보냅니다.

```python theme={"system"}
import wandb
from wandb import AlertLevel

with wandb.init() as run:

    if acc < threshold:
        run.alert(
            title="Low accuracy",
            text=f"Accuracy {acc} is below the acceptable threshold {threshold}",
            level=AlertLevel.WARN,
            wait_duration=300,
        )
```

<h2 id="tag-or-mention-users">
  사용자 태그 또는 멘션
</h2>

@ 기호 뒤에 Slack 사용자 ID를 붙여 알림의 제목이나 텍스트에서 자신이나 동료를 태그하세요. Slack 사용자 ID는 Slack 프로필 페이지에서 찾을 수 있습니다.

```python theme={"system"}
run.alert(title="Loss is NaN", text=f"Hey <@U1234ABCD> loss has gone to NaN")
```

<h2 id="configure-team-alerts">
  팀 알림 설정
</h2>

팀 관리자는 팀 설정 페이지에서 팀에 대한 알림을 설정할 수 있습니다: `wandb.ai/teams/your-team`.

팀 알림은 팀의 모든 사람에게 적용됩니다. W\&B는 알림을 비공개로 유지하기 때문에 **Slackbot** 채널을 사용하는 것을 권장합니다.

<h2 id="change-slack-channel-to-send-alerts-to">
  alerts를 보낼 Slack channel 변경
</h2>

alerts를 보낼 channel을 변경하려면 **Disconnect Slack**을 클릭한 다음 다시 연결하세요. 다시 연결한 후 다른 Slack channel을 선택하세요.
