Skip to content

Commit e425c35

Browse files
committed
PR Feedback
1 parent 6e613a5 commit e425c35

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

durabletask/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def __init__(self, *,
397397
)
398398
self._channel = channel
399399
self._stub = stubs.TaskHubSidecarServiceStub(channel)
400-
self._logger = shared.get_logger("client", log_handler, log_formatter)
400+
self._logger = shared.get_logger("async_client", log_handler, log_formatter)
401401
self.default_version = default_version
402402

403403
async def close(self) -> None:

durabletask/internal/grpc_interceptor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _AsyncClientCallDetails(
2525
['method', 'timeout', 'metadata', 'credentials', 'wait_for_ready']),
2626
grpc.aio.ClientCallDetails):
2727
"""This is an implementation of the aio ClientCallDetails interface needed for async interceptors.
28-
This class takes six named values and inherits the ClientCallDetails from grpc.aio package.
28+
This class takes five named values and inherits the ClientCallDetails from grpc.aio package.
2929
This class encloses the values that describe a RPC to be invoked.
3030
"""
3131
pass

tests/durabletask/test_orchestration_async_e2e.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@
77
import pytest
88

99
from durabletask import client, task, worker
10+
from durabletask.testing import create_test_backend
1011

11-
# NOTE: These tests assume a sidecar process is running. Example command:
12-
# go install github.com/microsoft/durabletask-go@main
13-
# durabletask-go --port 4001
14-
pytestmark = pytest.mark.e2e
12+
HOST = "localhost:50060"
13+
14+
15+
@pytest.fixture(autouse=True)
16+
def backend():
17+
"""Create an in-memory backend for testing."""
18+
b = create_test_backend(port=50060)
19+
yield b
20+
b.stop()
21+
b.reset()
1522

1623

1724
@pytest.mark.asyncio
@@ -23,11 +30,11 @@ def empty_orchestrator(ctx: task.OrchestrationContext, _):
2330
nonlocal invoked # don't do this in a real app!
2431
invoked = True
2532

26-
with worker.TaskHubGrpcWorker() as w:
33+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
2734
w.add_orchestrator(empty_orchestrator)
2835
w.start()
2936

30-
c = client.AsyncTaskHubGrpcClient()
37+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
3138
id = await c.schedule_new_orchestration(empty_orchestrator, tags={'Tagged': 'true'})
3239
state = await c.wait_for_orchestration_completion(id, timeout=30)
3340

@@ -56,12 +63,12 @@ def sequence(ctx: task.OrchestrationContext, start_val: int):
5663
numbers.append(current)
5764
return numbers
5865

59-
with worker.TaskHubGrpcWorker() as w:
66+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
6067
w.add_orchestrator(sequence)
6168
w.add_activity(plus_one)
6269
w.start()
6370

64-
c = client.AsyncTaskHubGrpcClient()
71+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
6572
id = await c.schedule_new_orchestration(sequence, input=1)
6673
state = await c.wait_for_orchestration_completion(id, timeout=30)
6774

@@ -82,11 +89,11 @@ def orchestrator(ctx: task.OrchestrationContext, _):
8289
c = yield ctx.wait_for_external_event('C')
8390
return [a, b, c]
8491

85-
with worker.TaskHubGrpcWorker() as w:
92+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
8693
w.add_orchestrator(orchestrator)
8794
w.start()
8895

89-
c = client.AsyncTaskHubGrpcClient()
96+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
9097
id = await c.schedule_new_orchestration(orchestrator)
9198
await c.raise_orchestration_event(id, 'A', data='a')
9299
await c.raise_orchestration_event(id, 'B', data='b')
@@ -104,11 +111,11 @@ def orchestrator(ctx: task.OrchestrationContext, _):
104111
result = yield ctx.wait_for_external_event("my_event")
105112
return result
106113

107-
with worker.TaskHubGrpcWorker() as w:
114+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
108115
w.add_orchestrator(orchestrator)
109116
w.start()
110117

111-
c = client.AsyncTaskHubGrpcClient()
118+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
112119
id = await c.schedule_new_orchestration(orchestrator)
113120
state = await c.wait_for_orchestration_start(id, timeout=30)
114121
assert state is not None
@@ -143,11 +150,11 @@ def orchestrator(ctx: task.OrchestrationContext, _):
143150
result = yield ctx.wait_for_external_event("my_event")
144151
return result
145152

146-
with worker.TaskHubGrpcWorker() as w:
153+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
147154
w.add_orchestrator(orchestrator)
148155
w.start()
149156

150-
c = client.AsyncTaskHubGrpcClient()
157+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
151158
id = await c.schedule_new_orchestration(orchestrator)
152159
state = await c.wait_for_orchestration_start(id, timeout=30)
153160
assert state is not None
@@ -165,11 +172,11 @@ async def test_async_purge_orchestration():
165172
def orchestrator(ctx: task.OrchestrationContext, _):
166173
pass
167174

168-
with worker.TaskHubGrpcWorker() as w:
175+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
169176
w.add_orchestrator(orchestrator)
170177
w.start()
171178

172-
c = client.AsyncTaskHubGrpcClient()
179+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
173180
id = await c.schedule_new_orchestration(orchestrator)
174181
await c.wait_for_orchestration_completion(id, timeout=30)
175182

@@ -181,7 +188,6 @@ def orchestrator(ctx: task.OrchestrationContext, _):
181188

182189

183190
@pytest.mark.asyncio
184-
@pytest.mark.skip(reason="durabletask-go does not yet support RestartInstance")
185191
async def test_async_restart_with_same_instance_id():
186192
def orchestrator(ctx: task.OrchestrationContext, _):
187193
result = yield ctx.call_activity(say_hello, input="World")
@@ -190,12 +196,12 @@ def orchestrator(ctx: task.OrchestrationContext, _):
190196
def say_hello(ctx: task.ActivityContext, input: str):
191197
return f"Hello, {input}!"
192198

193-
with worker.TaskHubGrpcWorker() as w:
199+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
194200
w.add_orchestrator(orchestrator)
195201
w.add_activity(say_hello)
196202
w.start()
197203

198-
c = client.AsyncTaskHubGrpcClient()
204+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
199205
id = await c.schedule_new_orchestration(orchestrator)
200206
state = await c.wait_for_orchestration_completion(id, timeout=30)
201207
assert state is not None
@@ -213,7 +219,6 @@ def say_hello(ctx: task.ActivityContext, input: str):
213219

214220

215221
@pytest.mark.asyncio
216-
@pytest.mark.skip(reason="durabletask-go does not yet support RestartInstance")
217222
async def test_async_restart_with_new_instance_id():
218223
def orchestrator(ctx: task.OrchestrationContext, _):
219224
result = yield ctx.call_activity(say_hello, input="World")
@@ -222,12 +227,12 @@ def orchestrator(ctx: task.OrchestrationContext, _):
222227
def say_hello(ctx: task.ActivityContext, input: str):
223228
return f"Hello, {input}!"
224229

225-
with worker.TaskHubGrpcWorker() as w:
230+
with worker.TaskHubGrpcWorker(host_address=HOST) as w:
226231
w.add_orchestrator(orchestrator)
227232
w.add_activity(say_hello)
228233
w.start()
229234

230-
c = client.AsyncTaskHubGrpcClient()
235+
c = client.AsyncTaskHubGrpcClient(host_address=HOST)
231236
id = await c.schedule_new_orchestration(orchestrator)
232237
state = await c.wait_for_orchestration_completion(id, timeout=30)
233238
assert state is not None

0 commit comments

Comments
 (0)