Skip to content

Commit 7640db1

Browse files
authored
Merge pull request #113 from lialln/dynamic-timeout
Add support for dynamic timeout and heartbeat in Task state
2 parents 2d1e92e + a0befed commit 7640db1

File tree

5 files changed

+111
-11
lines changed

5 files changed

+111
-11
lines changed

Diff for: src/stepfunctions/steps/compute.py

+8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ def __init__(self, state_id, wait_for_callback=False, **kwargs):
2828
state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine.
2929
wait_for_callback(bool, optional): Boolean value set to `True` if the Task state should wait for callback to resume the operation. (default: False)
3030
timeout_seconds (int, optional): Positive integer specifying timeout for the state in seconds. If the state runs longer than the specified timeout, then the interpreter fails the state with a `States.Timeout` Error Name. (default: 60)
31+
timeout_seconds_path (str, optional): Path specifying the state's timeout value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
3132
heartbeat_seconds (int, optional): Positive integer specifying heartbeat timeout for the state in seconds. This value should be lower than the one specified for `timeout_seconds`. If more time than the specified heartbeat elapses between heartbeats from the task, then the interpreter fails the state with a `States.Timeout` Error Name.
33+
heartbeat_seconds_path (str, optional): Path specifying the state's heartbeat value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
3234
comment (str, optional): Human-readable comment or description. (default: None)
3335
input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$')
3436
parameters (dict, optional): The value of this field becomes the effective input for the state.
@@ -55,7 +57,9 @@ def __init__(self, state_id, wait_for_completion=True, **kwargs):
5557
state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine.
5658
wait_for_completion(bool, optional): Boolean value set to `True` if the Task state should wait for the glue job to complete before proceeding to the next step in the workflow. Set to `False` if the Task state should submit the glue job and proceed to the next step. (default: True)
5759
timeout_seconds (int, optional): Positive integer specifying timeout for the state in seconds. If the state runs longer than the specified timeout, then the interpreter fails the state with a `States.Timeout` Error Name. (default: 60)
60+
timeout_seconds_path (str, optional): Path specifying the state's timeout value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
5861
heartbeat_seconds (int, optional): Positive integer specifying heartbeat timeout for the state in seconds. This value should be lower than the one specified for `timeout_seconds`. If more time than the specified heartbeat elapses between heartbeats from the task, then the interpreter fails the state with a `States.Timeout` Error Name.
62+
heartbeat_seconds_path (str, optional): Path specifying the state's heartbeat value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
5963
comment (str, optional): Human-readable comment or description. (default: None)
6064
input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$')
6165
parameters (dict, optional): The value of this field becomes the effective input for the state.
@@ -82,7 +86,9 @@ def __init__(self, state_id, wait_for_completion=True, **kwargs):
8286
state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine.
8387
wait_for_completion(bool, optional): Boolean value set to `True` if the Task state should wait for the batch job to complete before proceeding to the next step in the workflow. Set to `False` if the Task state should submit the batch job and proceed to the next step. (default: True)
8488
timeout_seconds (int, optional): Positive integer specifying timeout for the state in seconds. If the state runs longer than the specified timeout, then the interpreter fails the state with a `States.Timeout` Error Name. (default: 60)
89+
timeout_seconds_path (str, optional): Path specifying the state's timeout value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
8590
heartbeat_seconds (int, optional): Positive integer specifying heartbeat timeout for the state in seconds. This value should be lower than the one specified for `timeout_seconds`. If more time than the specified heartbeat elapses between heartbeats from the task, then the interpreter fails the state with a `States.Timeout` Error Name.
91+
heartbeat_seconds_path (str, optional): Path specifying the state's heartbeat value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
8692
comment (str, optional): Human-readable comment or description. (default: None)
8793
input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$')
8894
parameters (dict, optional): The value of this field becomes the effective input for the state.
@@ -109,7 +115,9 @@ def __init__(self, state_id, wait_for_completion=True, **kwargs):
109115
state_id (str): State name whose length **must be** less than or equal to 128 unicode characters. State names **must be** unique within the scope of the whole state machine.
110116
wait_for_completion(bool, optional): Boolean value set to `True` if the Task state should wait for the ecs job to complete before proceeding to the next step in the workflow. Set to `False` if the Task state should submit the ecs job and proceed to the next step. (default: True)
111117
timeout_seconds (int, optional): Positive integer specifying timeout for the state in seconds. If the state runs longer than the specified timeout, then the interpreter fails the state with a `States.Timeout` Error Name. (default: 60)
118+
timeout_seconds_path (str, optional): Path specifying the state's timeout value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
112119
heartbeat_seconds (int, optional): Positive integer specifying heartbeat timeout for the state in seconds. This value should be lower than the one specified for `timeout_seconds`. If more time than the specified heartbeat elapses between heartbeats from the task, then the interpreter fails the state with a `States.Timeout` Error Name.
120+
heartbeat_seconds_path (str, optional): Path specifying the state's heartbeat value in seconds from the state input. When resolved, the path must select a field whose value is a positive integer.
113121
comment (str, optional): Human-readable comment or description. (default: None)
114122
input_path (str, optional): Path applied to the state’s raw input to select some or all of it; that selection is used by the state. (default: '$')
115123
parameters (dict, optional): The value of this field becomes the effective input for the state.

Diff for: src/stepfunctions/steps/fields.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#
77
# http://www.apache.org/licenses/LICENSE-2.0
88
#
9-
# or in the "license" file accompanying this file. This file is distributed
10-
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11-
# express or implied. See the License for the specific language governing
9+
# or in the "license" file accompanying this file. This file is distributed
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
# express or implied. See the License for the specific language governing
1212
# permissions and limitations under the License.
1313
from __future__ import absolute_import
1414

@@ -53,9 +53,12 @@ class Field(Enum):
5353
MaxConcurrency = 'max_concurrency'
5454

5555
# Task state fields
56-
Resource = 'resource'
57-
TimeoutSeconds = 'timeout_seconds'
58-
HeartbeatSeconds = 'heartbeat_seconds'
56+
Resource = 'resource'
57+
TimeoutSeconds = 'timeout_seconds'
58+
TimeoutSecondsPath = 'timeout_seconds_path'
59+
HeartbeatSeconds = 'heartbeat_seconds'
60+
HeartbeatSecondsPath = 'heartbeat_seconds_path'
61+
5962

6063
# Retry and catch fields
6164
ErrorEquals = 'error_equals'

0 commit comments

Comments
 (0)