Skip to content

Schedules #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 17, 2023
Merged

Schedules #279

merged 6 commits into from
Feb 17, 2023

Conversation

cretz
Copy link
Member

@cretz cretz commented Feb 15, 2023

What was changed

  • Added full schedule API
  • Made sure workflows that fail start due to already-started throw a specific exception type

Sorry there is so much here, it's a large API. But most lines are just structure and comments. Use https://github.dev/temporalio/sdk-python/pull/279 w/ side-by-side and for the most of this you can ignore the diff that git is showing except for a few minor actual changes to existing code.

I decided that this fits best in the client package even though it makes that file quite big (that is the Python way quite often). I have also decided that the features repo tests weren't enough for properly testing everything so I have integration tests herein with the expectation to add the feature tests upon release (pretty soon after merged).

Checklist

  1. Closes High level API for schedules #87
  2. Closes [Bug] Make sure start workflows throws WorkflowAlreadyStartedError if already running #258

@cretz cretz requested a review from a team February 15, 2023 20:29
@cretz
Copy link
Member Author

cretz commented Feb 16, 2023

I am aware of CI breaks both due to my assumptions around list consistency and Windows builds currently breaking repo wide. I am working on those, but don't let it halt review.

@cretz cretz requested a review from a team February 16, 2023 21:53
await assert_no_schedules(client)

# Just in case it's on the minute boundary, move it off
now = datetime.utcnow()

Choose a reason for hiding this comment

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

Didn't we decide this is not needed since the backfill start range is exclusive?

Copy link
Member Author

@cretz cretz Feb 17, 2023

Choose a reason for hiding this comment

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

Harmless in the test to be safe and intentionally test off the boundary

Choose a reason for hiding this comment

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

I'd argue its misleading if a user read this test, but not blocking this PR



async def assert_no_schedules(client: Client) -> None:
# Listing appears eventually consistent

Choose a reason for hiding this comment

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

nit: remove comment now that this is confirmed?

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes the comment even more important to explain why I'm repeatedly getting count

"""

recent_actions: Sequence[ScheduleActionResult]
"""10 most recent actions, oldest first."""

Choose a reason for hiding this comment

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

These both should be 5

Copy link
Member Author

@cretz cretz Feb 17, 2023

Choose a reason for hiding this comment

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

👍 I will remove the counts on the list one. But we need to update https://typescript.temporal.io/api/interfaces/client.ScheduleSummary#info too. cc @mjameswh.

EDIT: Removed specifics about count since API docs don't have them either for list info.

Choose a reason for hiding this comment

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

Yeah the problem is the number returned by list is different then describe.

https://github.com/temporalio/temporal/blob/master/service/worker/scheduler/workflow.go#L148

Copy link
Contributor

Choose a reason for hiding this comment

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

I removed the exact count on both update and describe in TS.

I know the spec mention 10 on ScheduleInfo, but given that this was made tweakable on the server, I think that we'd better consider that number as an implementation detail rather than a contract.

)
)

def get_schedule_handle(self, id: str) -> ScheduleHandle:
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be useful to mention somewhere that get_schedule_handle doesn't validate that the schedule indeed exists, and thus, that describe and others might fail...

Copy link
Member Author

Choose a reason for hiding this comment

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

Meh, not needed for get_workflow_handle or get_async_activity_handle. Since they are sync calls to fetching a handle, I think it's clear.

ScheduleCalendarSpec._from_proto(c) for c in spec.structured_calendar
],
intervals=[ScheduleIntervalSpec._from_proto(i) for i in spec.interval],
cron_expressions=spec.cron_string,
Copy link
Contributor

Choose a reason for hiding this comment

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

You should never receive a cron_string from the server. I'd consider removing that line.

Copy link
Member Author

Choose a reason for hiding this comment

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

This will then always be an empty sequence of strings which is safe and still reads nice from a symmetry perspective. So which fields are populated remains a server decision.

Copy link
Contributor

@mjameswh mjameswh left a comment

Choose a reason for hiding this comment

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

LGTM

@cretz cretz merged commit fbcba65 into temporalio:main Feb 17, 2023
@cretz cretz deleted the schedules branch February 17, 2023 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Make sure start workflows throws WorkflowAlreadyStartedError if already running High level API for schedules
3 participants