From 2b6da29b8ed8d6dc4eb459a28382eacc66b58438 Mon Sep 17 00:00:00 2001 From: David Justo Date: Mon, 11 May 2020 18:08:54 +0000 Subject: [PATCH 1/3] enables trivial orchestrators --- azure/durable_functions/orchestrator.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/azure/durable_functions/orchestrator.py b/azure/durable_functions/orchestrator.py index 9172cc9a..74a6c20a 100644 --- a/azure/durable_functions/orchestrator.py +++ b/azure/durable_functions/orchestrator.py @@ -45,9 +45,23 @@ def handle(self, context: DurableOrchestrationContext): the durable extension. """ self.durable_context = context - - self.generator = self.fn(self.durable_context) + self.generator = None suspended = False + + fn_output = self.fn(self.durable_context) + # If `fn_output` is not an Iterator, then the orchestrator + # function does not make use of its context parameter. If so, + # `fn_output` is the return value instead of a generator + if isinstance(fn_output, Iterator): + self.generator = fn_output + + else: + orchestration_state = OrchestratorState( + is_done=True, + output=fn_output, + actions=self.durable_context.actions, + custom_status=self.durable_context.custom_status) + return orchestration_state.to_json_string() try: generation_state = self._generate_next(None) From 017f231aeb4083f8e7514f1dc8c9242b5354106d Mon Sep 17 00:00:00 2001 From: David Justo Date: Mon, 11 May 2020 19:36:07 +0000 Subject: [PATCH 2/3] added flake8-docstring, fixed arg to flake8 ,fixed formatting on noxfile --- noxfile.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/noxfile.py b/noxfile.py index 33589295..a6c9770b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,10 +5,11 @@ def tests(session): # same as pip install -r -requirements.txt session.install("-r", "requirements.txt") session.install("pytest") - session.run("pytest","-v","tests") + session.run("pytest", "-v", "tests") + @nox.session(python="3.7") def lint(session): session.install("flake8") - session.run("flake8","./azure/**py") - + session.install("flake8-docstrings") + session.run("flake8", "./azure/") From b238e370b0f621a255ac4745e2473da6526a935e Mon Sep 17 00:00:00 2001 From: David Justo Date: Mon, 11 May 2020 19:39:53 +0000 Subject: [PATCH 3/3] removed accidental commit from other PR --- azure/durable_functions/orchestrator.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/azure/durable_functions/orchestrator.py b/azure/durable_functions/orchestrator.py index 74a6c20a..9172cc9a 100644 --- a/azure/durable_functions/orchestrator.py +++ b/azure/durable_functions/orchestrator.py @@ -45,23 +45,9 @@ def handle(self, context: DurableOrchestrationContext): the durable extension. """ self.durable_context = context - self.generator = None - suspended = False - - fn_output = self.fn(self.durable_context) - # If `fn_output` is not an Iterator, then the orchestrator - # function does not make use of its context parameter. If so, - # `fn_output` is the return value instead of a generator - if isinstance(fn_output, Iterator): - self.generator = fn_output - else: - orchestration_state = OrchestratorState( - is_done=True, - output=fn_output, - actions=self.durable_context.actions, - custom_status=self.durable_context.custom_status) - return orchestration_state.to_json_string() + self.generator = self.fn(self.durable_context) + suspended = False try: generation_state = self._generate_next(None)