https://flyte.org logo
#announcements
Title
# announcements
k

Kim Junil

06/23/2022, 9:21 AM
Hi, It's related to the chat above I'm trying to schedule launchplan with cron_expression but error occurs
Copy code
launch plan daily failed to update due to rpc error: code = Internal desc = failed adding schedule for unknown schedule expression type &{0 0 * * ? *}
I found this code in flyteadmin github repo while debugging (https://github.com/flyteorg/flyteadmin/blob/master/scheduler/dbapi/event_scheduler_impl.go)
Copy code
func (s *eventScheduler) AddSchedule(ctx context.Context, input interfaces.AddScheduleInput) error {
	...
	switch v := input.ScheduleExpression.GetScheduleExpression().(type) {
	case *admin.Schedule_Rate:
		fixedRateValue = v.Rate.Value
		fixedRateUnit = v.Rate.Unit
	case *admin.Schedule_CronSchedule:
		cronString = v.CronSchedule.Schedule
	default:
		return fmt.Errorf("failed adding schedule for unknown schedule expression type %v", v)
	}
	...
}
and this code in flyteidl repo (https://github.com/flyteorg/flyteidl/blob/master/gen/pb-go/flyteidl/admin/schedule.pb.go)
Copy code
type Schedule struct {
	// Types that are valid to be assigned to ScheduleExpression:
	//	*Schedule_CronExpression
	//	*Schedule_Rate
	//	*Schedule_CronSchedule
	ScheduleExpression isSchedule_ScheduleExpression `protobuf_oneof:"ScheduleExpression"`
	// Name of the input variable that the kickoff time will be supplied to when the workflow is kicked off.
	KickoffTimeInputArg  string   `protobuf:"bytes,3,opt,name=kickoff_time_input_arg,json=kickoffTimeInputArg,proto3" json:"kickoff_time_input_arg,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}
It seems that the error is caused by
AddSchedule
function not processing ths
Schedule_CronExpression
type. Can someone help me?
p

Prafulla Mahindrakar

06/23/2022, 11:02 AM
Hi @Kim Junil, can you check these docs , if you are using the cron schedules correctly
Copy code
schedule=CronSchedule(
        ....
    ),
https://docs.flyte.org/projects/cookbook/en/latest/auto/core/scheduled_workflows/lp_schedules.html#launchplan-schedules And also cron expression format that you are using seems to be older aws format . Can you check this https://docs.flyte.org/en/latest/concepts/schedules.html#cron-expression-table
n

Niels Bantilan

06/23/2022, 1:40 PM
hi @Kim Junil @SeungTaeKim which docs led you to the cron expression that caused the error? The canonical schedule syntax should be documented where @Prafulla Mahindrakar pointed you to
And also cron expression format that you are using seems to be older aws format . Can you check this https://docs.flyte.org/en/latest/concepts/schedules.html#cron-expression-table
@Marc Paquette
And there's comment in this doc. https://docs.flyte.org/projects/cookbook/en/latest/auto/core/scheduled_workflows/lp_schedules.html#cron-schedules
Copy code
from flytekit import CronSchedule, LaunchPlan

# creates a launch plan that runs every minute.
cron_lp = LaunchPlan.get_or_create(
    name="my_cron_scheduled_lp",
    workflow=date_formatter_wf,
    schedule=CronSchedule(
        # Note that kickoff_time_input_arg matches the workflow input we defined above: kickoff_time
        # But in case you are using the AWS scheme of schedules and not using the native scheduler then switch over the schedule parameter with cron_expression
        schedule="*/1 * * * *",  # Following schedule runs every min
        kickoff_time_input_arg="kickoff_time",
    ),
)
Copy code
# But in case you are using the AWS scheme of schedules and not using the native scheduler then switch over the schedule parameter with cron_expression
p

Prafulla Mahindrakar

06/24/2022, 1:06 PM
If you are using native scheduler which is default supported CronSchedule should be used instead of CronExpression . Fixed the docs to clarify this point https://github.com/flyteorg/flytekit/pull/1081/files
👍 1
n

Niels Bantilan

06/24/2022, 2:26 PM
Thanks @Prafulla Mahindrakar! @Marc Paquette we should probably double check and do a pass at all the Cron-related docs to make sure they’re consistent. I think we should clarify the difference between the native scheduler vs other (AWS?-dependent) schedulers
👍 2
3 Views