Hi, community, does anyone is familiar with notifi...
# ask-the-community
l
Hi, community, does anyone is familiar with notification in flyte? I need my notfications be non-empty so that I can test my sendGrid emailer in flyte, thank you very much.
Copy code
{
  "json": {
    "exec_id": "f43c091b4c09c415c911",
    "src": "execution_manager.go:1510"
  },
  "level": "info",
  "msg": "@@@ publishing notifications for execution [project:\"flytesnacks\" domain:\"development\" name:\"f43c091b4c09c415c911\" ] in state [SUCCEEDED] for notifications [[]]",
  "ts": "2023-07-25T03:34:13+08:00"
}
This is my log in flyteadmin I use the below code and run
Copy code
pyflyte run --copy-all --remote launch-plan.py int_doubler_wf --a 8
Copy code
from datetime import timedelta
from flytekit import Email, FixedRate, LaunchPlan, PagerDuty, Slack, WorkflowExecutionPhase, task, workflow


@task
def double_int_and_print(a: int) -> str:
    return str(a * 2)


@workflow
def int_doubler_wf(a: int) -> str:
    doubled = double_int_and_print(a=a)
    return doubled

int_doubler_wf_lp = LaunchPlan.get_or_create(
    name="int_doubler_wf",
    workflow=int_doubler_wf,
    default_inputs={"a": 4},
    notifications=[
        Email(
            phases=[
                    WorkflowExecutionPhase.FAILED,
                    WorkflowExecutionPhase.ABORTED,
                    WorkflowExecutionPhase.TIMED_OUT,
                    WorkflowExecutionPhase.SUCCEEDED,],
            recipients_email=["<mailto:eric901201@gmail.com|eric901201@gmail.com>"],
        )
    ],
)
Thank you very much
j
What exactly is empty? Notifications only trigger on launch plan executions not workflow executions.
l
Copy code
```python
# remote_register.py
from flytekit.remote import FlyteRemote
from flytekit.configuration import Config, ImageConfig
from workflows.example import wf
from flytekit import ImageSpec
from flytekit import workflow, LaunchPlan, CronSchedule
from flytekit import Email,WorkflowExecutionPhase

remote = FlyteRemote(config=Config.auto(), \
                      default_project="flytesnacks", default_domain="development")

launch_plan = LaunchPlan.get_or_create(
    wf, 
    name="<http://workflows.example.wf|workflows.example.wf>", 
    default_inputs={"name": "Elmo"},
    notifications=[
        Email(
            phases=[
                    WorkflowExecutionPhase.FAILED,
                    WorkflowExecutionPhase.ABORTED,
                    WorkflowExecutionPhase.TIMED_OUT,
                    WorkflowExecutionPhase.SUCCEEDED,],
            recipients_email=["<mailto:eric901201@gmail.com|eric901201@gmail.com>"],
    )],
)

execution = remote.execute(launch_plan, inputs={"name": "Kermit"}, image_config=ImageConfig.auto(img_name="futureoutlier/flyte-practice:latest"))
```
@Jan Fiedler I've tried this but the notifications is still empty too.
j
I dont have a setup atm to reproduce this - sorry 😕
l
Thanks for your attention and the heart for helping