Skip to content

Commit

Permalink
Fixed MonitorJobPlugin restore constants
Browse files Browse the repository at this point in the history
Previous commit mixed constant job threshold's
limit with days, corrected it. Added comment
description for timestamp in addJob.
  • Loading branch information
roulaoregan-spi committed Dec 6, 2021
1 parent 553256a commit e313aff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion cuegui/cuegui/JobMonitorTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ def setLoadMine(self, value):
def addJob(self, job, timestamp=None):
"""Adds a job to the list. With locking"
@param job: Job can be None, a job object, or a job name.
@type job: job, string, None"""
@type job: job, string, None
@param timestamp: UTC time of the specific date the job was
added to be monitored
@type timestamp: float"""
newJobObj = cuegui.Utils.findJob(job)
self.ticksLock.lock()
try:
Expand Down
10 changes: 5 additions & 5 deletions cuegui/cuegui/plugins/MonitorJobsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
PLUGIN_DESCRIPTION = "Monitors a list of jobs"
PLUGIN_PROVIDES = "MonitorJobsDockWidget"
REGEX_EMPTY_STRING = re.compile("^$")
TIME_DELTA = 3
JOB_RESTORE_THRESHOLD_DAYS = 200
JOB_RESTORE_THRESHOLD_DAYS = 3
JOB_RESTORE_THRESHOLD_LIMIT = 200

class MonitorJobsDockWidget(cuegui.AbstractDockWidget.AbstractDockWidget):
"""Plugin for listing active jobs and managing them."""
Expand Down Expand Up @@ -118,15 +118,15 @@ def restoreJobIds(self, jobIds):
:type jobIds: list[tuples]
"""
today = datetime.datetime.now()
limit = JOB_RESTORE_THRESHOLD_DAYS if len(jobIds) > \
JOB_RESTORE_THRESHOLD_DAYS else len(jobIds)
limit = JOB_RESTORE_THRESHOLD_LIMIT if len(jobIds) > \
JOB_RESTORE_THRESHOLD_LIMIT else len(jobIds)
msg = ('Unable to load previously loaded job since it was moved '
'to the historical database: {0}')

try:
for jobId, timestamp in jobIds[:limit]:
loggedTime = datetime.datetime.fromtimestamp(timestamp)
if (today - loggedTime).days <= TIME_DELTA:
if (today - loggedTime).days <= JOB_RESTORE_THRESHOLD_DAYS:
try:
self.jobMonitor.addJob(jobId, timestamp)
except opencue.EntityNotFoundException:
Expand Down

0 comments on commit e313aff

Please sign in to comment.