Skip to content

Commit 160cd9a

Browse files
committed
Fixup: eliminate references to WorkflowOperationToken
1 parent f0b664f commit 160cd9a

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

temporalio/nexus/_operation_handlers.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,6 @@ class WorkflowRunOperationHandler(OperationHandler[InputT, OutputT]):
4242
Use this class to create an operation handler that starts a workflow by passing your
4343
``start`` method to the constructor. Your ``start`` method must use
4444
:py:func:`temporalio.nexus.start_workflow` to start the workflow.
45-
46-
Example:
47-
48-
.. code-block:: python
49-
50-
@service_handler(service=MyNexusService)
51-
class MyNexusServiceHandler:
52-
@operation_handler
53-
def my_workflow_run_operation(
54-
self,
55-
) -> OperationHandler[MyInput, MyOutput]:
56-
async def start(
57-
ctx: StartOperationContext, input: MyInput
58-
) -> WorkflowOperationToken[MyOutput]:
59-
return await start_workflow(
60-
WorkflowStartedByNexusOperation.run, input,
61-
id=str(uuid.uuid4()),
62-
)
63-
64-
return WorkflowRunOperationHandler.from_start_workflow(start)
6545
"""
6646

6747
def __init__(
@@ -95,13 +75,13 @@ async def start(
9575
if not isinstance(handle, WorkflowHandle):
9676
if isinstance(handle, client.WorkflowHandle):
9777
raise RuntimeError(
98-
f"Expected {handle} to be a WorkflowOperationToken, but got a client.WorkflowHandle. "
99-
f"You must use temporalio.nexus.start_workflow "
78+
f"Expected {handle} to be a nexus.WorkflowHandle, but got a client.WorkflowHandle. "
79+
f"You must use WorkflowRunOperationContext.start_workflow "
10080
"to start a workflow that will deliver the result of the Nexus operation, "
10181
"not client.Client.start_workflow."
10282
)
10383
raise RuntimeError(
104-
f"Expected {handle} to be a WorkflowOperationToken, but got {type(handle)}. "
84+
f"Expected {handle} to be a nexus.WorkflowHandle, but got {type(handle)}. "
10585
)
10686
return StartOperationResultAsync(handle.to_token())
10787

temporalio/nexus/_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_workflow_run_start_method_input_and_output_type_annotations(
4646
output_type = None
4747
elif not issubclass(origin_type, WorkflowHandle):
4848
warnings.warn(
49-
f"Expected return type of {start.__name__} to be a subclass of WorkflowOperationToken, "
49+
f"Expected return type of {start.__name__} to be a subclass of WorkflowHandle, "
5050
f"but is {output_type}"
5151
)
5252
output_type = None

temporalio/workflow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ async def workflow_start_nexus_operation(
859859
Callable[[Any], nexusrpc.handler.OperationHandler[I, O]],
860860
Callable[
861861
[S, nexusrpc.handler.StartOperationContext, I],
862-
Awaitable[temporalio.nexus.WorkflowOperationToken[O]],
862+
Awaitable[temporalio.nexus.WorkflowHandle[O]],
863863
],
864864
str,
865865
],
@@ -4429,7 +4429,7 @@ async def start_nexus_operation(
44294429
Callable[[Any], nexusrpc.handler.OperationHandler[I, O]],
44304430
Callable[
44314431
[S, nexusrpc.handler.StartOperationContext, I],
4432-
Awaitable[temporalio.nexus.WorkflowOperationToken[O]],
4432+
Awaitable[temporalio.nexus.WorkflowHandle[O]],
44334433
],
44344434
str,
44354435
],
@@ -5215,7 +5215,7 @@ async def start_operation(
52155215
Callable[[S], nexusrpc.handler.OperationHandler[I, O]],
52165216
Callable[
52175217
[S, nexusrpc.handler.StartOperationContext, I],
5218-
Awaitable[temporalio.nexus.WorkflowOperationToken[O]],
5218+
Awaitable[temporalio.nexus.WorkflowHandle[O]],
52195219
],
52205220
str,
52215221
],
@@ -5243,7 +5243,7 @@ async def execute_operation(
52435243
Callable[[S], nexusrpc.handler.OperationHandler[I, O]],
52445244
Callable[
52455245
[S, nexusrpc.handler.StartOperationContext, I],
5246-
Awaitable[temporalio.nexus.WorkflowOperationToken[O]],
5246+
Awaitable[temporalio.nexus.WorkflowHandle[O]],
52475247
],
52485248
str,
52495249
],

0 commit comments

Comments
 (0)