Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
Signed-off-by: Mukundan Sundararajan <[email protected]>
  • Loading branch information
mukundansundar committed Dec 20, 2023
1 parent 29bcbb7 commit c95e8b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 4 additions & 3 deletions ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(

Check warning on line 235 in ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py

View check run for this annotation

Codecov / codecov/patch

ext/dapr-ext-workflow/dapr/ext/workflow/workflow_runtime.py#L235

Added line #L235 was not covered by tests
f'Function {fn.__name__} already has an alternate name {fn._alternate_name}')
fn.__dict__['_alternate_name'] = name if name else fn.__name__

@wraps(fn)
Expand All @@ -243,4 +244,4 @@ def innerfn(*args, **kwargs):
innerfn.__signature__ = inspect.signature(fn)
return innerfn

return wrapper
return wrapper
6 changes: 1 addition & 5 deletions ext/dapr-ext-workflow/tests/test_workflow_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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}')

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c95e8b7

Please sign in to comment.