Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Vertex AI Pipelines peut vous informer de la réussite ou de l'échec d'une exécution de pipeline. Lorsque le pipeline se ferme, Google Cloud envoie un e-mail de notification d'état final aux adresses e-mail que vous spécifiez.
Ce guide explique comment configurer les notifications par e-mail à partir d'un pipeline à l'aide du composant de notification par e-mail du SDK Google Cloud Pipeline Components.
Avant de commencer
Avant de créer un pipeline qui envoie des notifications, suivez les instructions ci-dessous pour configurer votre projet Google Cloud et votre environnement de développement.
Installez la version 1.8 ou une version ultérieure du SDK Kubeflow Pipelines.
(Facultatif) Avant l'installation, exécutez la commande suivante pour voir quelle version du SDK Kubeflow Pipelines est actuellement installée :
L'exemple suivant montre comment configurer les notifications par e-mail en définissant une tâche de notification par e-mail (notify_email_task) et en l'ajoutant au gestionnaire de sortie du pipeline (dsl.ExitHandler). Cette tâche de notification appelle l'opérateur VertexNotificationEmailOp dans le composant de notification par e-mail lorsque le pipeline se ferme.
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')
Remplacez les éléments suivants :
PIPELINE_NAME : nom du pipeline.
PIPELINE_ROOT_PATH : spécifiez un URI Cloud Storage auquel votre compte de service de pipelines peut accéder. Les artefacts des exécutions de votre pipeline sont stockés dans la racine du pipeline.
La racine du pipeline peut être définie en tant qu'argument de l'annotation @kfp.dsl.pipeline sur la fonction du pipeline, ou elle peut être définie lorsque vous appelez create_run_from_job_spec pour créer une exécution de pipeline.
TASK_NAME : nom de la tâche de pipeline pour laquelle vous configurez des notifications par e-mail.
RECIPIENTS_LIST : liste pouvant contenir jusqu'à trois adresses e-mail séparées par une virgule pouvant recevoir les notifications.
Ajoutez vos tâches de pipeline dans le corps de la fonction du gestionnaire de sortie dsl.ExitHandler. En encapsulant les tâches de la fonction du gestionnaire de sortie de cette manière, vous indiquez que le composant d'e-mail de notification doit signaler l'état de ces tâches lorsque le pipeline se ferme. Par exemple, si une tâche du contenu du gestionnaire de sortie échoue, la notification indiquera l'état "Échec".
Exemple d'e-mail de notification
Si vous configurez les notifications par e-mail pour un pipeline à l'aide de l'exemple de code présenté à la section Envoyer une notification à partir d'un pipeline, Vertex AI envoie une notification par e-mail semblable à ce qui suit à la fermeture du pipeline :
Objet : Job Vertex Pipelines "PIPELINE_NAME" tâche "TASK_NAME"
De : Notifications Google <notify-noreply@google.com>
Cher client Vertex AI, bonjour,
Le job Vertex Pipelines "PIPELINE_NAME" tâche "TASK_NAME" s'est terminé avec l'état suivant : {status}.
Détails supplémentaires :
- Projet : {project}
- Nom du pipeline : PIPELINE_NAME
- Job ID du pipeline : {pipeline_job_id}
- Heure de début : {start_time}
Pour afficher ce job de pipeline dans la console Cloud, utilisez le lien suivant : {console_link}
Cordialement,
L'équipe Google Cloud AI
Dans cet exemple :
{status} représente l'état final de la tâche, qui peut être SUCCEEDED, FAILED ou CANCELLED.
{project} est le nom du projet.
{pipeline_job_id} est le job ID unique du pipeline.
{start_time} représente l'heure de début du pipeline.
{console_link} est un lien hypertexte vers le job de pipeline dans la console Google Cloud.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2024/11/21 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2024/11/21 (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."]]