Skip to content

Commit

Permalink
pretty print params on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
egafni committed Jul 12, 2016
1 parent 38385d7 commit 8f1f283
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cosmos/models/Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .. import TaskStatus, StageStatus, signal_task_status_change
from ..util.helpers import wait_for_file
import datetime
import pprint

opj = os.path.join

Expand All @@ -33,9 +34,10 @@ class GetOutputError(Exception): pass

task_failed_printout = u"""Failure Info:
<EXIT_STATUS="{0.exit_status}">
<COMMAND path="{0.output_command_script_path}" drm_jobID="{0.drm_jobID}"
params="{0.params_pretty}">
<COMMAND path="{0.output_command_script_path}" drm_jobID="{0.drm_jobID}">
<PARAMS>
{0.params_pformat}
</PARAMS>
{0.command_script_text}
</COMMAND>
<STDOUT path="{0.output_stdout_path}">
Expand Down Expand Up @@ -326,8 +328,12 @@ def url(self):
def params_pretty(self):
return '%s' % ', '.join('%s=%s' % (k, "'%s'" % v if isinstance(v, basestring) else v) for k, v in self.params.items())

@property
def params_pformat(self):
return pprint.pformat(self.params, indent=2, width=1)

def __repr__(self):
return '<Task[%s] %s(uid=%s)>' % (self.id or 'id_%s' % id(self),
return "<Task[%s] %s(uid='%s')>" % (self.id or 'id_%s' % id(self),
self.stage.name if self.stage else '',
self.uid
)
Expand Down

0 comments on commit 8f1f283

Please sign in to comment.