Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Support Styx style schedule #83

Merged
merged 10 commits into from
Oct 2, 2020
Merged

Support Styx style schedule #83

merged 10 commits into from
Oct 2, 2020

Conversation

honnix
Copy link
Member

@honnix honnix commented Sep 29, 2020

TL;DR

When integrating with our scheduler Styx, we will need to extend the semantics of schedule to support Styx cron syntax, cron aliases, as well as offset.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

Complete description and details can be found in the issue description.

Tracking Issue

flyteorg/flyte#529

Follow-up issue

@honnix honnix requested a review from kumare3 September 29, 2020 09:59
@honnix honnix force-pushed the support-styx-schedule branch from 45e696e to 28680fc Compare September 29, 2020 11:25
@katrogan
Copy link
Contributor

hey @honnix mind bumping the version here and here as part of your change?

@honnix
Copy link
Member Author

honnix commented Sep 29, 2020

Sure I will fix that.

@honnix honnix force-pushed the support-styx-schedule branch from 28680fc to 58b4964 Compare September 29, 2020 18:10
@honnix
Copy link
Member Author

honnix commented Sep 29, 2020

I made the changes as suggested. I will work on flyteadmin later to reject launch plan with this kind of schedule, then probably there is no need to change flyteconsole to display the schedule. Another PR will be made in flytekit to propagate the proto.

@honnix
Copy link
Member Author

honnix commented Sep 29, 2020

I forgot to make generate again. :( Sorry and will fix.

@honnix
Copy link
Member Author

honnix commented Sep 30, 2020

Does this look more reasonable now?

@@ -16,6 +16,12 @@ message FixedRate {
FixedRateUnit unit = 2;
}

// Supported only by some schedulers for example Spotify/Styx. Your platform may not have this enabled.
message CronScheduleWithOffset {
string schedule = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the schedule here actually the expression?
Also, this is pretty good, i think eventually we should just deprecate cron_expression for CronScheduleWithOffset (just offset will be 0 by default and not supported on most platforms)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be a cron expression or alias such as hourly, daily, weekly, monthly etc. So we were not so sure what name could be more reasonable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR flyteorg/flytekit#188 gives more details.

@kumare3
Copy link
Contributor

kumare3 commented Sep 30, 2020

minor nit, then +1

Copy link
Contributor

@wild-endeavor wild-endeavor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what @katrogan thinks?

protos/flyteidl/admin/schedule.proto Outdated Show resolved Hide resolved
protos/flyteidl/admin/schedule.proto Outdated Show resolved Hide resolved
protos/flyteidl/admin/schedule.proto Outdated Show resolved Hide resolved
@honnix
Copy link
Member Author

honnix commented Oct 1, 2020

@wild-endeavor I guess it is legacy reason, the cron expression handling is very weird in flytekit as it basically casts from a richer semantics to a weaker one by string manipulation. Is it OK with this change we start accepting Unix flavoured cron in launch plan definition? For example, for the deprecated cron expression we keep the the existing logic unchanged, while for CronSchedule we parse it directly using croniter, and the validation will also allow cron alias, such as daily, weekly, etc. The validation logic can be found in the proposed flytekit PR.

@honnix
Copy link
Member Author

honnix commented Oct 1, 2020

@wild-endeavor What do you think of the name of this class: https://github.com/lyft/flytekit/blob/6274318ad9f64b0367754a917d08d0f133358300/flytekit/common/schedules.py#L128. There is already a class named CronSchedule.

@honnix
Copy link
Member Author

honnix commented Oct 2, 2020

I have a second thought now, that I think it might make other changes easier (flytekit and flyteadmin) to name the message as CronScheduleWithOffset, without conflicting with existing names that we need to keep for backward compatibility.

@wild-endeavor
Copy link
Contributor

+1 after changing the name to CronSchedule

@katrogan
Copy link
Contributor

katrogan commented Oct 2, 2020

I like CronSchedule too! I think it will make sense to move to that as the replacement for cron_expression (which like @honnix mentioned is a weird/less-structured format anyways)

@honnix
Copy link
Member Author

honnix commented Oct 2, 2020

How do we handle the python class name then? We could have more validation branches to cover alias, Unix cron and existing cron in the same class. How does that sound?

@honnix
Copy link
Member Author

honnix commented Oct 2, 2020

@katrogan @wild-endeavor I revert it back to CronSchedule. Please take a look again. Thanks.

@@ -16,14 +16,20 @@ message FixedRate {
FixedRateUnit unit = 2;
}

message CronSchedule {
string schedule = 1;
string offset = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit: can you add comments on what the expected format for schedule and offset should be?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katrogan Do we plan to support AWS cron as well in CronSchedule.schedule? If yes, I can revise the comment a bit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move away from the aws cron type (which is more work) and have admin handle converting to it in its aws specific scheduler handler. But that can be a separate issue and we can keep using the deprecated cron_expression in the meantime

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. The problem is the 5-fields cron syntax is weaker than the one used by AWS, so it's not gonna be an 100% mapping.

Copy link
Contributor

@katrogan katrogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @wild-endeavor mind taking one last look?

@honnix
Copy link
Member Author

honnix commented Oct 2, 2020

Alright. I'm merging this and will make changes in flytekit accordingly. Thanks everyone for reviewing and commenting on this PR.

@honnix honnix merged commit 4c06596 into master Oct 2, 2020
@honnix honnix deleted the support-styx-schedule branch October 2, 2020 19:55
@honnix
Copy link
Member Author

honnix commented Oct 2, 2020

@katrogan I drafted this release https://github.com/lyft/flyteidl/releases/tag/untagged-eaee7bcfa18de386fe2b, please take a look and release if it is OK.

@katrogan
Copy link
Contributor

katrogan commented Oct 2, 2020

@honnix looks good!

@honnix
Copy link
Member Author

honnix commented Oct 2, 2020

Somehow the github workflow is not triggered to publish to pypi. 🤔

@wild-endeavor
Copy link
Contributor

I just tried to push it manually - can you try to pull on your end?

@honnix
Copy link
Member Author

honnix commented Oct 2, 2020

@wild-endeavor Yeah that worked. I guess I messed it by drafting a release and then publish. There are weird things regarding which event to use: https://stackoverflow.com/questions/59319281/github-action-different-between-release-created-and-published

honnix added a commit to flyteorg/flytekit that referenced this pull request Oct 4, 2020
* Extend `CronSchedule` to support `schedule` and `offset` added in flyteorg/flyteidl#83

Co-authored-by: tnsetting <[email protected]>
max-hoffman pushed a commit to dolthub/flytekit that referenced this pull request May 11, 2021
* Extend `CronSchedule` to support `schedule` and `offset` added in flyteorg/flyteidl#83

Co-authored-by: tnsetting <[email protected]>
pingsutw pushed a commit to pingsutw/flyte-monorepo that referenced this pull request Apr 4, 2023
* Extend `CronSchedule` to support `schedule` and `offset` added in flyteorg/flyteidl#83

Co-authored-by: tnsetting <[email protected]>
eapolinario pushed a commit that referenced this pull request Sep 8, 2023
* Support cron schedule with offset.

For example: https://github.com/spotify/styx#schedule-string

* Add generated files

* Update protos/flyteidl/admin/schedule.proto

Co-authored-by: Yee Hing Tong <[email protected]>

* Update protos/flyteidl/admin/schedule.proto

Co-authored-by: Yee Hing Tong <[email protected]>

* Update protos/flyteidl/admin/schedule.proto

Co-authored-by: Yee Hing Tong <[email protected]>

* Regenerate files

* Regenerate files

* Change the message name back

* Revert "Change the message name back"

This reverts commit e468ea8.

* Add comments for schedule and offset

Co-authored-by: Yee Hing Tong <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants