Skip to content

Commit 6c454da

Browse files
committed
Small fixes
* use workflow_config.`get('defaultLambdaRole')` instead of [] (not already present, at least in tests) * rename my_* to custom_* Signed-off-by: Yves Bastide <yves@botify.com>
1 parent beeb6fd commit 6c454da

File tree

2 files changed

+43
-42
lines changed

2 files changed

+43
-42
lines changed

.editorconfig

Whitespace-only changes.

swf/models/workflow.py

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,43 @@ class WorkflowExecutionDoesNotExist(DoesNotExistError):
4646
class WorkflowType(BaseModel):
4747
"""Simple Workflow Type wrapper
4848
49-
:param domain: Domain the workflow type should be registered in
50-
:type domain: swf.models.Domain
49+
:ivar domain: Domain the workflow type should be registered in
50+
:type domain: swf.models.Domain
5151
52-
:param name: name of the workflow type
53-
:type name: str
52+
:ivar name: name of the workflow type
53+
:type name: str
5454
55-
:param version: workflow type version
56-
:type version: str
55+
:ivar version: workflow type version
56+
:type version: str
5757
58-
:param status: workflow type status
59-
:type status: swf.core.ConnectedSWFObject.{REGISTERED, DEPRECATED}
58+
:ivar status: workflow type status
59+
:type status: swf.core.ConnectedSWFObject.{REGISTERED, DEPRECATED}
6060
61-
:param creation_date: creation date of the current WorkflowType (timestamp)
62-
:type creation_date: float
61+
:ivar creation_date: creation date of the current WorkflowType (timestamp)
62+
:type creation_date: float
6363
64-
:param deprecation_date: deprecation date of WorkflowType (timestamp)
65-
:type deprecation_date: float
64+
:ivar deprecation_date: deprecation date of WorkflowType (timestamp)
65+
:type deprecation_date: float
6666
67-
:param task_list: task list to use for scheduling decision tasks for executions
67+
:ivar task_list: task list to use for scheduling decision tasks for executions
6868
of this workflow type
69-
:type task_list: str
69+
:type task_list: str
7070
71-
:param child_policy: policy to use for the child workflow executions
71+
:ivar child_policy: policy to use for the child workflow executions
7272
when a workflow execution of this type is terminated
73-
:type child_policy: CHILD_POLICIES.{TERMINATE |
74-
REQUEST_CANCEL |
75-
ABANDON}
73+
:type child_policy: CHILD_POLICIES
7674
77-
:param execution_timeout: maximum duration for executions of this workflow type
78-
:type execution_timeout: str
75+
:ivar execution_timeout: maximum duration for executions of this workflow type
76+
:type execution_timeout: str
7977
80-
:param decision_tasks_timeout: maximum duration of decision tasks for this workflow type
81-
:type decision_tasks_timeout: str
78+
:ivar decision_tasks_timeout: maximum duration of decision tasks for this workflow type
79+
:type decision_tasks_timeout: str
8280
83-
:param description: Textual description of the workflow type
84-
:type description: str
81+
:ivar description: Textual description of the workflow type
82+
:type description: str
83+
84+
:ivar lambda_role: Lambda role
85+
:type lambda_role: str
8586
"""
8687
__slots__ = [
8788
'domain',
@@ -167,7 +168,7 @@ def _diff(self):
167168
('deprecation_date', self.deprecation_date, workflow_info['deprecationDate']),
168169
('task_list', self.task_list, workflow_config['defaultTaskList']['name']),
169170
('child_policy', self.child_policy, workflow_config['defaultChildPolicy']),
170-
('lambda_role', self.lambda_role, workflow_config['defaultLambdaRole']),
171+
('lambda_role', self.lambda_role, workflow_config.get('defaultLambdaRole')),
171172
('execution_timeout', self.execution_timeout, workflow_config['defaultExecutionStartToCloseTimeout']),
172173
('decision_tasks_timeout', self.decision_tasks_timeout, workflow_config['defaultTaskStartToCloseTimeout']),
173174
('description', self.description, workflow_info['description']),
@@ -195,7 +196,7 @@ def exists(self):
195196
def save(self):
196197
"""Creates the workflow type amazon side"""
197198
try:
198-
self.my_register_workflow_type(
199+
self.custom_register_workflow_type(
199200
self.domain.name,
200201
self.name,
201202
self.version,
@@ -274,7 +275,7 @@ def start_execution(self, workflow_id=None, task_list=None,
274275
if tag_list and len(tag_list) > 5:
275276
raise ValueError("You cannot have more than 5 tags in StartWorkflowExecution.")
276277

277-
run_id = self.my_start_workflow_execution(
278+
run_id = self.custom_start_workflow_execution(
278279
self.domain.name,
279280
workflow_id,
280281
self.name,
@@ -290,13 +291,13 @@ def start_execution(self, workflow_id=None, task_list=None,
290291

291292
return WorkflowExecution(self.domain, workflow_id, run_id=run_id)
292293

293-
def my_register_workflow_type(self, domain, name, version,
294-
task_list=None,
295-
default_child_policy=None,
296-
default_execution_start_to_close_timeout=None,
297-
default_task_start_to_close_timeout=None,
298-
default_lambda_role=None,
299-
description=None):
294+
def custom_register_workflow_type(self, domain, name, version,
295+
task_list=None,
296+
default_child_policy=None,
297+
default_execution_start_to_close_timeout=None,
298+
default_task_start_to_close_timeout=None,
299+
default_lambda_role=None,
300+
description=None):
300301
"""
301302
Registers a new workflow type and its configuration settings
302303
in the specified domain.
@@ -376,13 +377,13 @@ def my_register_workflow_type(self, domain, name, version,
376377
'description': description,
377378
})
378379

379-
def my_start_workflow_execution(self, domain, workflow_id,
380-
workflow_name, workflow_version,
381-
task_list=None, child_policy=None,
382-
execution_start_to_close_timeout=None,
383-
input=None, tag_list=None,
384-
task_start_to_close_timeout=None,
385-
lambda_role=None):
380+
def custom_start_workflow_execution(self, domain, workflow_id,
381+
workflow_name, workflow_version,
382+
task_list=None, child_policy=None,
383+
execution_start_to_close_timeout=None,
384+
input=None, tag_list=None,
385+
task_start_to_close_timeout=None,
386+
lambda_role=None):
386387
"""
387388
Starts an execution of the workflow type in the specified
388389
domain using the provided workflowId and input data.
@@ -621,7 +622,7 @@ def _diff(self):
621622
('status', self.status, execution_info['executionStatus']),
622623
('task_list', self.task_list, execution_config['taskList']['name']),
623624
('child_policy', self.child_policy, execution_config['childPolicy']),
624-
('lambda_role', self.lambda_role, execution_config['lambdaRole']),
625+
('lambda_role', self.lambda_role, execution_config.get('lambdaRole')),
625626
('execution_timeout', self.execution_timeout, execution_config['executionStartToCloseTimeout']),
626627
('tag_list', self.tag_list, execution_info.get('tagList')),
627628
('decision_tasks_timeout', self.decision_tasks_timeout, execution_config['taskStartToCloseTimeout']),

0 commit comments

Comments
 (0)