Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f16041b

Browse files
authoredOct 15, 2021
Merge branch 'main' into support-placeholders-for-transform-step
2 parents d575518 + 5f73cf7 commit f16041b

File tree

8 files changed

+409
-66
lines changed

8 files changed

+409
-66
lines changed
 

‎.github/ISSUE_TEMPLATE/bug.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: "\U0001F41B Bug Report"
3+
about: Report a bug
4+
title: "short issue description"
5+
labels: bug, needs-triage
6+
---
7+
8+
<!--
9+
description of the bug:
10+
-->
11+
12+
13+
14+
15+
### Reproduction Steps
16+
17+
<!--
18+
minimal amount of code that causes the bug (if possible) or a reference.
19+
20+
The code sample should be an SSCCE. See http://sscce.org/ for details.
21+
In short, provide a code sample that we can copy/paste, run and reproduce.
22+
-->
23+
24+
### What did you expect to happen?
25+
26+
<!--
27+
What were you trying to achieve by performing the steps above?
28+
-->
29+
30+
### What actually happened?
31+
32+
<!--
33+
What is the unexpected behavior you were seeing? If you got an error, paste it here.
34+
-->
35+
36+
37+
### Environment
38+
39+
- **AWS Step Functions Data Science Python SDK version :**
40+
- **Python Version:** <!-- Version of Python (run the command `python3 --version`) -->
41+
42+
### Other
43+
44+
<!-- e.g. detailed explanation, stack-traces, related issues, suggestions on how to fix, links for us to have context, eg. associated pull-request, stackoverflow, slack, etc -->
45+
46+
47+
48+
49+
---
50+
51+
This is :bug: Bug Report

‎.github/ISSUE_TEMPLATE/doc.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: "📕 Documentation Issue"
3+
about: Issue in the reference documentation
4+
title: "short issue description"
5+
labels: feature-request, documentation, needs-triage
6+
---
7+
8+
<!--
9+
- want to help? submit a pull request! docs can be found here: https://github.com/aws/aws-step-functions-data-science-sdk-python/tree/main/doc
10+
-->
11+
12+
<!--
13+
link to reference doc page:
14+
-->
15+
16+
17+
18+
<!--
19+
describe your issue:
20+
-->
21+
22+
23+
24+
25+
26+
---
27+
28+
This is a 📕 documentation issue
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: "\U0001F680 Feature Request"
3+
about: Request a new feature
4+
title: "short issue description"
5+
labels: feature-request, needs-triage
6+
---
7+
8+
<!-- short description of the feature you are proposing: -->
9+
10+
11+
12+
13+
14+
### Use Case
15+
16+
<!-- why do you need this feature? -->
17+
18+
19+
20+
21+
22+
### Proposed Solution
23+
24+
<!-- Please include prototype/workaround/sketch/reference implementation: -->
25+
26+
27+
28+
29+
30+
### Other
31+
32+
<!--
33+
e.g. detailed explanation, stacktraces, related issues, suggestions on how to fix,
34+
links for us to have context, eg. associated pull-request, stackoverflow, slack, etc
35+
-->
36+
37+
38+
39+
40+
41+
* [ ] :wave: I may be able to implement this feature request
42+
* [ ] :warning: This feature might incur a breaking change
43+
44+
---
45+
46+
This is a :rocket: Feature Request

‎.github/pull_request_template.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
### Description
2+
3+
Please include a summary of the change being made.
4+
5+
Fixes #(issue)
6+
7+
### Why is the change necessary?
8+
9+
What capability does it enable? What problem does it solve?
10+
11+
### Solution
12+
13+
Please include an overview of the solution. Discuss trade-offs made, caveats, alternatives, etc.
14+
15+
### Testing
16+
17+
How was this change tested?
18+
19+
----
20+
21+
### Pull Request Checklist
22+
23+
Please check all boxes (including N/A items)
24+
25+
#### Testing
26+
27+
- [ ] Unit tests added
28+
- [ ] Integration test added
29+
- [ ] Manual testing - why was it necessary? could it be automated?
30+
31+
#### Documentation
32+
33+
- [ ] __docs__: All relevant [docs](https://github.com/aws/aws-step-functions-data-science-sdk-python/tree/main/doc) updated
34+
- [ ] __docstrings__: All public APIs documented
35+
36+
### Title and description
37+
38+
- [ ] __Change type__: Title is prefixed with change type: and follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
39+
- [ ] __References__: Indicate issues fixed via: `Fixes #xxx`
40+
41+
----
42+
43+
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

‎src/stepfunctions/steps/states.py

+37-11
Original file line numberDiff line numberDiff line change
@@ -254,27 +254,29 @@ def accept(self, visitor):
254254

255255
def add_retry(self, retry):
256256
"""
257-
Add a Retry block to the tail end of the list of retriers for the state.
257+
Add a retrier or a list of retriers to the tail end of the list of retriers for the state.
258+
See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-retrying-after-an-error>`_ for more details.
258259
259260
Args:
260-
retry (Retry): Retry block to add.
261+
retry (Retry or list(Retry)): A retrier or list of retriers to add.
261262
"""
262263
if Field.Retry in self.allowed_fields():
263-
self.retries.append(retry)
264+
self.retries.extend(retry) if isinstance(retry, list) else self.retries.append(retry)
264265
else:
265-
raise ValueError("{state_type} state does not support retry field. ".format(state_type=type(self).__name__))
266+
raise ValueError(f"{type(self).__name__} state does not support retry field. ")
266267

267268
def add_catch(self, catch):
268269
"""
269-
Add a Catch block to the tail end of the list of catchers for the state.
270+
Add a catcher or a list of catchers to the tail end of the list of catchers for the state.
271+
See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-fallback-states>`_ for more details.
270272
271273
Args:
272-
catch (Catch): Catch block to add.
274+
catch (Catch or list(Catch): catcher or list of catchers to add.
273275
"""
274276
if Field.Catch in self.allowed_fields():
275-
self.catches.append(catch)
277+
self.catches.extend(catch) if isinstance(catch, list) else self.catches.append(catch)
276278
else:
277-
raise ValueError("{state_type} state does not support catch field. ".format(state_type=type(self).__name__))
279+
raise ValueError(f"{type(self).__name__} state does not support catch field. ")
278280

279281
def to_dict(self):
280282
result = super(State, self).to_dict()
@@ -487,10 +489,12 @@ class Parallel(State):
487489
A Parallel state causes the interpreter to execute each branch as concurrently as possible, and wait until each branch terminates (reaches a terminal state) before processing the next state in the Chain.
488490
"""
489491

490-
def __init__(self, state_id, **kwargs):
492+
def __init__(self, state_id, retry=None, catch=None, **kwargs):
491493
"""
492494
Args:
493495
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.
496+
retry (Retry or list(Retry), optional): A retrier or list of retriers that define the state's retry policy. See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-retrying-after-an-error>`_ for more details.
497+
catch (Catch or list(Catch), optional): A catcher or list of catchers that define a fallback state. See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-fallback-states>`_ for more details.
494498
comment (str, optional): Human-readable comment or description. (default: None)
495499
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: '$')
496500
parameters (dict, optional): The value of this field becomes the effective input for the state.
@@ -500,6 +504,12 @@ def __init__(self, state_id, **kwargs):
500504
super(Parallel, self).__init__(state_id, 'Parallel', **kwargs)
501505
self.branches = []
502506

507+
if retry:
508+
self.add_retry(retry)
509+
510+
if catch:
511+
self.add_catch(catch)
512+
503513
def allowed_fields(self):
504514
return [
505515
Field.Comment,
@@ -536,11 +546,13 @@ class Map(State):
536546
A Map state can accept an input with a list of items, execute a state or chain for each item in the list, and return a list, with all corresponding results of each execution, as its output.
537547
"""
538548

539-
def __init__(self, state_id, **kwargs):
549+
def __init__(self, state_id, retry=None, catch=None, **kwargs):
540550
"""
541551
Args:
542552
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.
543553
iterator (State or Chain): State or chain to execute for each of the items in `items_path`.
554+
retry (Retry or list(Retry), optional): A retrier or list of retriers that define the state's retry policy. See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-retrying-after-an-error>`_ for more details.
555+
catch (Catch or list(Catch), optional): A catcher or list of catchers that define a fallback state. See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-fallback-states>`_ for more details.
544556
items_path (str, optional): Path in the input for items to iterate over. (default: '$')
545557
max_concurrency (int, optional): Maximum number of iterations to have running at any given point in time. (default: 0)
546558
comment (str, optional): Human-readable comment or description. (default: None)
@@ -551,6 +563,12 @@ def __init__(self, state_id, **kwargs):
551563
"""
552564
super(Map, self).__init__(state_id, 'Map', **kwargs)
553565

566+
if retry:
567+
self.add_retry(retry)
568+
569+
if catch:
570+
self.add_catch(catch)
571+
554572
def attach_iterator(self, iterator):
555573
"""
556574
Attach `State` or `Chain` as iterator to the Map state, that will execute for each of the items in `items_path`. If an iterator was attached previously with the Map state, it will be replaced.
@@ -586,10 +604,12 @@ class Task(State):
586604
Task State causes the interpreter to execute the work identified by the state’s `resource` field.
587605
"""
588606

589-
def __init__(self, state_id, **kwargs):
607+
def __init__(self, state_id, retry=None, catch=None, **kwargs):
590608
"""
591609
Args:
592610
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.
611+
retry (Retry or list(Retry), optional): A retrier or list of retriers that define the state's retry policy. See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-retrying-after-an-error>`_ for more details.
612+
catch (Catch or list(Catch), optional): A catcher or list of catchers that define a fallback state. See `Error handling in Step Functions <https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html#error-handling-fallback-states>`_ for more details.
593613
resource (str): A URI that uniquely identifies the specific task to execute. The States language does not constrain the URI scheme nor any other part of the URI.
594614
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)
595615
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.
@@ -608,6 +628,12 @@ def __init__(self, state_id, **kwargs):
608628
if self.heartbeat_seconds is not None and self.heartbeat_seconds_path is not None:
609629
raise ValueError("Only one of 'heartbeat_seconds' or 'heartbeat_seconds_path' can be provided.")
610630

631+
if retry:
632+
self.add_retry(retry)
633+
634+
if catch:
635+
self.add_catch(catch)
636+
611637
def allowed_fields(self):
612638
return [
613639
Field.Comment,

0 commit comments

Comments
 (0)
Please sign in to comment.