Skip to content

Commit

Permalink
Fix python3 related issues on Redirect plugin (#1631)
Browse files Browse the repository at this point in the history
- Qt's QCompleter expects a list as input and an iterable was being
provided.
- The call to `proc.getJob` can raise an Exception if no result is
found. The previously untreated exception would halt the procs loop and
prevent the full list from being processed
- Another occurence of QCompleter was also altered to ensure a list and
not an iterable is passed
  • Loading branch information
DiegoTavares authored Jan 27, 2025
1 parent 97e5d3f commit 19b0883
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
51 changes: 28 additions & 23 deletions cuegui/cuegui/Redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def refresh(self):
slist = opencue.api.getJobNames()
slist.sort()

self.__c = QtWidgets.QCompleter(slist, self)
self.__c = QtWidgets.QCompleter(list(slist), self)
self.__c.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.setCompleter(self.__c)

Expand Down Expand Up @@ -411,7 +411,7 @@ class RedirectWidget(QtWidgets.QWidget):
"""

HEADERS = ["Name", "Cores", "Memory", "PrcTime", "Group", "Service",
"Job Cores", "Pending", "LLU", "Log"]
"Job Cores", "Waiting Frames", "LLU", "Log"]

def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
Expand Down Expand Up @@ -604,7 +604,7 @@ def __isBurstSafe(self, alloc, procs, show):
@classmethod
def __isAllowed(cls, procs, targetJob):
"""Checks if the follow criteria are met to allow redirect to target job:
- if source/target job have pending frames
- if source/target job have waiting frames
- if target job hasn't reached maximum cores
- check if adding frames will push target job over it's max cores
Expand All @@ -626,18 +626,18 @@ def __isAllowed(cls, procs, targetJob):
targetJob.coresReserved(),
targetJob.maxCores())

# Case 2: 1. Check target job for pending frames
# 2. Check source procs for pending frames
# Case 2: 1. Check target job for waiting frames
# 2. Check source procs for waiting frames
if allowed and targetJob.waitingFrames() <= 0:
allowed = False
errMsg = "Target job %s has no pending (waiting) frames" % targetJob.name()
errMsg = "Target job %s has no waiting frames" % targetJob.name()

if allowed:
for proc in procs:
job = proc.getJob()
if job.waitingFrames() <= 0:
allowed = False
errMsg = "Source job %s has no pending (waiting) frames" % job.name()
errMsg = "Source job %s has no waiting frames" % job.name()
break

# Case 3: Check if each proc or summed up procs will
Expand Down Expand Up @@ -808,21 +808,26 @@ def update(self):
if proc.data.group_name not in groupFilter:
continue

name = proc.data.name.split("/")[0]
lluTime = cuegui.Utils.getLLU(proc)
job = proc.getJob()
logLines = cuegui.Utils.getLastLine(proc.data.log_path) or ""

if name not in hosts:
cue_host = opencue.api.findHost(name)
hosts[name] = {
"host": cue_host,
"procs": [],
"mem": cue_host.data.idle_memory,
"cores": int(cue_host.data.idle_cores),
"time": 0,
"ok": False,
'alloc': cue_host.data.alloc_name}
# pylint: disable=broad-except
try:
name = proc.data.name.split("/")[0]
lluTime = cuegui.Utils.getLLU(proc)
job = proc.getJob()
logLines = cuegui.Utils.getLastLine(proc.data.log_path) or ""

if name not in hosts:
cue_host = opencue.api.findHost(name)
hosts[name] = {
"host": cue_host,
"procs": [],
"mem": cue_host.data.idle_memory,
"cores": int(cue_host.data.idle_cores),
"time": 0,
"ok": False,
'alloc': cue_host.data.alloc_name}
except Exception:
# Ignore dangling procs (not bound to a job through a VirtualProc)
continue

host = hosts[name]
if host["ok"]:
Expand All @@ -835,7 +840,7 @@ def update(self):
host["llu"] = cuegui.Utils.numFormat(lluTime, "t")
host["log"] = logLines
host['job_cores'] = job.data.job_stats.reserved_cores
host['waiting'] = job.pendingFrames() or 0
host['waiting'] = job.waitingFrames() or 0

if host["cores"] >= self.__controls.getCores() and \
host["cores"] <= self.__controls.getMaxCores() and \
Expand Down
2 changes: 1 addition & 1 deletion cuegui/cuegui/plugins/StuckFramePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def refresh(self):
"""Refreshes the show list."""
slist = opencue.api.getDefaultServices()
slist.sort(key=lambda s: s.name())
self.__c = QtWidgets.QCompleter(slist, self)
self.__c = QtWidgets.QCompleter(list(slist), self)
self.__c.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.setCompleter(self.__c)

Expand Down

0 comments on commit 19b0883

Please sign in to comment.