Skip to content

Commit 16b540c

Browse files
committed
Make Temporal context classes non-private
1 parent 58f6977 commit 16b540c

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

temporalio/nexus/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from ._decorators import workflow_run_operation as workflow_run_operation
22
from ._operation_context import Info as Info
33
from ._operation_context import (
4-
WorkflowRunOperationContext as WorkflowRunOperationContext,
4+
TemporalStartOperationContext as TemporalStartOperationContext,
55
)
66
from ._operation_context import (
77
_TemporalCancelOperationContext as _TemporalCancelOperationContext,
88
)
99
from ._operation_context import (
10-
_TemporalStartOperationContext as _TemporalStartOperationContext,
10+
WorkflowRunOperationContext as WorkflowRunOperationContext,
1111
)
1212
from ._operation_context import client as client
1313
from ._operation_context import info as info

temporalio/nexus/_decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
)
1818

1919
from temporalio.nexus._operation_context import (
20+
TemporalStartOperationContext,
2021
WorkflowRunOperationContext,
21-
_TemporalStartOperationContext,
2222
)
2323
from temporalio.nexus._operation_handlers import (
2424
WorkflowRunOperationHandler,
@@ -115,7 +115,7 @@ def operation_handler_factory(
115115
async def _start(
116116
ctx: StartOperationContext, input: InputT
117117
) -> WorkflowHandle[OutputT]:
118-
tctx = _TemporalStartOperationContext.get()
118+
tctx = TemporalStartOperationContext.get()
119119
return await start(self, WorkflowRunOperationContext(tctx), input)
120120

121121
_start.__doc__ = start.__doc__

temporalio/nexus/_operation_context.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# CancelOperationContext and passes it as the first parameter to the nexusrpc operation
3636
# handler. In addition, it sets one of the following context vars.
3737

38-
_temporal_start_operation_context: ContextVar[_TemporalStartOperationContext] = (
38+
_temporal_start_operation_context: ContextVar[TemporalStartOperationContext] = (
3939
ContextVar("temporal-start-operation-context")
4040
)
4141

@@ -70,7 +70,7 @@ def client() -> temporalio.client.Client:
7070

7171

7272
def _temporal_context() -> (
73-
Union[_TemporalStartOperationContext, _TemporalCancelOperationContext]
73+
Union[TemporalStartOperationContext, _TemporalCancelOperationContext]
7474
):
7575
ctx = _try_temporal_context()
7676
if ctx is None:
@@ -79,7 +79,7 @@ def _temporal_context() -> (
7979

8080

8181
def _try_temporal_context() -> (
82-
Optional[Union[_TemporalStartOperationContext, _TemporalCancelOperationContext]]
82+
Optional[Union[TemporalStartOperationContext, _TemporalCancelOperationContext]]
8383
):
8484
start_ctx = _temporal_start_operation_context.get(None)
8585
cancel_ctx = _temporal_cancel_operation_context.get(None)
@@ -89,7 +89,7 @@ def _try_temporal_context() -> (
8989

9090

9191
@dataclass
92-
class _TemporalStartOperationContext:
92+
class TemporalStartOperationContext:
9393
"""
9494
Context for a Nexus start operation being handled by a Temporal Nexus Worker.
9595
"""
@@ -104,7 +104,7 @@ class _TemporalStartOperationContext:
104104
"""The Temporal client in use by the worker handling this Nexus operation."""
105105

106106
@classmethod
107-
def get(cls) -> _TemporalStartOperationContext:
107+
def get(cls) -> TemporalStartOperationContext:
108108
ctx = _temporal_start_operation_context.get(None)
109109
if ctx is None:
110110
raise RuntimeError("Not in Nexus operation context.")
@@ -170,15 +170,15 @@ def add_outbound_links(
170170

171171
@dataclass
172172
class WorkflowRunOperationContext:
173-
temporal_context: _TemporalStartOperationContext
173+
temporal_context: TemporalStartOperationContext
174174

175175
@property
176176
def nexus_context(self) -> StartOperationContext:
177177
return self.temporal_context.nexus_context
178178

179179
@classmethod
180180
def get(cls) -> WorkflowRunOperationContext:
181-
return cls(_TemporalStartOperationContext.get())
181+
return cls(TemporalStartOperationContext.get())
182182

183183
# Overload for single-param workflow
184184
# TODO(nexus-prerelease): bring over other overloads

temporalio/worker/_nexus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
from temporalio.exceptions import ApplicationError
3535
from temporalio.nexus import (
3636
Info,
37+
TemporalStartOperationContext,
3738
_TemporalCancelOperationContext,
38-
_TemporalStartOperationContext,
3939
logger,
4040
)
4141
from temporalio.service import RPCError, RPCStatusCode
@@ -269,7 +269,7 @@ async def _start_operation(
269269
],
270270
callback_headers=dict(start_request.callback_header),
271271
)
272-
_TemporalStartOperationContext(
272+
TemporalStartOperationContext(
273273
nexus_context=ctx,
274274
client=self._client,
275275
info=lambda: Info(task_queue=self._task_queue),

0 commit comments

Comments
 (0)