Skip to content

StepFunctions: Fix Evaluation of Nested Map Runs #12033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, job_program: Program, job_inputs: list[Any]):

self._jobs_number = len(job_inputs)
self._open_jobs = [
Job(job_index=job_index, job_program=copy.deepcopy(job_program), job_input=job_input)
Job(job_index=job_index, job_program=job_program, job_input=job_input)
for job_index, job_input in enumerate(job_inputs)
]
self._open_jobs.reverse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class ScenariosTemplate(TemplateLoader):
MAP_STATE_NESTED: Final[str] = os.path.join(
_THIS_FOLDER, "statemachines/map_state_nested.json5"
)
MAP_STATE_NESTED_CONFIG_DISTRIBUTED: Final[str] = os.path.join(
_THIS_FOLDER, "statemachines/map_state_nested_config_distributed.json5"
)
MAP_STATE_NO_PROCESSOR_CONFIG: Final[str] = os.path.join(
_THIS_FOLDER, "statemachines/map_state_no_processor_config.json5"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"StartAt": "SetupState",
"States": {
"SetupState": {
"Type": "Pass",
"Result": {
"values": [
{
"sub-values": [
{
"num": 1,
"str": "A"
},
{
"num": 2,
"str": "B"
}
]
}
]
},
"Next": "MapState",
},
"MapState": {
"Type": "Map",
"MaxConcurrency": 1,
"ItemsPath": "$.values",
"ItemProcessor": {
"ProcessorConfig": {
"Mode": "DISTRIBUTED",
"ExecutionType": "STANDARD",
},
"StartAt": "SubMapState",
"States": {
"SubMapState": {
"Type": "Map",
"MaxConcurrency": 1,
"ItemsPath": "$.sub-values",
"ResultPath": "$.result",
"ItemProcessor": {
"ProcessorConfig": {
"Mode": "DISTRIBUTED",
"ExecutionType": "STANDARD",
},
"StartAt": "SubMapStateSuccess",
"States": {
"SubMapStateSuccess": {
"Type": "Succeed"
}
},
},
"End": true,
}
},
},
"End": true,
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,28 @@ def test_map_state_label(
exec_input,
)

@markers.aws.validated
@markers.snapshot.skip_snapshot_verify(paths=["$..events[8].previousEventId"])
def test_map_state_nested_config_distributed(
self,
aws_client,
create_state_machine_iam_role,
create_state_machine,
sfn_snapshot,
):
template = ST.load_sfn_template(ST.MAP_STATE_NESTED_CONFIG_DISTRIBUTED)
definition = json.dumps(template)

exec_input = json.dumps({})
create_and_record_execution(
aws_client,
create_state_machine_iam_role,
create_state_machine,
sfn_snapshot,
definition,
exec_input,
)

@markers.aws.validated
def test_map_state_result_writer(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24895,5 +24895,155 @@
}
}
}
},
"tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_nested_config_distributed": {
"recorded-date": "13-12-2024, 13:38:16",
"recorded-content": {
"get_execution_history": {
"events": [
{
"executionStartedEventDetails": {
"input": {},
"inputDetails": {
"truncated": false
},
"roleArn": "snf_role_arn"
},
"id": 1,
"previousEventId": 0,
"timestamp": "timestamp",
"type": "ExecutionStarted"
},
{
"id": 2,
"previousEventId": 0,
"stateEnteredEventDetails": {
"input": {},
"inputDetails": {
"truncated": false
},
"name": "SetupState"
},
"timestamp": "timestamp",
"type": "PassStateEntered"
},
{
"id": 3,
"previousEventId": 2,
"stateExitedEventDetails": {
"name": "SetupState",
"output": {
"values": [
{
"sub-values": [
{
"num": 1,
"str": "A"
},
{
"num": 2,
"str": "B"
}
]
}
]
},
"outputDetails": {
"truncated": false
}
},
"timestamp": "timestamp",
"type": "PassStateExited"
},
{
"id": 4,
"previousEventId": 3,
"stateEnteredEventDetails": {
"input": {
"values": [
{
"sub-values": [
{
"num": 1,
"str": "A"
},
{
"num": 2,
"str": "B"
}
]
}
]
},
"inputDetails": {
"truncated": false
},
"name": "MapState"
},
"timestamp": "timestamp",
"type": "MapStateEntered"
},
{
"id": 5,
"mapStateStartedEventDetails": {
"length": 1
},
"previousEventId": 4,
"timestamp": "timestamp",
"type": "MapStateStarted"
},
{
"id": 6,
"mapRunStartedEventDetails": {
"mapRunArn": "arn:<partition>:states:<region>:111111111111:mapRun:<ArnPart_0idx>/<MapRunArnPart0_0idx>:<MapRunArnPart1_0idx>"
},
"previousEventId": 5,
"timestamp": "timestamp",
"type": "MapRunStarted"
},
{
"id": 7,
"previousEventId": 6,
"timestamp": "timestamp",
"type": "MapRunSucceeded"
},
{
"id": 8,
"previousEventId": 7,
"timestamp": "timestamp",
"type": "MapStateSucceeded"
},
{
"id": 9,
"previousEventId": 6,
"stateExitedEventDetails": {
"name": "MapState",
"output": "[{\"sub-values\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}],\"result\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}]}]",
"outputDetails": {
"truncated": false
}
},
"timestamp": "timestamp",
"type": "MapStateExited"
},
{
"executionSucceededEventDetails": {
"output": "[{\"sub-values\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}],\"result\":[{\"num\":1,\"str\":\"A\"},{\"num\":2,\"str\":\"B\"}]}]",
"outputDetails": {
"truncated": false
}
},
"id": 10,
"previousEventId": 9,
"timestamp": "timestamp",
"type": "ExecutionSucceeded"
}
],
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@
"tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_nested": {
"last_validated_date": "2024-03-29T16:26:02+00:00"
},
"tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_nested_config_distributed": {
"last_validated_date": "2024-12-13T13:38:16+00:00"
},
"tests/aws/services/stepfunctions/v2/scenarios/test_base_scenarios.py::TestBaseScenarios::test_map_state_no_processor_config": {
"last_validated_date": "2023-12-15T21:25:27+00:00"
},
Expand Down
Loading