Commit 65553a4c authored by Manuel Günther's avatar Manuel Günther

Added option to ignore warnings while refreshing (jman refresh...

Added option to ignore warnings while refreshing (jman refresh --ignore-warnings); added 'job-name' to the list that is shown on 'jman ls'.
parent 874462bc
......@@ -202,7 +202,7 @@ class Job:
try_remove_files(self.stderr_filename(instance), recurse, verbose)
def check(self):
def check(self, ignore_warnings=False):
"""Checks if the job is in error state. If this job is a parametric job, it
will return an error state if **any** of the parametrized jobs are in error
state."""
......@@ -211,7 +211,15 @@ class Job:
try:
if os.stat(name).st_size != 0:
logging.debug("Job %s has a stderr file with size != 0" % jobname)
if not ignore_warnings:
return False
# read the contents of the log file to ignore the annoying warning messages
is_error = False
f = open(name,'r')
for line in f:
is_error = is_error or (line and 'WARNING' not in line)
return not is_error
except OSError, e:
logging.warn("Could not find error file '%s'" % name)
return True
......@@ -252,8 +260,8 @@ class Job:
def __str__(self):
"""Returns a string containing a short job description"""
return "%s @%s (%s ago) %s" % (self.name(),
self.queue(), self.age(short=False), ' '.join(self.args[0]))
return "%s @%s (%s ago) %s %s" % (self.name(),
self.queue(), self.age(short=False), self.kwargs['name'], ' '.join(self.args[0]))
def row(self, fmt, maxcmd=0):
"""Returns a string containing the job description suitable for a table."""
......@@ -262,7 +270,7 @@ class Job:
if maxcmd and len(cmdline) > maxcmd:
cmdline = cmdline[:(maxcmd-3)] + '...'
return fmt % (self.name(), self.queue(), self.age(), cmdline)
return fmt % (self.name(), self.queue(), self.age(), self.kwargs['name'], cmdline)
def has_key(self, key):
return self.data.has_key(key)
......@@ -370,12 +378,12 @@ class JobManager:
"""Returns the status of each job still being tracked"""
# configuration
fields = ("job-id", "queue", "age", "arguments")
lengths = (20, 5, 3, 43)
fields = ("job-id", "queue", "age", "job-name", "arguments")
lengths = (20, 7, 3, 20, 43)
marker = '='
# work
fmt = "%%%ds %%%ds %%%ds %%-%ds" % lengths
fmt = "%%%ds %%%ds %%%ds %%%ds %%-%ds" % lengths
delimiter = fmt % tuple([k*marker for k in lengths])
header = [fields[k].center(lengths[k]) for k in range(len(lengths))]
header = ' '.join(header)
......@@ -399,7 +407,7 @@ class JobManager:
"""Gets the error output of a certain job"""
return self[key].stderr(instance)
def refresh(self):
def refresh(self, ignore_warnings=False):
"""Conducts a qstat over all jobs in the cache. If the job is not present
anymore check the logs directory for output and error files. If the size of
the error file is different than zero, warn the user.
......@@ -412,7 +420,7 @@ class JobManager:
for k in sorted(self.job.keys()):
d = qstat(k, context=self.context)
if not d: #job has finished. check
status = self.job[k].check()
status = self.job[k].check(ignore_warnings)
if status:
success.append(self.job[k])
del self.job[k]
......
......@@ -56,7 +56,7 @@ def refresh(args):
"""Refresh action"""
jm = setup(args)
(good, bad) = jm.refresh()
(good, bad) = jm.refresh(args.ignore_warnings)
if good:
if args.verbose:
......@@ -302,8 +302,9 @@ def main():
# subcommand 'refresh'
refparser = cmdparser.add_parser('refresh', aliases=['ref'],
help='refreshes the current list of executing jobs by querying SGE, updates the databases of currently executing jobs. If you wish, it may optionally save jobs that executed successfuly and/or failed execution')
refparser.add_argument('-s', '--success-db', default='success.db', dest='successdb', metavar="DB", help='if you provide a name of a file, jobs that have succeeded will be saved on this file (defaults to "%(default)s")')
refparser.add_argument('-f', '--fail-db', dest='faildb', default='failure.db', metavar="DB", help='if you provide a name of a file, jobs that have failed will be saved on this file (defaults to "%(default)s")')
refparser.add_argument('-s', '--success-db', default='success.db', dest='successdb', metavar="DB", help='jobs that have succeeded will be saved on this file (defaults to "%(default)s")')
refparser.add_argument('-f', '--fail-db', dest='faildb', default='failure.db', metavar="DB", help='jobs that have failed will be saved on this file (defaults to "%(default)s")')
refparser.add_argument('-w', '--ignore-warnings', action="store_true", help='if enabled, warnings are not counted as errors')
refparser.add_argument('db', metavar='DATABASE', help='replace the default database to be refreshed by one provided by you; this option is only required if you are running outside the directory where you originally submitted the jobs from or if you have altered manually the location of the JobManager database', nargs='?')
refparser.set_defaults(func=refresh)
......
......@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name='gridtk',
version='0.3.0',
version='0.3.1',
description='SGE Grid Submission and Monitoring Tools for Idiap',
url='https://github.com/idiap/gridtk',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment