From 3bee0c66990c1cd9b7e93c19b01dff013aba3cb2 Mon Sep 17 00:00:00 2001 From: Rui Wang Napieralski Date: Thu, 17 Dec 2020 08:26:29 -0800 Subject: [PATCH 1/2] fix:decode binary stderr string before dumping it out --- src/sagemaker_training/process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sagemaker_training/process.py b/src/sagemaker_training/process.py index cce47d10..8ba83326 100644 --- a/src/sagemaker_training/process.py +++ b/src/sagemaker_training/process.py @@ -74,7 +74,7 @@ def check_error(cmd, error_class, capture_error=False, **kwargs): _, stderr = process.communicate() # This will force the stderr to be printed after stdout # If wait is false and cature error is true, we will never see the stderr. - print(stderr) + print(stderr.decode(errors="replace")) return_code = process.poll() else: stderr = None From 3d5e9ae11c09171553250917bf18f66c2de0a050 Mon Sep 17 00:00:00 2001 From: Rui Wang Napieralski Date: Thu, 17 Dec 2020 11:03:00 -0800 Subject: [PATCH 2/2] fix failing test --- test/unit/test_process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/test_process.py b/test/unit/test_process.py index 2dd95910..6704f426 100644 --- a/test/unit/test_process.py +++ b/test/unit/test_process.py @@ -74,7 +74,7 @@ def test_run_bash(log, popen, entry_point_type_script): @patch("subprocess.Popen") @patch("sagemaker_training.logging_config.log_script_invocation") def test_run_python(log, popen, entry_point_type_script): - popen().communicate.return_value = (None, 0) + popen().communicate.return_value = (None, b"this is stderr") with pytest.raises(errors.ExecuteUserScriptError): process.ProcessRunner("launcher.py", ["--lr", "13"], {}).run(capture_error=True)