Skip to content

Commit

Permalink
Switch tasks with run.
Browse files Browse the repository at this point in the history
Just some changes in the naming. Passing `tasks=` does not really reflect the fact
that we are passing a runner. So instead, we will be using `run` (which is self explanatory)

@rantonmattei
  • Loading branch information
xethorn committed Feb 18, 2015
1 parent bf35e99 commit 7651a59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions garcon/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ def run(self):
return True

def execute_activity(self, context):
"""Execute the tasks within the activity.
"""Execute the runner.
Args:
context (dict): The flow context.
"""

return self.tasks.execute(self, context)
return self.runner.execute(self, context)

def hydrate(self, data):
"""Hydrate the task with information provided.
Expand All @@ -169,7 +169,13 @@ def hydrate(self, data):
self.requires = getattr(self, 'requires', []) or data.get('requires')
self.retry = getattr(self, 'retry', None) or data.get('retry', 0)
self.task_list = self.task_list or data.get('task_list')
self.tasks = getattr(self, 'tasks', []) or data.get('tasks')

# The previous way to create an activity was to fill a `tasks` param,
# which is not `run`.
self.runner = (
getattr(self, 'runner', None) or
data.get('run') or data.get('tasks'))

self.generators = getattr(
self, 'generators', None) or data.get('generators')

Expand Down Expand Up @@ -221,7 +227,7 @@ def timeout(self):
int: Task list timeout.
"""

return self.tasks.timeout
return self.runner.timeout


class ActivityWorker():
Expand Down Expand Up @@ -289,7 +295,8 @@ def wrapper(**options):
requires=options.get('requires', []),
retry=options.get('retry'),
task_list=domain + '_' + options.get('name'),
tasks=options.get('tasks', [])
tasks=options.get('tasks'),
run=options.get('run'),
))
return activity
return wrapper
Expand Down
2 changes: 1 addition & 1 deletion tests/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_execute_activity(monkeypatch):
custom_task = MagicMock(return_value=resp)

current_activity = activity.Activity()
current_activity.tasks = runner.Sync(custom_task)
current_activity.runner = runner.Sync(custom_task)

val = current_activity.execute_activity(dict(foo='bar'))

Expand Down

0 comments on commit 7651a59

Please sign in to comment.