Skip to content

Commit 0bbffe2

Browse files
Merge pull request #84 from eecs485staff/is_executable_take_args
Give partitioner an arg for `is_executable()`
2 parents b3353e7 + da3a0ac commit 0bbffe2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

madoop/mapreduce.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ def mapreduce(
4343
# Executable scripts must have valid shebangs
4444
is_executable(map_exe)
4545
is_executable(reduce_exe)
46+
# The partitioner executable expects to receive num_reducers as an arg
4647
if partitioner:
47-
is_executable(partitioner)
48+
is_executable(partitioner, str(num_reducers))
4849

4950
# Create a tmp directory which will be automatically cleaned up
5051
with tempfile.TemporaryDirectory(prefix="madoop-") as tmpdir:
@@ -157,7 +158,7 @@ def normalize_input_paths(input_path):
157158
return input_paths
158159

159160

160-
def is_executable(exe):
161+
def is_executable(exe, *args):
161162
"""Verify exe is executable and raise exception if it is not.
162163
163164
Execute exe with an empty string input and verify that it returns zero. We
@@ -168,7 +169,7 @@ def is_executable(exe):
168169
exe = pathlib.Path(exe).resolve()
169170
try:
170171
subprocess.run(
171-
str(exe),
172+
[str(exe), *args],
172173
shell=False,
173174
input="".encode(),
174175
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)