Skip to content
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

fix python3 string/bytes error when using --printLogs #3005

Merged
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
11 changes: 11 additions & 0 deletions src/toil/test/cwl/alwaysfails.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env cwl-runner
# Command that will always fail
cwlVersion: v1.0
class: CommandLineTool
baseCommand: invalidcommand
inputs:
message:
type: string
inputBinding:
position: 1
outputs: []
17 changes: 17 additions & 0 deletions src/toil/test/utils/utilsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from toil.common import Toil, Config
from toil.provisioners import clusterFactory
from toil.version import python
from mock import patch

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -387,6 +388,22 @@ def testGetStatusSuccessfulCWLWF(self):
wf.wait()
self.check_status('COMPLETED', status_fn=ToilStatus.getStatus)

@needs_cwl
@needs_docker
@patch('builtins.print')
def testPrintJobLog(self, mock_print):
"""Test that ToilStatus.printJobLog() reads the log from a failed command without error."""
# Run a workflow that will always fail
cmd = ['toil-cwl-runner', '--jobStore', self.toilDir, '--clean=never',
'src/toil/test/cwl/alwaysfails.cwl', '--message', 'Testing']
wf = subprocess.Popen(cmd)
wf.wait()
# print log and check output
status = ToilStatus(self.toilDir)
status.printJobLog()
args, kwargs = mock_print.call_args
self.assertIn('LOG_FILE_OF_JOB', args[0])


def printUnicodeCharacter():
# We want to get a unicode character to stdout but we can't print it directly because of
Expand Down
2 changes: 1 addition & 1 deletion src/toil/utils/toilStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def printJobLog(self):
if job.logJobStoreFileID is not None:
msg = "LOG_FILE_OF_JOB:%s LOG: =======>\n" % job
with job.getLogFileHandle(self.jobStore) as fH:
msg += fH.read()
msg += fH.read().decode('utf-8')
msg += "<========="
else:
msg = "LOG_FILE_OF_JOB:%s LOG: Job has no log file" % job
Expand Down