Skip to content

support timezone when scheduling with Argo workflows#1250

Merged
savingoyal merged 10 commits intoNetflix:masterfrom
amerberg:argo_schedule_tz
Jan 31, 2023
Merged

support timezone when scheduling with Argo workflows#1250
savingoyal merged 10 commits intoNetflix:masterfrom
amerberg:argo_schedule_tz

Conversation

@amerberg
Copy link
Copy Markdown
Contributor

This PR adds support for specifying a timezone when scheduling Argo workflows.

The relevant Argo documentation is here: https://argoproj.github.io/argo-workflows/cron-workflows/#cronworkflow-options

return " ".join(schedule.schedule.split()[:5])
return None

def _timezone(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

small nit - can we have _cron(...) return a tuple that includes the timezone as well. that will negate the need for creating this function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@amerberg
Copy link
Copy Markdown
Contributor Author

How do we want to handle AWS Batch, which as far as I can tell, doesn't support a timezone with the cron schedule? It seems like we should at least issue a warning, perhaps even fail, if the user specifies a timezone and we can't use it with it.

@shrinandj
Copy link
Copy Markdown
Contributor

Thanks a lot for adding this!

Other than addressing the review comment above, can you also add a note about the testing you did for this change? The basic tests to do here would include running a flow providing a timezone and running a flow without a timezone (current behavior).

@amerberg
Copy link
Copy Markdown
Contributor Author

Yes, I tested by adding a schedule decorator to a simple flow. I created workflows with two different timezones, and then one with no timezone, and confirmed that they all started at the correct time.

@savingoyal
Copy link
Copy Markdown
Collaborator

How do we want to handle AWS Batch, which as far as I can tell, doesn't support a timezone with the cron schedule? It seems like we should at least issue a warning, perhaps even fail, if the user specifies a timezone and we can't use it with it.

Yep - within AWS Step Functions we would want to check if the user has specified timezone and fail hard if that is the case. Can you also add a note in @schedule re: the format that the timezone should be specified in.

@savingoyal
Copy link
Copy Markdown
Collaborator

cc @valayDave re: impact on Airflow integration

@amerberg
Copy link
Copy Markdown
Contributor Author

Added documentation for timezone format (IANA standard) and an assertion to check that a timezone isn't provided with Step Functions.

shrinandj
shrinandj previously approved these changes Jan 27, 2023
Copy link
Copy Markdown
Contributor

@shrinandj shrinandj left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for your contributions!

def _cron(self):
schedule = self.flow._flow_decorators.get("schedule")
if schedule:
assert (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rather than the assert, can you raise StepFunctionsException so that Metaflow can pretty print the exception?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

savingoyal
savingoyal previously approved these changes Jan 28, 2023
Copy link
Copy Markdown
Collaborator

@savingoyal savingoyal left a comment

Choose a reason for hiding this comment

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

LGTM! (pending a review from @valayDave regarding Airflow compatibility)

"weekly": False,
"daily": True,
"hourly": False,
"timezone": None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This default value of timezone should be added to the doc string at line number 20. We can even add this link for people to easily know what the format looks like

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.

@amerberg
Copy link
Copy Markdown
Contributor Author

Based on the Airflow docs, I think the way to make this work with Airflow would be to use a timezone-aware pendulum.datetime for the start_date here:

start_date=datetime.now(),
. However, I don't have a working Airflow setup to test it.

@valayDave
Copy link
Copy Markdown
Collaborator

@amerberg ; Thanks for scoping the Airflow change. For now we can leave airflow with out the change. I already have some pending stacked PRs like #1234 where i can incorporate necessary changes.

@amerberg
Copy link
Copy Markdown
Contributor Author

@valayDave Should we at least add a check, analogous to the Step Functions check, to fail if the user specifies a timezone with Airflow?

@valayDave
Copy link
Copy Markdown
Collaborator

@amerberg : I already have something in the works with #1252 ; For the moment we can merge this PR after which I will rebase and update my stacked PRs so that we do something analogous to the Step functions check.

@savingoyal savingoyal merged commit ba270d2 into Netflix:master Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants