Skip to content

Commit 22b47e6

Browse files
committed
linter fixes
1 parent 5d2cd5c commit 22b47e6

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

tests/durabletask-azuremanaged/test_dts_activity_sequence.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
that calls an activity function in a sequence and prints the outputs."""
33
import os
44

5+
import pytest
6+
57
from durabletask import client, task
68
from durabletask.azuremanaged.client import DurableTaskSchedulerClient
79
from durabletask.azuremanaged.worker import DurableTaskSchedulerWorker
810

9-
import pytest
10-
11-
1211
pytestmark = pytest.mark.dts
1312

13+
1414
def hello(ctx: task.ActivityContext, name: str) -> str:
1515
"""Activity function that returns a greeting"""
1616
return f'Hello {name}!'

tests/durabletask-azuremanaged/test_dts_orchestration_e2e.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# Licensed under the MIT License.
33

44
import json
5-
import threading
6-
import time
75
import os
6+
import threading
87
from datetime import timedelta
98

109
import pytest
@@ -21,6 +20,7 @@
2120
taskhub_name = os.getenv("TASKHUB", "default")
2221
endpoint = os.getenv("ENDPOINT", "http://localhost:8080")
2322

23+
2424
def test_empty_orchestration():
2525

2626
invoked = False
@@ -31,12 +31,12 @@ def empty_orchestrator(ctx: task.OrchestrationContext, _):
3131

3232
# Start a worker, which will connect to the sidecar in a background thread
3333
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
34-
taskhub=taskhub_name, token_credential=None) as w:
34+
taskhub=taskhub_name, token_credential=None) as w:
3535
w.add_orchestrator(empty_orchestrator)
3636
w.start()
3737

3838
c = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
39-
taskhub=taskhub_name, token_credential=None)
39+
taskhub=taskhub_name, token_credential=None)
4040
id = c.schedule_new_orchestration(empty_orchestrator)
4141
state = c.wait_for_orchestration_completion(id, timeout=30)
4242

@@ -66,13 +66,13 @@ def sequence(ctx: task.OrchestrationContext, start_val: int):
6666

6767
# Start a worker, which will connect to the sidecar in a background thread
6868
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
69-
taskhub=taskhub_name, token_credential=None) as w:
69+
taskhub=taskhub_name, token_credential=None) as w:
7070
w.add_orchestrator(sequence)
7171
w.add_activity(plus_one)
7272
w.start()
7373

7474
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
75-
taskhub=taskhub_name, token_credential=None)
75+
taskhub=taskhub_name, token_credential=None)
7676
id = task_hub_client.schedule_new_orchestration(sequence, input=1)
7777
state = task_hub_client.wait_for_orchestration_completion(
7878
id, timeout=30)
@@ -113,14 +113,14 @@ def orchestrator(ctx: task.OrchestrationContext, input: int):
113113

114114
# Start a worker, which will connect to the sidecar in a background thread
115115
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
116-
taskhub=taskhub_name, token_credential=None) as w:
116+
taskhub=taskhub_name, token_credential=None) as w:
117117
w.add_orchestrator(orchestrator)
118118
w.add_activity(throw)
119119
w.add_activity(increment_counter)
120120
w.start()
121121

122122
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
123-
taskhub=taskhub_name, token_credential=None)
123+
taskhub=taskhub_name, token_credential=None)
124124
id = task_hub_client.schedule_new_orchestration(orchestrator, input=1)
125125
state = task_hub_client.wait_for_orchestration_completion(id, timeout=30)
126126

@@ -158,14 +158,14 @@ def parent_orchestrator(ctx: task.OrchestrationContext, count: int):
158158

159159
# Start a worker, which will connect to the sidecar in a background thread
160160
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
161-
taskhub=taskhub_name, token_credential=None) as w:
161+
taskhub=taskhub_name, token_credential=None) as w:
162162
w.add_activity(increment)
163163
w.add_orchestrator(orchestrator_child)
164164
w.add_orchestrator(parent_orchestrator)
165165
w.start()
166166

167167
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
168-
taskhub=taskhub_name, token_credential=None)
168+
taskhub=taskhub_name, token_credential=None)
169169
id = task_hub_client.schedule_new_orchestration(parent_orchestrator, input=10)
170170
state = task_hub_client.wait_for_orchestration_completion(id, timeout=30)
171171

@@ -184,13 +184,13 @@ def orchestrator(ctx: task.OrchestrationContext, _):
184184

185185
# Start a worker, which will connect to the sidecar in a background thread
186186
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
187-
taskhub=taskhub_name, token_credential=None) as w:
187+
taskhub=taskhub_name, token_credential=None) as w:
188188
w.add_orchestrator(orchestrator)
189189
w.start()
190190

191191
# Start the orchestration and immediately raise events to it.
192192
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
193-
taskhub=taskhub_name, token_credential=None)
193+
taskhub=taskhub_name, token_credential=None)
194194
id = task_hub_client.schedule_new_orchestration(orchestrator)
195195
task_hub_client.raise_orchestration_event(id, 'A', data='a')
196196
task_hub_client.raise_orchestration_event(id, 'B', data='b')
@@ -285,12 +285,12 @@ def orchestrator(ctx: task.OrchestrationContext, _):
285285

286286
# Start a worker, which will connect to the sidecar in a background thread
287287
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
288-
taskhub=taskhub_name, token_credential=None) as w:
288+
taskhub=taskhub_name, token_credential=None) as w:
289289
w.add_orchestrator(orchestrator)
290290
w.start()
291291

292292
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
293-
taskhub=taskhub_name, token_credential=None)
293+
taskhub=taskhub_name, token_credential=None)
294294
id = task_hub_client.schedule_new_orchestration(orchestrator)
295295
state = task_hub_client.wait_for_orchestration_start(id, timeout=30)
296296
assert state is not None
@@ -302,23 +302,25 @@ def orchestrator(ctx: task.OrchestrationContext, _):
302302
assert state.runtime_status == client.OrchestrationStatus.TERMINATED
303303
assert state.serialized_output == json.dumps("some reason for termination")
304304

305+
305306
def test_terminate_recursive():
306307
def root(ctx: task.OrchestrationContext, _):
307308
result = yield ctx.call_sub_orchestrator(child)
308309
return result
310+
309311
def child(ctx: task.OrchestrationContext, _):
310312
result = yield ctx.wait_for_external_event("my_event")
311313
return result
312314

313315
# Start a worker, which will connect to the sidecar in a background thread
314316
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
315-
taskhub=taskhub_name, token_credential=None) as w:
317+
taskhub=taskhub_name, token_credential=None) as w:
316318
w.add_orchestrator(root)
317319
w.add_orchestrator(child)
318320
w.start()
319321

320322
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
321-
taskhub=taskhub_name, token_credential=None)
323+
taskhub=taskhub_name, token_credential=None)
322324
id = task_hub_client.schedule_new_orchestration(root)
323325
state = task_hub_client.wait_for_orchestration_start(id, timeout=30)
324326
assert state is not None
@@ -331,7 +333,7 @@ def child(ctx: task.OrchestrationContext, _):
331333
assert state.runtime_status == client.OrchestrationStatus.TERMINATED
332334

333335
# Verify that child orchestration is also terminated
334-
c = task_hub_client.wait_for_orchestration_completion(id, timeout=30)
336+
task_hub_client.wait_for_orchestration_completion(id, timeout=30)
335337
assert state is not None
336338
assert state.runtime_status == client.OrchestrationStatus.TERMINATED
337339

@@ -417,14 +419,14 @@ def throw_activity_with_retry(ctx: task.ActivityContext, _):
417419
raise RuntimeError("Kah-BOOOOM!!!")
418420

419421
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
420-
taskhub=taskhub_name, token_credential=None) as w:
422+
taskhub=taskhub_name, token_credential=None) as w:
421423
w.add_orchestrator(parent_orchestrator_with_retry)
422424
w.add_orchestrator(child_orchestrator_with_retry)
423425
w.add_activity(throw_activity_with_retry)
424426
w.start()
425427

426428
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
427-
taskhub=taskhub_name, token_credential=None)
429+
taskhub=taskhub_name, token_credential=None)
428430
id = task_hub_client.schedule_new_orchestration(parent_orchestrator_with_retry)
429431
state = task_hub_client.wait_for_orchestration_completion(id, timeout=30)
430432
assert state is not None
@@ -460,13 +462,13 @@ def throw_activity(ctx: task.ActivityContext, _):
460462
raise RuntimeError("Kah-BOOOOM!!!")
461463

462464
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
463-
taskhub=taskhub_name, token_credential=None) as w:
465+
taskhub=taskhub_name, token_credential=None) as w:
464466
w.add_orchestrator(mock_orchestrator)
465467
w.add_activity(throw_activity)
466468
w.start()
467469

468470
task_hub_client = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
469-
taskhub=taskhub_name, token_credential=None)
471+
taskhub=taskhub_name, token_credential=None)
470472
id = task_hub_client.schedule_new_orchestration(mock_orchestrator)
471473
state = task_hub_client.wait_for_orchestration_completion(id, timeout=30)
472474
assert state is not None
@@ -477,19 +479,20 @@ def throw_activity(ctx: task.ActivityContext, _):
477479
assert state.failure_details.stack_trace is not None
478480
assert throw_activity_counter == 4
479481

482+
480483
def test_custom_status():
481484

482485
def empty_orchestrator(ctx: task.OrchestrationContext, _):
483486
ctx.set_custom_status("foobaz")
484487

485488
# Start a worker, which will connect to the sidecar in a background thread
486489
with DurableTaskSchedulerWorker(host_address=endpoint, secure_channel=True,
487-
taskhub=taskhub_name, token_credential=None) as w:
490+
taskhub=taskhub_name, token_credential=None) as w:
488491
w.add_orchestrator(empty_orchestrator)
489492
w.start()
490493

491494
c = DurableTaskSchedulerClient(host_address=endpoint, secure_channel=True,
492-
taskhub=taskhub_name, token_credential=None)
495+
taskhub=taskhub_name, token_credential=None)
493496
id = c.schedule_new_orchestration(empty_orchestrator)
494497
state = c.wait_for_orchestration_completion(id, timeout=30)
495498

tests/durabletask-azuremanaged/test_durabletask_grpc_interceptor.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4-
import threading
54
import unittest
65
from concurrent import futures
76
from importlib.metadata import version
87

98
import grpc
109

1110
from durabletask.azuremanaged.client import DurableTaskSchedulerClient
12-
from durabletask.azuremanaged.internal.durabletask_grpc_interceptor import (
13-
DTSDefaultClientInterceptorImpl,
14-
)
1511
from durabletask.internal import orchestrator_service_pb2 as pb
1612
from durabletask.internal import orchestrator_service_pb2_grpc as stubs
1713

1814

1915
class MockTaskHubSidecarServiceServicer(stubs.TaskHubSidecarServiceServicer):
2016
"""Mock implementation of the TaskHubSidecarService for testing."""
21-
17+
2218
def __init__(self):
2319
self.captured_metadata = {}
2420
self.requests_received = 0
25-
21+
2622
def GetInstance(self, request, context):
2723
"""Implementation of GetInstance that captures the metadata."""
2824
# Store all metadata key-value pairs from the context
@@ -38,7 +34,7 @@ def GetInstance(self, request, context):
3834

3935
class TestDurableTaskGrpcInterceptor(unittest.TestCase):
4036
"""Tests for the DTSDefaultClientInterceptorImpl class."""
41-
37+
4238
@classmethod
4339
def setUpClass(cls):
4440
# Start a real gRPC server on a free port
@@ -52,11 +48,11 @@ def setUpClass(cls):
5248

5349
# Start the server in a background thread
5450
cls.server.start()
55-
51+
5652
@classmethod
5753
def tearDownClass(cls):
5854
cls.server.stop(grace=None)
59-
55+
6056
def test_user_agent_metadata_passed_in_request(self):
6157
"""Test that the user agent metadata is correctly passed in gRPC requests."""
6258
# Create a client that connects to our mock server

tests/durabletask/test_orchestration_e2e.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ def orchestrator(ctx: task.OrchestrationContext, _):
278278
assert state.runtime_status == client.OrchestrationStatus.TERMINATED
279279
assert state.serialized_output == json.dumps("some reason for termination")
280280

281+
281282
def test_terminate_recursive():
282283
def root(ctx: task.OrchestrationContext, _):
283284
result = yield ctx.call_sub_orchestrator(child)
284285
return result
286+
285287
def child(ctx: task.OrchestrationContext, _):
286288
result = yield ctx.wait_for_external_event("my_event")
287289
return result
@@ -305,7 +307,7 @@ def child(ctx: task.OrchestrationContext, _):
305307
assert state.runtime_status == client.OrchestrationStatus.TERMINATED
306308

307309
# Verify that child orchestration is also terminated
308-
c = task_hub_client.wait_for_orchestration_completion(id, timeout=30)
310+
task_hub_client.wait_for_orchestration_completion(id, timeout=30)
309311
assert state is not None
310312
assert state.runtime_status == client.OrchestrationStatus.TERMINATED
311313

@@ -445,6 +447,7 @@ def throw_activity(ctx: task.ActivityContext, _):
445447
assert state.failure_details.stack_trace is not None
446448
assert throw_activity_counter == 4
447449

450+
448451
def test_custom_status():
449452

450453
def empty_orchestrator(ctx: task.OrchestrationContext, _):

0 commit comments

Comments
 (0)