Skip to content

Commit af0e3c2

Browse files
committed
Nitpicks and cleanup
1 parent 552a2dd commit af0e3c2

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.

durabletask-azurefunctions/durabletask/azurefunctions/decorators/durable_app.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3+
34
import base64
45
from functools import wraps
56

@@ -76,7 +77,16 @@ def stub_complete(stub_response):
7677
nonlocal response
7778
response = stub_response
7879
stub.CompleteOrchestratorTask = stub_complete
79-
execution_started_events = [e for e in [e1 for e1 in request.newEvents] + [e2 for e2 in request.pastEvents] if e.HasField("executionStarted")]
80+
execution_started_events = []
81+
for e in request.pastEvents:
82+
if e.HasField("executionStarted"):
83+
execution_started_events.append(e)
84+
for e in request.newEvents:
85+
if e.HasField("executionStarted"):
86+
execution_started_events.append(e)
87+
if len(execution_started_events) == 0:
88+
raise Exception("No ExecutionStarted event found in orchestration request.")
89+
8090
function_name = execution_started_events[-1].executionStarted.name
8191
worker.add_named_orchestrator(function_name, orchestrator_func)
8292
worker._execute_orchestrator(request, stub, None)

durabletask-azurefunctions/durabletask/azurefunctions/internal/azurefunctions_null_stub.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
13

24
from durabletask.internal.ProtoTaskHubSidecarServiceStub import ProtoTaskHubSidecarServiceStub
35

46

57
class AzureFunctionsNullStub(ProtoTaskHubSidecarServiceStub):
6-
"""Missing associated documentation comment in .proto file."""
8+
"""A task hub sidecar stub class that implements all methods as no-ops."""
79

810
def __init__(self):
911
"""Constructor.
10-
11-
Args:
12-
channel: A grpc.Channel.
1312
"""
1413
self.Hello = lambda *args, **kwargs: None
1514
self.StartInstance = lambda *args, **kwargs: None

durabletask-azurefunctions/durabletask/azurefunctions/worker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# Worker class used for Durable Task Scheduler (DTS)
1111
class DurableFunctionsWorker(TaskHubGrpcWorker):
12-
"""TOOD: Docs
12+
"""TODO: Docs
1313
"""
1414

1515
def __init__(self):
@@ -27,6 +27,6 @@ def __init__(self):
2727
self._interceptors = None
2828

2929
def add_named_orchestrator(self, name: str, func):
30-
"""TOOD: Docs
30+
"""TODO: Docs
3131
"""
3232
self._registry.add_named_orchestrator(name, func)

durabletask/internal/ProtoTaskHubSidecarServiceStub.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from typing import Any, Callable
1+
from typing import Callable
22

33

44
class ProtoTaskHubSidecarServiceStub(object):
5-
"""TODO: Docs"""
5+
"""A stub class roughly matching the TaskHubSidecarServiceStub generated from the .proto file.
6+
Used by Azure Functions during orchestration and entity executions to inject custom behavior,
7+
as no real sidecar stub is available.
8+
"""
69

710
def __init__(self):
811
"""Constructor.

0 commit comments

Comments
 (0)