From c95e8b7b9191c305bf9ed728a285854cac81bd32 Mon Sep 17 00:00:00 2001 From: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:00:46 +0530 Subject: [PATCH] fix linter Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com> --- .../dapr/ext/workflow/workflow_runtime.py | 7 ++++--- ext/dapr-ext-workflow/tests/test_workflow_runtime.py | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py b/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py index ff1534e2..ca1a5fed 100644 --- a/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py +++ b/ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py @@ -97,7 +97,6 @@ def activityWrapper(ctx: task.ActivityContext, inp: Optional[TInput] = None): else: fn.__dict__['_alternate_name'] = name if name else fn.__name__ - self.__worker._registry.add_named_activity(fn.__dict__['_alternate_name'], activityWrapper) fn.__dict__['_activity_registered'] = True @@ -202,6 +201,7 @@ def innerfn(): return wrapper + def alternate_name(name: Optional[str] = None): """Decorator to register a workflow or activity function with an alternate name. @@ -232,7 +232,8 @@ def add(ctx, x: int, y: int) -> int: def wrapper(fn: any): if hasattr(fn, '_alternate_name'): - raise ValueError(f'Function {fn.__name__} already has an alternate name {fn._alternate_name}') + raise ValueError( + f'Function {fn.__name__} already has an alternate name {fn._alternate_name}') fn.__dict__['_alternate_name'] = name if name else fn.__name__ @wraps(fn) @@ -243,4 +244,4 @@ def innerfn(*args, **kwargs): innerfn.__signature__ = inspect.signature(fn) return innerfn - return wrapper \ No newline at end of file + return wrapper diff --git a/ext/dapr-ext-workflow/tests/test_workflow_runtime.py b/ext/dapr-ext-workflow/tests/test_workflow_runtime.py index af080f01..a08de7f3 100644 --- a/ext/dapr-ext-workflow/tests/test_workflow_runtime.py +++ b/ext/dapr-ext-workflow/tests/test_workflow_runtime.py @@ -15,8 +15,6 @@ from typing import List import unittest -import logging -import inspect from dapr.ext.workflow.dapr_workflow_context import DaprWorkflowContext from unittest import mock from dapr.ext.workflow.workflow_runtime import WorkflowRuntime, alternate_name @@ -37,7 +35,6 @@ def add_named_activity(self, name: str, fn): class WorkflowRuntimeTest(unittest.TestCase): def setUp(self): - self.log = logging.getLogger(__name__) listActivities.clear() listOrchestrators.clear() mock.patch('durabletask.worker._Registry', return_value=FakeTaskHubGrpcWorker()).start() @@ -51,7 +48,6 @@ def setUp(self): if hasattr(self.mock_client_activity, "_activity_registered"): del self.mock_client_activity.__dict__["_activity_registered"] - def mock_client_wf(ctx: DaprWorkflowContext, input): print(f'{input}') @@ -129,7 +125,7 @@ def test_duplicate_alternate_name_registration(self): with self.assertRaises(ValueError) as exeception_context: (self.runtime_options.activity(name="random"))(client_act) self.assertEqual(exeception_context.exception.args[0], - f'Activity {client_act.__name__} already has an alternate name test') + f'Activity {client_act.__name__} already has an alternate name test') def test_register_wf_act_using_both_decorator_and_method_without_name(self): client_wf = (self.runtime_options.workflow())(self.mock_client_wf)