Skip to content

Commit e3de88f

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 0e96246 commit e3de88f

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
@@ -45,42 +45,43 @@ class WorkflowExecutionDoesNotExist(DoesNotExistError):
4545
class WorkflowType(BaseModel):
4646
"""Simple Workflow Type wrapper
4747
48-
:param domain: Domain the workflow type should be registered in
49-
:type domain: swf.models.Domain
48+
:ivar domain: Domain the workflow type should be registered in
49+
:type domain: swf.models.Domain
5050
51-
:param name: name of the workflow type
52-
:type name: str
51+
:ivar name: name of the workflow type
52+
:type name: str
5353
54-
:param version: workflow type version
55-
:type version: str
54+
:ivar version: workflow type version
55+
:type version: str
5656
57-
:param status: workflow type status
58-
:type status: swf.core.ConnectedSWFObject.{REGISTERED, DEPRECATED}
57+
:ivar status: workflow type status
58+
:type status: swf.core.ConnectedSWFObject.{REGISTERED, DEPRECATED}
5959
60-
:param creation_date: creation date of the current WorkflowType (timestamp)
61-
:type creation_date: float
60+
:ivar creation_date: creation date of the current WorkflowType (timestamp)
61+
:type creation_date: float
6262
63-
:param deprecation_date: deprecation date of WorkflowType (timestamp)
64-
:type deprecation_date: float
63+
:ivar deprecation_date: deprecation date of WorkflowType (timestamp)
64+
:type deprecation_date: float
6565
66-
:param task_list: task list to use for scheduling decision tasks for executions
66+
:ivar task_list: task list to use for scheduling decision tasks for executions
6767
of this workflow type
68-
:type task_list: str
68+
:type task_list: str
6969
70-
:param child_policy: policy to use for the child workflow executions
70+
:ivar child_policy: policy to use for the child workflow executions
7171
when a workflow execution of this type is terminated
72-
:type child_policy: CHILD_POLICIES.{TERMINATE |
73-
REQUEST_CANCEL |
74-
ABANDON}
72+
:type child_policy: CHILD_POLICIES
7573
76-
:param execution_timeout: maximum duration for executions of this workflow type
77-
:type execution_timeout: str
74+
:ivar execution_timeout: maximum duration for executions of this workflow type
75+
:type execution_timeout: str
7876
79-
:param decision_tasks_timeout: maximum duration of decision tasks for this workflow type
80-
:type decision_tasks_timeout: str
77+
:ivar decision_tasks_timeout: maximum duration of decision tasks for this workflow type
78+
:type decision_tasks_timeout: str
8179
82-
:param description: Textual description of the workflow type
83-
:type description: str
80+
:ivar description: Textual description of the workflow type
81+
:type description: str
82+
83+
:ivar lambda_role: Lambda role
84+
:type lambda_role: str
8485
"""
8586
__slots__ = [
8687
'domain',
@@ -166,7 +167,7 @@ def _diff(self):
166167
('deprecation_date', self.deprecation_date, workflow_info['deprecationDate']),
167168
('task_list', self.task_list, workflow_config['defaultTaskList']['name']),
168169
('child_policy', self.child_policy, workflow_config['defaultChildPolicy']),
169-
('lambda_role', self.lambda_role, workflow_config['defaultLambdaRole']),
170+
('lambda_role', self.lambda_role, workflow_config.get('defaultLambdaRole')),
170171
('execution_timeout', self.execution_timeout, workflow_config['defaultExecutionStartToCloseTimeout']),
171172
('decision_tasks_timeout', self.decision_tasks_timeout, workflow_config['defaultTaskStartToCloseTimeout']),
172173
('description', self.description, workflow_info['description']),
@@ -194,7 +195,7 @@ def exists(self):
194195
def save(self):
195196
"""Creates the workflow type amazon side"""
196197
try:
197-
self.my_register_workflow_type(
198+
self.custom_register_workflow_type(
198199
self.domain.name,
199200
self.name,
200201
self.version,
@@ -272,7 +273,7 @@ def start_execution(self, workflow_id=None, task_list=None,
272273
if tag_list and len(tag_list) > 5:
273274
raise ValueError("You cannot have more than 5 tags in StartWorkflowExecution.")
274275

275-
run_id = self.my_start_workflow_execution(
276+
run_id = self.custom_start_workflow_execution(
276277
self.domain.name,
277278
workflow_id,
278279
self.name,
@@ -288,13 +289,13 @@ def start_execution(self, workflow_id=None, task_list=None,
288289

289290
return WorkflowExecution(self.domain, workflow_id, run_id=run_id)
290291

291-
def my_register_workflow_type(self, domain, name, version,
292-
task_list=None,
293-
default_child_policy=None,
294-
default_execution_start_to_close_timeout=None,
295-
default_task_start_to_close_timeout=None,
296-
default_lambda_role=None,
297-
description=None):
292+
def custom_register_workflow_type(self, domain, name, version,
293+
task_list=None,
294+
default_child_policy=None,
295+
default_execution_start_to_close_timeout=None,
296+
default_task_start_to_close_timeout=None,
297+
default_lambda_role=None,
298+
description=None):
298299
"""
299300
Registers a new workflow type and its configuration settings
300301
in the specified domain.
@@ -374,13 +375,13 @@ def my_register_workflow_type(self, domain, name, version,
374375
'description': description,
375376
})
376377

377-
def my_start_workflow_execution(self, domain, workflow_id,
378-
workflow_name, workflow_version,
379-
task_list=None, child_policy=None,
380-
execution_start_to_close_timeout=None,
381-
input=None, tag_list=None,
382-
task_start_to_close_timeout=None,
383-
lambda_role=None):
378+
def custom_start_workflow_execution(self, domain, workflow_id,
379+
workflow_name, workflow_version,
380+
task_list=None, child_policy=None,
381+
execution_start_to_close_timeout=None,
382+
input=None, tag_list=None,
383+
task_start_to_close_timeout=None,
384+
lambda_role=None):
384385
"""
385386
Starts an execution of the workflow type in the specified
386387
domain using the provided workflowId and input data.
@@ -619,7 +620,7 @@ def _diff(self):
619620
('status', self.status, execution_info['executionStatus']),
620621
('task_list', self.task_list, execution_config['taskList']['name']),
621622
('child_policy', self.child_policy, execution_config['childPolicy']),
622-
('lambda_role', self.lambda_role, execution_config['lambdaRole']),
623+
('lambda_role', self.lambda_role, execution_config.get('lambdaRole')),
623624
('execution_timeout', self.execution_timeout, execution_config['executionStartToCloseTimeout']),
624625
('tag_list', self.tag_list, execution_info.get('tagList')),
625626
('decision_tasks_timeout', self.decision_tasks_timeout, execution_config['taskStartToCloseTimeout']),

0 commit comments

Comments
 (0)