Skip to content

Commit fdd8278

Browse files
authored
Merge pull request #226 from Azure/dev
Promote dev to master for v1.0.0b11 release
2 parents 0b805d8 + af482d2 commit fdd8278

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

azure/durable_functions/models/actions/CallActivityWithRetryAction.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
from json import dumps
12
from typing import Dict, Union
23

34
from .Action import Action
45
from .ActionType import ActionType
56
from ..RetryOptions import RetryOptions
67
from ..utils.json_utils import add_attrib, add_json_attrib
8+
from azure.functions._durable_functions import _serialize_custom_object
79

810

911
class CallActivityWithRetryAction(Action):
@@ -16,7 +18,7 @@ def __init__(self, function_name: str,
1618
retry_options: RetryOptions, input_=None):
1719
self.function_name: str = function_name
1820
self.retry_options: RetryOptions = retry_options
19-
self.input_ = input_
21+
self.input_ = dumps(input_, default=_serialize_custom_object)
2022

2123
if not self.function_name:
2224
raise ValueError("function_name cannot be empty")

tests/orchestrator/test_retries.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from tests.test_utils.ContextBuilder import ContextBuilder
2+
from tests.test_utils.testClasses import SerializableClass
23
from azure.durable_functions.models.RetryOptions import RetryOptions
34
from azure.durable_functions.models.OrchestratorState import OrchestratorState
45
from azure.durable_functions.models.DurableOrchestrationContext import DurableOrchestrationContext
@@ -42,6 +43,38 @@ def generator_function(context: DurableOrchestrationContext):
4243

4344
return outputs
4445

46+
47+
def generator_function_with_serialization(context: DurableOrchestrationContext):
48+
"""Orchestrator function for testing retry'ing with serializable input arguments.
49+
50+
Parameters
51+
----------
52+
context: DurableOrchestrationContext
53+
Durable orchestration context, exposes the Durable API
54+
55+
Returns
56+
-------
57+
List[str]:
58+
Output of activities, a list of hello'd cities
59+
"""
60+
61+
outputs = []
62+
63+
retry_options = RETRY_OPTIONS
64+
task1 = yield context.call_activity_with_retry(
65+
"Hello", retry_options, SerializableClass("Tokyo"))
66+
task2 = yield context.call_activity_with_retry(
67+
"Hello", retry_options, SerializableClass("Seatlle"))
68+
task3 = yield context.call_activity_with_retry(
69+
"Hello", retry_options, SerializableClass("London"))
70+
71+
outputs.append(task1)
72+
outputs.append(task2)
73+
outputs.append(task3)
74+
75+
return outputs
76+
77+
4578
def get_context_with_retries_and_corrupted_completion() -> ContextBuilder:
4679
"""Get a ContextBuilder whose history contains a late completion event
4780
for an event that already failed.
@@ -267,4 +300,18 @@ def test_retries_can_fail():
267300
error_msg = f"{REASONS} \n {DETAILS}"
268301

269302
expected_error_str = f"{error_msg}{error_label}"
270-
assert str.startswith(error_str, expected_error_str)
303+
assert str.startswith(error_str, expected_error_str)
304+
305+
def test_retries_with_serializable_input():
306+
"""Tests that retried tasks work with serialized input classes."""
307+
context = get_context_with_retries()
308+
309+
result_1 = get_orchestration_state_result(
310+
context, generator_function)
311+
312+
result_2 = get_orchestration_state_result(
313+
context, generator_function_with_serialization)
314+
315+
assert "output" in result_1
316+
assert "output" in result_2
317+
assert result_1["output"] == result_2["output"]

0 commit comments

Comments
 (0)