@@ -43,6 +43,8 @@ def mapreduce(
4343 # Executable scripts must have valid shebangs
4444 is_executable (map_exe )
4545 is_executable (reduce_exe )
46+ if partitioner :
47+ is_executable (partitioner )
4648
4749 # Create a tmp directory which will be automatically cleaned up
4850 with tempfile .TemporaryDirectory (prefix = "madoop-" ) as tmpdir :
@@ -173,7 +175,13 @@ def is_executable(exe):
173175 stderr = subprocess .PIPE ,
174176 check = True ,
175177 )
176- except (subprocess .CalledProcessError , OSError ) as err :
178+ except subprocess .CalledProcessError as err :
179+ raise MadoopError (
180+ f"Failed executable test: { err } "
181+ f"\n { err .stdout .decode ()} " if err .stdout else ""
182+ f"{ err .stderr .decode ()} " if err .stderr else ""
183+ ) from err
184+ except OSError as err :
177185 raise MadoopError (f"Failed executable test: { err } " ) from err
178186
179187
@@ -198,12 +206,17 @@ def map_single_chunk(exe, input_path, output_path, chunk):
198206 check = True ,
199207 input = chunk ,
200208 stdout = outfile ,
209+ stderr = subprocess .PIPE
201210 )
202211 except subprocess .CalledProcessError as err :
203212 raise MadoopError (
204213 f"Command returned non-zero: "
205- f"{ exe } < { input_path } > { output_path } "
214+ f"{ exe } < { input_path } > { output_path } \n "
215+ f"{ err } "
216+ f"\n { err .stderr .decode ()} " if err .stderr else ""
206217 ) from err
218+ except OSError as err :
219+ raise MadoopError (f"Command returned non-zero: { err } " ) from err
207220
208221
209222def map_stage (exe , input_dir , output_dir ):
@@ -300,6 +313,7 @@ def partition_keys_custom(
300313 [partitioner , str (num_reducers )],
301314 stdin = stack .enter_context (inpath .open ()),
302315 stdout = subprocess .PIPE ,
316+ stderr = subprocess .PIPE ,
303317 text = True ,
304318 ))
305319 for line , partition in zip (
@@ -326,8 +340,10 @@ def partition_keys_custom(
326340
327341 return_code = process .wait ()
328342 if return_code :
343+ stderr_output = process .stderr .read ()
329344 raise MadoopError (
330- f"Partition executable returned non-zero: { str (partitioner )} "
345+ f"Partition executable returned non-zero: { str (partitioner )} \n "
346+ f"{ stderr_output } "
331347 )
332348
333349
@@ -419,12 +435,17 @@ def reduce_single_file(exe, input_path, output_path):
419435 check = True ,
420436 stdin = infile ,
421437 stdout = outfile ,
438+ stderr = subprocess .PIPE
422439 )
423440 except subprocess .CalledProcessError as err :
424441 raise MadoopError (
425442 f"Command returned non-zero: "
426- f"{ exe } < { input_path } > { output_path } "
443+ f"{ exe } < { input_path } > { output_path } \n "
444+ f"{ err } "
445+ f"\n { err .stderr .decode ()} " if err .stderr else ""
427446 ) from err
447+ except OSError as err :
448+ raise MadoopError (f"Command returned non-zero: { err } " ) from err
428449
429450
430451def reduce_stage (exe , input_dir , output_dir ):
0 commit comments