다음 예시는 이메일 알림 태스크(notify_email_task)를 정의하고 파이프라인의 종료 핸들러(dsl.ExitHandler)에 추가하여 이메일 알림을 구성하는 방법을 보여줍니다. 이 알림 태스크은 파이프라인이 종료될 때 이메일 알림 구성요소의 VertexNotificationEmailOp 연산자를 호출합니다.
fromkfpimportdslfromkfpimportcompilerfromgoogle_cloud_pipeline_components.v1.vertex_notification_emailimportVertexNotificationEmailOp@dsl.pipeline(name='PIPELINE_NAME',pipeline_root=PIPELINE_ROOT_PATH,)defTASK_NAME():notify_email_task=VertexNotificationEmailOp(recipients=RECIPIENTS_LIST)withdsl.ExitHandler(notify_email_task):# Add your pipeline tasks here.compiler.Compiler().compile(pipeline_func=notification_email_pipeline,package_path='notification_email_pipeline.yaml')
다음을 바꿉니다.
PIPELINE_NAME: 파이프라인의 이름
PIPELINE_ROOT_PATH: 파이프라인 서비스 계정이 액세스할 수 있는 Cloud Storage URI를 지정. 파이프라인 실행의 아티팩트는 파이프라인 루트 내에 저장됩니다.
파이프라인 루트는 파이프라인 함수에서 @kfp.dsl.pipeline 주석의 인수로 설정하거나 create_run_from_job_spec을 호출하여 파이프라인 실행을 만들 때 설정할 수 있습니다.
TASK_NAME: 이메일 알림을 구성하려는 파이프라인 태스크의 이름
RECIPIENTS_LIST: 알림 이메일을 보낼 이메일 주소(최대 3개)의 쉼표로 구분된 목록
dsl.ExitHandler 종료 핸들러 함수의 본문에 파이프라인 태스크를 추가합니다. 종료 핸들러 함수의 태스크를 이러한 방식으로 래핑하면 알림 이메일 구성요소가 파이프라인이 종료될 때 이러한 태스크의 상태를 보고하도록 지정합니다. 예를 들어 종료 핸들러의 콘텐츠 내의 태스크가 실패하면 알림은 상태를 실패로 보고합니다.
알림 이메일 예시
파이프라인에서 알림 보내기의 코드 샘플을 사용하여 파이프라인의 이메일 알림을 구성하면 파이프라인이 종료될 때 Vertex AI에서 다음과 유사한 이메일 알림을 보냅니다.
제목: Vertex 파이프라인 작업 'PIPELINE_NAME' 'TASK_NAME' 태스크
보낸사람: Google 알림 <notify-noreply@google.com>
Vertex AI 고객님, 안녕하세요.
Vertex 파이프라인 작업 'PIPELINE_NAME' 'TASK_NAME' 태스크 상태가 {status}로 종료되었습니다.
추가 세부정보:
- 프로젝트: {project}
- 파이프라인 이름:PIPELINE_NAME - 파이프라인 작업 ID:{pipeline_job_id} - 시작 시간: {start_time}
Cloud 콘솔에서 이 파이프라인 작업을 보려면 {console_link} 링크를 사용하세요.
감사합니다. Google Cloud AI팀
이 예시에서는 다음과 같이 정의됩니다.
{status}: 태스크의 최종 상태를 나타내며 SUCCEEDED, FAILED, CANCELLED 중 하나일 수 있음
{project}: 프로젝트 이름
{pipeline_job_id}: 고유한 파이프라인 작업 ID
{start_time}: 파이프라인의 시작 시간
{console_link}: Google Cloud 콘솔에서 파이프라인 작업에 대한 하이퍼링크
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Configure email notifications\n\nVertex AI Pipelines can notify you of the success or failure of a pipeline run. When the pipeline exits, Google Cloud sends a final status notification email to the email addresses that you specify.\n\nThis guide shows how to configure email notifications from a pipeline\nby using the [Email notification\ncomponent](/vertex-ai/docs/pipelines/email-notification-component)\nin the Google Cloud SDK.\n| **Note:** Google retains the email addresses that you send notifications to for up to 14 days for debugging purposes and 30 days for analytics purposes.\n\nBefore you begin\n----------------\n\nBefore you build a pipeline that sends notifications, use the following instructions to set\nup your Google Cloud project and development environment.\n\n1. To get your Google Cloud project ready to run ML pipelines, follow the\n instructions in the guide to [configuring your\n Google Cloud project](/vertex-ai/docs/pipelines/configure-project).\n\n2. Install v2 or later of the Kubeflow Pipelines SDK.\n\n pip install --upgrade \"kfp\u003e=2,\u003c3\"\n\n| **Note:** To upgrade to the latest version of the Kubeflow Pipelines SDK, run the following command: \n| `pip install kfp --upgrade` \n| If an updated version is available, running this command uninstalls KFP and installs the latest version.\\\\\n\n1. To use Vertex AI Python client in your pipelines, [install the\n Vertex AI client libraries v1.7 or later](https://github.com/googleapis/python-aiplatform).\n\n2. To use Vertex AI services in your pipelines, [install the\n Google Cloud Pipeline Components](https://github.com/kubeflow/pipelines/tree/master/components/google-cloud#installation).\n\nSend a notification from a pipeline\n-----------------------------------\n\nThe following example shows how to configure email notifications by defining an email notification task (`notify_email_task`) and adding it to the pipeline's exit handler (`dsl.ExitHandler`). This notification task invokes the `VertexNotificationEmailOp` operator in the email notification component when the pipeline exits. \n\n from kfp import dsl\n from kfp import compiler\n from google_cloud_pipeline_components.v1.vertex_notification_email import VertexNotificationEmailOp\n\n @dsl.pipeline(\n name='\u003cvar translate=\"no\"\u003ePIPELINE_NAME\u003c/var\u003e',\n pipeline_root=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePIPELINE_ROOT_PATH\u003c/span\u003e\u003c/var\u003e,\n )\n def \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nf\"\u003eTASK_NAME\u003c/span\u003e\u003c/var\u003e():\n notify_email_task = VertexNotificationEmailOp(recipients=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eRECIPIENTS_LIST\u003c/span\u003e\u003c/var\u003e)\n\n with dsl.ExitHandler(notify_email_task):\n # Add your pipeline tasks here.\n\n compiler.Compiler().compile(pipeline_func=notification_email_pipeline,\n package_path='notification_email_pipeline.yaml')\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePIPELINE_NAME\u003c/var\u003e: The name of the pipeline.\n\n- \u003cvar translate=\"no\"\u003ePIPELINE_ROOT_PATH\u003c/var\u003e: Specify a Cloud Storage URI that your\n [pipelines service account can access](/vertex-ai/docs/pipelines/configure-project#service-account). The artifacts of your\n pipeline runs are stored within the pipeline root.\n\n The pipeline root can be set as an argument of the `@kfp.dsl.pipeline`\n annotation on the pipeline function, or it can be set when you call\n `create_run_from_job_spec` to create a pipeline run.\n- \u003cvar translate=\"no\"\u003eTASK_NAME\u003c/var\u003e: The name of the pipeline task for which you're configuring email notifications.\n\n- \u003cvar translate=\"no\"\u003eRECIPIENTS_LIST\u003c/var\u003e: A comma-separated list of up to three email addresses to\n send the notification email to.\n\nAdd your pipeline tasks in the body of the `dsl.ExitHandler` exit handler function. By wrapping the tasks in the exit handler function in this way, you specify that the notification email component should report the status of these tasks when the pipeline exits. For example, if a task within the exit handler's contents fails, then the notification reports the status as failed.\n\nExample of a notification email\n-------------------------------\n\nIf you configure email notifications for a pipeline using the code sample in [Send a notification from a pipeline](#sending-notification-from-pipeline), Vertex AI sends an email notification similar to the following when the pipeline exits:\n\u003e Subject: Vertex Pipelines job \"\u003cvar translate=\"no\"\u003ePIPELINE_NAME\u003c/var\u003e\" task \"\u003cvar translate=\"no\"\u003eTASK_NAME\u003c/var\u003e\" \n\u003e From: Google Notifications \\\u003cnotify-noreply@google.com\\\u003e \n\u003e\n\u003e Hello Vertex AI Customer, \n\u003e\n\u003e Vertex AI Pipelines job \"\u003cvar translate=\"no\"\u003ePIPELINE_NAME\u003c/var\u003e\" task \"\u003cvar translate=\"no\"\u003eTASK_NAME\u003c/var\u003e\" ended with the following state: {status}. \n\u003e\n\u003e Additional details: \n\u003e - Project: {project} \n\u003e - Pipeline name: \u003cvar translate=\"no\"\u003ePIPELINE_NAME\u003c/var\u003e \n\u003e - Pipeline job ID: {pipeline_job_id} \n\u003e - Start time: {start_time} \n\u003e\n\u003e To view this pipeline job in Cloud Console, use the following link: {console_link} \n\u003e\n\u003e Sincerely, \n\u003e The Google Cloud AI Team \n\nIn this example:\n\n- `{status}` represents the final state of the task, which can be `SUCCEEDED`, `FAILED`, or `CANCELLED`.\n- `{project}` is the project name.\n- `{pipeline_job_id}` is the unique pipeline job ID.\n- `{start_time}` represents the start time for the pipeline.\n- `{console_link}` is a hyperlink to the pipeline job in the Google Cloud console."]]