Skip to content

Commit 18b890e

Browse files
authored
Server 1.24 related fixes (#551)
1 parent 927415a commit 18b890e

File tree

2 files changed

+22
-41
lines changed

2 files changed

+22
-41
lines changed

temporalio/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,11 @@ def updated(self, *search_attributes: SearchAttributePair) -> TypedSearchAttribu
511511
# Go over each update, replacing matching keys by index or adding
512512
for attr in search_attributes:
513513
existing_index = next(
514-
(i for i, attr in enumerate(attrs) if attr.key.name == attr.key.name),
514+
(
515+
i
516+
for i, index_attr in enumerate(attrs)
517+
if attr.key.name == index_attr.key.name
518+
),
515519
None,
516520
)
517521
if existing_index is None:

tests/test_client.py

Lines changed: 17 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,9 @@ async def test_schedule_backfill(
10581058
)
10591059
],
10601060
)
1061-
assert 2 == (await handle.describe()).info.num_actions
1061+
# The number of items backfilled on a schedule boundary changed in 1.24, so
1062+
# we check for either
1063+
assert (await handle.describe()).info.num_actions in [2, 3]
10621064

10631065
# Add two more backfills and and -2m will be deduped
10641066
await handle.backfill(
@@ -1073,7 +1075,9 @@ async def test_schedule_backfill(
10731075
overlap=ScheduleOverlapPolicy.ALLOW_ALL,
10741076
),
10751077
)
1076-
assert 6 == (await handle.describe()).info.num_actions
1078+
# The number of items backfilled on a schedule boundary changed in 1.24, so
1079+
# we check for either
1080+
assert (await handle.describe()).info.num_actions in [6, 8]
10771081

10781082
await handle.delete()
10791083
await assert_no_schedules(client)
@@ -1155,19 +1159,17 @@ def update_schedule_typed_attrs(
11551159
input.description.typed_search_attributes[text_attr_key]
11561160
== "some-schedule-attr1"
11571161
)
1162+
# This assertion has changed since server 1.24. Now, even untyped search
1163+
# attributes are given a type server side
11581164
assert (
11591165
input.description.schedule.action.typed_search_attributes
1160-
and len(input.description.schedule.action.typed_search_attributes) == 1
1166+
and len(input.description.schedule.action.typed_search_attributes) == 2
11611167
and input.description.schedule.action.typed_search_attributes[text_attr_key]
11621168
== "some-workflow-attr1"
1163-
)
1164-
assert (
1165-
input.description.schedule.action.untyped_search_attributes
1166-
and len(input.description.schedule.action.untyped_search_attributes) == 1
1167-
and input.description.schedule.action.untyped_search_attributes[
1168-
untyped_keyword_key.name
1169+
and input.description.schedule.action.typed_search_attributes[
1170+
untyped_keyword_key
11691171
]
1170-
== ["some-untyped-attr1"]
1172+
== "some-untyped-attr1"
11711173
)
11721174

11731175
# Update the workflow search attribute with a new typed value but does
@@ -1189,41 +1191,16 @@ def update_schedule_typed_attrs(
11891191
# Check that it changed
11901192
desc = await handle.describe()
11911193
assert isinstance(desc.schedule.action, ScheduleActionStartWorkflow)
1194+
# This assertion has changed since server 1.24. Now, even untyped search
1195+
# attributes are given a type server side
11921196
assert (
11931197
desc.schedule.action.typed_search_attributes
1194-
and len(desc.schedule.action.typed_search_attributes) == 1
1195-
and desc.schedule.action.typed_search_attributes[text_attr_key]
1196-
== "some-workflow-attr2"
1197-
)
1198-
assert (
1199-
desc.schedule.action.untyped_search_attributes
1200-
and len(desc.schedule.action.untyped_search_attributes) == 1
1201-
and desc.schedule.action.untyped_search_attributes[untyped_keyword_key.name]
1202-
== ["some-untyped-attr1"]
1203-
)
1204-
1205-
# Normal update with no typed attr change but remove untyped
1206-
def update_schedule_remove_untyped(
1207-
input: ScheduleUpdateInput,
1208-
) -> Optional[ScheduleUpdate]:
1209-
assert isinstance(
1210-
input.description.schedule.action, ScheduleActionStartWorkflow
1211-
)
1212-
input.description.schedule.action.untyped_search_attributes = {}
1213-
return ScheduleUpdate(input.description.schedule)
1214-
1215-
await handle.update(update_schedule_remove_untyped)
1216-
1217-
# Check that typed did not change but untyped did
1218-
desc = await handle.describe()
1219-
assert isinstance(desc.schedule.action, ScheduleActionStartWorkflow)
1220-
assert (
1221-
desc.schedule.action.typed_search_attributes
1222-
and len(desc.schedule.action.typed_search_attributes) == 1
1198+
and len(desc.schedule.action.typed_search_attributes) == 2
12231199
and desc.schedule.action.typed_search_attributes[text_attr_key]
12241200
== "some-workflow-attr2"
1201+
and desc.schedule.action.typed_search_attributes[untyped_keyword_key]
1202+
== "some-untyped-attr1"
12251203
)
1226-
assert not desc.schedule.action.untyped_search_attributes
12271204

12281205

12291206
async def assert_no_schedules(client: Client) -> None:

0 commit comments

Comments
 (0)