Skip to content

Commit

Permalink
Fix map function used in split and reduce steps
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdevries committed Feb 3, 2025
1 parent f3c7a01 commit 0504b32
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions docs/examples/workflows/use-cases/map_reduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ See the upstream example [here](https://github.com/argoproj/argo-workflows/blob/

os.mkdir("/mnt/out")

part_ids = list(map_(lambda x: str(x), range(num_parts)))
part_ids = list(map(lambda x: str(x), range(num_parts)))
for i, part_id in enumerate(part_ids, start=1):
with open("/mnt/out/" + part_id + ".json", "w") as f:
json.dump({"foo": i}, f)
Expand Down Expand Up @@ -70,7 +70,7 @@ See the upstream example [here](https://github.com/argoproj/argo-workflows/blob/
os.mkdir("/mnt/out")

total = 0
for f in list(map_(lambda x: open("/mnt/in/" + x), os.listdir("/mnt/in"))):
for f in list(map(lambda x: open("/mnt/in/" + x), os.listdir("/mnt/in"))):
result = json.load(f)
total = total + result["bar"]
with open("/mnt/out/total.json", "w") as f:
Expand Down Expand Up @@ -156,7 +156,7 @@ See the upstream example [here](https://github.com/argoproj/argo-workflows/blob/
import os
import sys
os.mkdir('/mnt/out')
part_ids = list(map_(lambda x: str(x), range(num_parts)))
part_ids = list(map(lambda x: str(x), range(num_parts)))
for (i, part_id) in enumerate(part_ids, start=1):
with open('/mnt/out/' + part_id + '.json', 'w') as f:
json.dump({'foo': i}, f)
Expand Down Expand Up @@ -218,7 +218,7 @@ See the upstream example [here](https://github.com/argoproj/argo-workflows/blob/
import os
os.mkdir('/mnt/out')
total = 0
for f in list(map_(lambda x: open('/mnt/in/' + x), os.listdir('/mnt/in'))):
for f in list(map(lambda x: open('/mnt/in/' + x), os.listdir('/mnt/in'))):
result = json.load(f)
total = total + result['bar']
with open('/mnt/out/total.json', 'w') as f:
Expand Down
4 changes: 2 additions & 2 deletions examples/workflows/use_cases/map-reduce.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spec:
import os
import sys
os.mkdir('/mnt/out')
part_ids = list(map_(lambda x: str(x), range(num_parts)))
part_ids = list(map(lambda x: str(x), range(num_parts)))
for (i, part_id) in enumerate(part_ids, start=1):
with open('/mnt/out/' + part_id + '.json', 'w') as f:
json.dump({'foo': i}, f)
Expand Down Expand Up @@ -123,7 +123,7 @@ spec:
import os
os.mkdir('/mnt/out')
total = 0
for f in list(map_(lambda x: open('/mnt/in/' + x), os.listdir('/mnt/in'))):
for f in list(map(lambda x: open('/mnt/in/' + x), os.listdir('/mnt/in'))):
result = json.load(f)
total = total + result['bar']
with open('/mnt/out/total.json', 'w') as f:
Expand Down
4 changes: 2 additions & 2 deletions examples/workflows/use_cases/map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def split(num_parts: int) -> None:

os.mkdir("/mnt/out")

part_ids = list(map_(lambda x: str(x), range(num_parts)))
part_ids = list(map(lambda x: str(x), range(num_parts)))
for i, part_id in enumerate(part_ids, start=1):
with open("/mnt/out/" + part_id + ".json", "w") as f:
json.dump({"foo": i}, f)
Expand Down Expand Up @@ -64,7 +64,7 @@ def reduce() -> None:
os.mkdir("/mnt/out")

total = 0
for f in list(map_(lambda x: open("/mnt/in/" + x), os.listdir("/mnt/in"))):
for f in list(map(lambda x: open("/mnt/in/" + x), os.listdir("/mnt/in"))):
result = json.load(f)
total = total + result["bar"]
with open("/mnt/out/total.json", "w") as f:
Expand Down

0 comments on commit 0504b32

Please sign in to comment.