Skip to content

Commit

Permalink
Merge pull request #5 from Autodesk/dev
Browse files Browse the repository at this point in the history
Reduce number of server status checks
  • Loading branch information
avirshup authored Aug 1, 2016
2 parents 4054d07 + 19b44b6 commit 7719426
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
20 changes: 14 additions & 6 deletions pyccc/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def __init__(self, engine=None,
self._callback_result = None
self._output_files = None
self.jobid = None
self._stopped = None

if submit and self.engine and self.image: self.submit()

Expand Down Expand Up @@ -140,23 +141,30 @@ def status(self):
"""
Returns status of 'queued', 'running', 'finished' or 'error'
"""
if self.jobid:
return self.engine.get_status(self)
if self._stopped:
return self._stopped
elif self.jobid:
stat = self.engine.get_status(self)
if stat in status.DONE_STATES:
self._stopped = stat
return stat
else:
return "Unsubmitted"


def _finish_job(self):
"""
To be called after job has finished.
Retreives stdout, stderr, and list of available files
:return:
"""
if self._finished: return
if self.status not in status.DONE_STATES:
stat = self.status
if stat not in status.DONE_STATES:
raise pyccc.JobStillRunning(self)
if self.status != status.FINISHED:
raise pyccc.JobErrorState(self, 'Job did not complete successfully (status:%s)' %
self.status)
if stat != status.FINISHED:
raise pyccc.JobErrorState(self, 'Job did not complete successfully (status:%s)'%
stat)
self._output_files = self.engine._list_output_files(self)
self._final_stdout, self._final_stderr = self.engine._get_final_stds(self)
self._finished = True
Expand Down
11 changes: 6 additions & 5 deletions pyccc/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,18 @@ def __init__(self, job, **kwargs):

super(StatusView,self).__init__(**kwargs)
self._job = job
text = ipy.HTML(self.STATUS_STRING % (job.name,
stat = job.status
text = ipy.HTML(self.STATUS_STRING%(job.name,
str(job.engine),
job.jobid,
job.image,
job.command,
job.status))
if job.status == status.QUEUED:
stat))
if stat == status.QUEUED:
bar_spec = dict(value=1, bar_style='danger')
elif job.status == status.RUNNING:
elif stat == status.RUNNING:
bar_spec = dict(value=50, bar_style='info')
elif job.status == status.FINISHED:
elif stat == status.FINISHED:
bar_spec = dict(value=100, bar_style='success')
else:
bar_spec = dict(value=100, bar_style='danger')
Expand Down

0 comments on commit 7719426

Please sign in to comment.