Skip to content

Commit

Permalink
Refactor restore jobIds code
Browse files Browse the repository at this point in the history
Changed constant to more descriptive name,
changed multi line text to use implicit joins,
fixed arg type.
  • Loading branch information
roulaoregan-spi committed Dec 4, 2021
1 parent 539d2cc commit 440ae37
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cuegui/cuegui/plugins/MonitorJobsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
PLUGIN_PROVIDES = "MonitorJobsDockWidget"
REGEX_EMPTY_STRING = re.compile("^$")
TIME_DELTA = 3
JOB_LOAD_LIMIT = 200
JOB_RESTORE_THRESHOLD_DAYS = 200

class MonitorJobsDockWidget(cuegui.AbstractDockWidget.AbstractDockWidget):
"""Plugin for listing active jobs and managing them."""
Expand Down Expand Up @@ -114,16 +114,14 @@ def restoreJobIds(self, jobIds):
:param jobIds: monitored jobs ids and their timestamp from previous working state
(loaded from config.ini file)
:ptype: list of tuples ex:
[("Job.f156be87-987a-48b9-b9da-774cd58674a3", 1612482716.170947),...
ex: [("Job.f156be87-987a-48b9-b9da-774cd58674a3", 1612482716.170947),...
:type: list[tuples]
"""
today = datetime.datetime.now()
limit = JOB_LOAD_LIMIT if len(jobIds) > JOB_LOAD_LIMIT else len(jobIds)
msg = """
Unable to load previously loaded job since
it was moved to the historical
database:
"""
limit = JOB_RESTORE_THRESHOLD_DAYS if len(jobIds) > \
JOB_RESTORE_THRESHOLD_DAYS 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]:
Expand All @@ -132,7 +130,7 @@ def restoreJobIds(self, jobIds):
try:
self.jobMonitor.addJob(jobId, timestamp)
except opencue.EntityNotFoundException:
logger.info(msg, jobId)
logger.info(msg.format(jobId))
except ValueError:
# load older format
for jobId in jobIds[:limit]:
Expand Down

0 comments on commit 440ae37

Please sign in to comment.