예제 #1
0
def test_fixed_rate():
    obj = _schedules.FixedRate(_datetime.timedelta(hours=10),
                               kickoff_time_input_arg="abc")
    assert obj.rate.unit == _schedules.FixedRate.FixedRateUnit.HOUR
    assert obj.rate.value == 10
    assert obj == _schedules.FixedRate.from_flyte_idl(obj.to_flyte_idl())

    obj = _schedules.FixedRate(_datetime.timedelta(hours=24),
                               kickoff_time_input_arg="abc")
    assert obj.rate.unit == _schedules.FixedRate.FixedRateUnit.DAY
    assert obj.rate.value == 1
    assert obj == _schedules.FixedRate.from_flyte_idl(obj.to_flyte_idl())

    obj = _schedules.FixedRate(_datetime.timedelta(minutes=30),
                               kickoff_time_input_arg="abc")
    assert obj.rate.unit == _schedules.FixedRate.FixedRateUnit.MINUTE
    assert obj.rate.value == 30
    assert obj == _schedules.FixedRate.from_flyte_idl(obj.to_flyte_idl())

    obj = _schedules.FixedRate(_datetime.timedelta(minutes=120),
                               kickoff_time_input_arg="abc")
    assert obj.rate.unit == _schedules.FixedRate.FixedRateUnit.HOUR
    assert obj.rate.value == 2
    assert obj == _schedules.FixedRate.from_flyte_idl(obj.to_flyte_idl())
예제 #2
0
# Example 1 show cron schedule
scale_rotate_cronscheduled_launchplan = workflows.ScaleAndRotateWorkflow.create_launch_plan(
    schedule=_schedules.CronSchedule("0/30 * * * ? *"),
    labels=Labels({
        'flyte.org/managed': 'true',
    }),
    annotations=Annotations({
        'flyte.org/secret-inject': 'required',
    }),
    notifications=[
        _notifications.Slack(
            [
                _execution.WorkflowExecutionPhase.SUCCEEDED,
                _execution.WorkflowExecutionPhase.FAILED,
                _execution.WorkflowExecutionPhase.TIMED_OUT,
                _execution.WorkflowExecutionPhase.ABORTED,
            ],
            ['*****@*****.**'],
        ),
    ],
)

# Example 2 shows Fixed Rate schedule as an example
scale_rotate_fixedRateScheduled_launchplan = workflows.ScaleAndRotateWorkflow.create_launch_plan(
    schedule=_schedules.FixedRate(duration=timedelta(hours=1)), )

# Example 3: Execution time is implicitly passed as an input
scheduled_time_lp = ScheduledWorkflow.create_launch_plan(
    schedule=_schedules.CronSchedule("0/30 * * * ? *",
                                     kickoff_time_input_arg='trigger_time'))