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

[cuegui] Fix issue with jobs changing order (bouncing) when ordered on the JobMonitor plugin #1484

Merged
Merged
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
35 changes: 29 additions & 6 deletions cuegui/cuegui/JobMonitorTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ def displayState(job):
return "Dependency"
return "In Progress"

def sortableKey(key, datetime_key):
"""
Returns a sortable key that sets apart similar keys using time_key

@type key: string or int
@param key: A key used for sorting
@type datetime_key: int
@param datetime_key: Date time represented as an integer
@rtype: string or float
@return: datetime_key appended to key if key is a string,
the 0.datetime_key summed to key if key is an int
"""
if isinstance(key, int) and isinstance(datetime_key, int):
return float(str(key)+"."+str(datetime_key))
return str(key) + str(datetime_key)

class JobMonitorTree(cuegui.AbstractTreeWidget.AbstractTreeWidget):
"""Tree widget to display a list of monitored jobs."""
Expand All @@ -80,6 +95,7 @@ def __init__(self, parent):
self.startColumnsForType(cuegui.Constants.TYPE_JOB)
self.addColumn("Job", 470, id=1,
data=lambda job: job.data.name,
sort=lambda job: sortableKey(job.data.name, job.data.start_time),
tip="The name of the job: show-shot-user_uniqueName")
self.addColumn("_Comment", 20, id=2,
sort=lambda job: job.data.has_comment,
Expand All @@ -93,6 +109,7 @@ def __init__(self, parent):
# pylint: disable=unnecessary-lambda
self.addColumn("State", 80, id=4,
data=lambda job: displayState(job),
sort=lambda job: sortableKey(displayState(job), job.data.start_time),
tip="The state of each job.\n"
"In Progress \t The job is on the queue\n"
"Failing \t The job has dead frames\n"
Expand All @@ -101,28 +118,34 @@ def __init__(self, parent):
self.addColumn("Done/Total", 90, id=5,
data=lambda job: "%d of %d" % (job.data.job_stats.succeeded_frames,
job.data.job_stats.total_frames),
sort=lambda job: job.data.job_stats.succeeded_frames,
sort=lambda job: sortableKey(job.data.job_stats.succeeded_frames,
job.data.start_time),
tip="The number of succeeded frames vs the total number\n"
"of frames in each job.")
self.addColumn("Running", 60, id=6,
data=lambda job: job.data.job_stats.running_frames,
sort=lambda job: job.data.job_stats.running_frames,
sort=lambda job: sortableKey(job.data.job_stats.running_frames,
job.data.start_time),
tip="The number of running frames in each job,")
self.addColumn("Dead", 50, id=7,
data=lambda job: job.data.job_stats.dead_frames,
sort=lambda job: job.data.job_stats.dead_frames,
sort=lambda job: sortableKey(job.data.job_stats.dead_frames,
job.data.start_time),
tip="Total number of dead frames in each job.")
self.addColumn("Eaten", 50, id=8,
data=lambda job: job.data.job_stats.eaten_frames,
sort=lambda job: job.data.job_stats.eaten_frames,
sort=lambda job: sortableKey(job.data.job_stats.eaten_frames,
job.data.start_time),
tip="Total number of eaten frames in each job.")
self.addColumn("Wait", 60, id=9,
data=lambda job: job.data.job_stats.waiting_frames,
sort=lambda job: job.data.job_stats.waiting_frames,
sort=lambda job: sortableKey(job.data.job_stats.waiting_frames,
job.data.start_time),
tip="The number of waiting frames in each job,")
self.addColumn("MaxRss", 55, id=10,
data=lambda job: cuegui.Utils.memoryToString(job.data.job_stats.max_rss),
sort=lambda job: job.data.job_stats.max_rss,
sort=lambda job: sortableKey(job.data.job_stats.max_rss,
job.data.start_time),
tip="The maximum memory used any single frame in each job.")
self.addColumn("Age", 50, id=11,
data=lambda job: (cuegui.Utils.secondsToHHHMM((job.data.stop_time or
Expand Down
Loading