2020 Optional ,
2121 Sequence ,
2222 Tuple ,
23- Type ,
2423 cast ,
2524)
2625
3231from temporalio .api .common .v1 import Payload , Payloads , WorkflowExecution
3332from temporalio .api .enums .v1 import EventType , IndexedValueType
3433from temporalio .api .failure .v1 import Failure
35- from temporalio .api .operatorservice .v1 import AddSearchAttributesRequest
36- from temporalio .api .workflowservice .v1 import (
37- GetSearchAttributesRequest ,
38- GetWorkflowExecutionHistoryRequest ,
34+ from temporalio .api .operatorservice .v1 import (
35+ AddSearchAttributesRequest ,
36+ ListSearchAttributesRequest ,
3937)
38+ from temporalio .api .workflowservice .v1 import GetWorkflowExecutionHistoryRequest
4039from temporalio .bridge .proto .workflow_activation import WorkflowActivation
4140from temporalio .bridge .proto .workflow_completion import WorkflowActivationCompletion
4241from temporalio .client import (
@@ -1356,9 +1355,11 @@ def do_search_attribute_update(self) -> None:
13561355 empty_float_list : List [float ] = []
13571356 workflow .upsert_search_attributes (
13581357 {
1359- f"{ sa_prefix } text" : ["text3" ],
1360- # We intentionally leave keyword off to confirm it still comes back
1361- f"{ sa_prefix } int" : [123 , 456 ],
1358+ f"{ sa_prefix } text" : ["text2" ],
1359+ # We intentionally leave keyword off to confirm it still comes
1360+ # back but replace keyword list
1361+ f"{ sa_prefix } keyword_list" : ["keywordlist3" , "keywordlist4" ],
1362+ f"{ sa_prefix } int" : [456 ],
13621363 # Empty list to confirm removed
13631364 f"{ sa_prefix } double" : empty_float_list ,
13641365 f"{ sa_prefix } bool" : [False ],
@@ -1374,18 +1375,20 @@ async def test_workflow_search_attributes(client: Client, env_type: str):
13741375 pytest .skip ("Only testing search attributes on local which disables cache" )
13751376
13761377 async def search_attributes_present () -> bool :
1377- resp = await client .workflow_service . get_search_attributes (
1378- GetSearchAttributesRequest ( )
1378+ resp = await client .operator_service . list_search_attributes (
1379+ ListSearchAttributesRequest ( namespace = client . namespace )
13791380 )
1380- return any (k for k in resp .keys .keys () if k .startswith (sa_prefix ))
1381+ return any (k for k in resp .custom_attributes .keys () if k .startswith (sa_prefix ))
13811382
13821383 # Add search attributes if not already present
13831384 if not await search_attributes_present ():
13841385 await client .operator_service .add_search_attributes (
13851386 AddSearchAttributesRequest (
1387+ namespace = client .namespace ,
13861388 search_attributes = {
13871389 f"{ sa_prefix } text" : IndexedValueType .INDEXED_VALUE_TYPE_TEXT ,
13881390 f"{ sa_prefix } keyword" : IndexedValueType .INDEXED_VALUE_TYPE_KEYWORD ,
1391+ f"{ sa_prefix } keyword_list" : IndexedValueType .INDEXED_VALUE_TYPE_KEYWORD_LIST ,
13891392 f"{ sa_prefix } int" : IndexedValueType .INDEXED_VALUE_TYPE_INT ,
13901393 f"{ sa_prefix } double" : IndexedValueType .INDEXED_VALUE_TYPE_DOUBLE ,
13911394 f"{ sa_prefix } bool" : IndexedValueType .INDEXED_VALUE_TYPE_BOOL ,
@@ -1402,29 +1405,31 @@ async def search_attributes_present() -> bool:
14021405 id = f"workflow-{ uuid .uuid4 ()} " ,
14031406 task_queue = worker .task_queue ,
14041407 search_attributes = {
1405- f"{ sa_prefix } text" : ["text1" , "text2" , "text0" ],
1408+ f"{ sa_prefix } text" : ["text1" ],
14061409 f"{ sa_prefix } keyword" : ["keyword1" ],
1410+ f"{ sa_prefix } keyword_list" : ["keywordlist1" , "keywordlist2" ],
14071411 f"{ sa_prefix } int" : [123 ],
14081412 f"{ sa_prefix } double" : [456.78 ],
14091413 f"{ sa_prefix } bool" : [True ],
14101414 f"{ sa_prefix } datetime" : [
1411- # With UTC
1412- datetime (2001 , 2 , 3 , 4 , 5 , 6 , tzinfo = timezone .utc ),
1413- # With other offset
1414- datetime (2002 , 3 , 4 , 5 , 6 , 7 , tzinfo = timezone (timedelta (hours = 8 ))),
1415+ datetime (2001 , 2 , 3 , 4 , 5 , 6 , tzinfo = timezone .utc )
14151416 ],
14161417 },
14171418 )
14181419 # Make sure it started with the right attributes
14191420 expected = {
1420- f"{ sa_prefix } text" : {"type" : "str" , "values" : ["text1" , "text2" , "text0" ]},
1421+ f"{ sa_prefix } text" : {"type" : "str" , "values" : ["text1" ]},
14211422 f"{ sa_prefix } keyword" : {"type" : "str" , "values" : ["keyword1" ]},
1423+ f"{ sa_prefix } keyword_list" : {
1424+ "type" : "str" ,
1425+ "values" : ["keywordlist1" , "keywordlist2" ],
1426+ },
14221427 f"{ sa_prefix } int" : {"type" : "int" , "values" : [123 ]},
14231428 f"{ sa_prefix } double" : {"type" : "float" , "values" : [456.78 ]},
14241429 f"{ sa_prefix } bool" : {"type" : "bool" , "values" : [True ]},
14251430 f"{ sa_prefix } datetime" : {
14261431 "type" : "datetime" ,
1427- "values" : ["2001-02-03 04:05:06+00:00" , "2002-03-04 05:06:07+08:00" ],
1432+ "values" : ["2001-02-03 04:05:06+00:00" ],
14281433 },
14291434 }
14301435 assert expected == await handle .query (
@@ -1434,9 +1439,13 @@ async def search_attributes_present() -> bool:
14341439 # Do an attribute update and check query
14351440 await handle .signal (SearchAttributeWorkflow .do_search_attribute_update )
14361441 expected = {
1437- f"{ sa_prefix } text" : {"type" : "str" , "values" : ["text3 " ]},
1442+ f"{ sa_prefix } text" : {"type" : "str" , "values" : ["text2 " ]},
14381443 f"{ sa_prefix } keyword" : {"type" : "str" , "values" : ["keyword1" ]},
1439- f"{ sa_prefix } int" : {"type" : "int" , "values" : [123 , 456 ]},
1444+ f"{ sa_prefix } keyword_list" : {
1445+ "type" : "str" ,
1446+ "values" : ["keywordlist3" , "keywordlist4" ],
1447+ },
1448+ f"{ sa_prefix } int" : {"type" : "int" , "values" : [456 ]},
14401449 f"{ sa_prefix } double" : {"type" : "<unknown>" , "values" : []},
14411450 f"{ sa_prefix } bool" : {"type" : "bool" , "values" : [False ]},
14421451 f"{ sa_prefix } datetime" : {
0 commit comments