Skip to content
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

Update schedule search attributes #753

Merged
merged 6 commits into from
Jan 27, 2025

Conversation

dandavison
Copy link
Contributor

@dandavison dandavison commented Jan 26, 2025

Fixes #594

Support updating schedule SAs. The API is that the user sets typed SAs in the same "updater" function that they use for updating the schedule itself.

@dandavison dandavison force-pushed the schedule-update-sa branch 2 times, most recently from 4d105ff to a3b5856 Compare January 27, 2025 02:26
@dandavison dandavison marked this pull request as ready for review January 27, 2025 02:27
@dandavison dandavison requested a review from a team as a code owner January 27, 2025 02:27
and len(desc.search_attributes) == 0
)

await assert_eq_eventually(True, expectation)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the test case that fails without the change above relating to empty map in the request proto.

@dandavison dandavison marked this pull request as draft January 27, 2025 02:36
@dandavison dandavison marked this pull request as ready for review January 27, 2025 02:54
request_id=str(uuid.uuid4()),
)
if update.search_attributes is not None:
request.search_attributes.indexed_fields.clear() # Ensure that we at least create an empty map
Copy link
Contributor Author

@dandavison dandavison Jan 27, 2025

Choose a reason for hiding this comment

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

Without this, if the user sets an empty but non-None value, then the request proto does not contain a search_attributes field at all. That's incorrect; what we want in that case is an empty map, which clears all SAs server-side. See docs in API: temporalio/api:/temporal/api/workflowservice/v1/request_response.proto

I investigated making this change (empty map in proto for empty but non-None SAs) in encode_search_attributes so that it is applied consistently to all code paths, but it causes the existing test test_schedule_workflow_search_attribute_update to break.

Copy link
Member

@cretz cretz Jan 27, 2025

Choose a reason for hiding this comment

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

This approach makes sense since, uniquely in Python, we pass the collection to write to for the helpers instead of just assign the variable due to how Python protos work. Though it is strange you can't just start writing to the map and it is created lazily.

request_id=str(uuid.uuid4()),
)
if update.search_attributes is not None:
request.search_attributes.indexed_fields.clear() # Ensure that we at least create an empty map
Copy link
Member

@cretz cretz Jan 27, 2025

Choose a reason for hiding this comment

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

This approach makes sense since, uniquely in Python, we pass the collection to write to for the helpers instead of just assign the variable due to how Python protos work. Though it is strange you can't just start writing to the map and it is created lazily.

Run tests sequentially and fix reference to workflow.NondeterminismError
@dandavison dandavison merged commit 51f4b66 into temporalio:main Jan 27, 2025
13 checks passed
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.

[Feature Request] Support schedule search attribute update
2 participants