Пример #1
0
def test_notification():
    phases = [
        _execution.WorkflowExecutionPhase.FAILED,
        _execution.WorkflowExecutionPhase.SUCCEEDED,
    ]
    recipients = ["a", "b", "c"]

    obj = _common.Notification(phases,
                               email=_common.EmailNotification(recipients))
    assert obj.phases == phases
    assert obj.email.recipients_email == recipients
    obj2 = _common.Notification.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.phases == phases
    assert obj2.email.recipients_email == recipients

    obj = _common.Notification(
        phases, pager_duty=_common.PagerDutyNotification(recipients))
    assert obj.phases == phases
    assert obj.pager_duty.recipients_email == recipients
    obj2 = _common.Notification.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.phases == phases
    assert obj2.pager_duty.recipients_email == recipients

    obj = _common.Notification(phases,
                               slack=_common.SlackNotification(recipients))
    assert obj.phases == phases
    assert obj.slack.recipients_email == recipients
    obj2 = _common.Notification.from_flyte_idl(obj.to_flyte_idl())
    assert obj == obj2
    assert obj2.phases == phases
    assert obj2.slack.recipients_email == recipients
Пример #2
0
 def __init__(self, phases: List[int], recipients_email: List[str]):
     """
     :param list[int] phases: A required list of phases for which to fire the event.  Events can only be fired for
         terminal phases. Phases should be as defined in: :py:class:`flytekit.models.core.execution.WorkflowExecutionPhase`
     :param list[str] recipients_email: A required non-empty list of recipients for the notification.
     """
     super(Email, self).__init__(phases, email=_common_model.EmailNotification(recipients_email))
Пример #3
0
def test_execution_notification_soft_overrides(mock_client_factory):
    mock_client = MagicMock()
    mock_client.create_execution = MagicMock(
        return_value=identifier.WorkflowExecutionIdentifier('xp', 'xd', 'xn'))
    mock_client_factory.return_value = mock_client

    m = MagicMock()
    type(m).id = PropertyMock(return_value=identifier.Identifier(
        identifier.ResourceType.LAUNCH_PLAN, "project", "domain", "name",
        "version"))

    notification = _common_models.Notification(
        [0, 1, 2], email=_common_models.EmailNotification(["*****@*****.**"]))

    engine.FlyteLaunchPlan(m).execute('xp',
                                      'xd',
                                      'xn',
                                      literals.LiteralMap({}),
                                      notification_overrides=[notification])

    mock_client.create_execution.assert_called_once_with(
        'xp', 'xd', 'xn',
        _execution_models.ExecutionSpec(
            identifier.Identifier(identifier.ResourceType.LAUNCH_PLAN,
                                  "project", "domain", "name", "version"),
            literals.LiteralMap({}),
            _execution_models.ExecutionMetadata(
                _execution_models.ExecutionMetadata.ExecutionMode.MANUAL,
                'sdk', 0),
            notifications=_execution_models.NotificationList([notification]),
        ))
Пример #4
0
def test_email_notification():
    email_notif = notification.Email(phases=[_workflow_execution_succeeded],
                                     recipients_email=["*****@*****.**"])
    assert email_notif.to_flyte_idl() == _common_pb2.Notification(
        phases=[_workflow_execution_succeeded],
        email=_common_model.EmailNotification(["*****@*****.**"
                                               ]).to_flyte_idl(),
        pager_duty=None,
        slack=None,
    )
Пример #5
0
def test_notification_email():
    obj = _common.EmailNotification(["a", "b", "c"])
    assert obj.recipients_email == ["a", "b", "c"]
    obj2 = _common.EmailNotification.from_flyte_idl(obj.to_flyte_idl())
    assert obj2 == obj
Пример #6
0
def test_notification_email():
    obj = _common.EmailNotification(['a', 'b', 'c'])
    assert obj.recipients_email == ['a', 'b', 'c']
    obj2 = _common.EmailNotification.from_flyte_idl(obj.to_flyte_idl())
    assert obj2 == obj