def main(): # initialize DrQueue client client = DrQueueClient() # fetch a list of all jobs jobs = client.query_job_list() # walk through tasks of every job for job in jobs: tasks = client.query_task_list(job['_id']) print("\nJob \"%s\" (ID: %s):" % (job['name'], job['_id'])) print("Overall status: " + client.job_status(job['_id'])) print("Task id status owner completed at") for task in tasks: tmsg_id = task['msg_id'] theader = task['header'] username = theader['username'] if task['completed'] == None: status = "pending" print("%s %s %s" % (tmsg_id, string.ljust(status, 8), string.ljust(username, 10))) else: result_header = task['result_header'] result_content = task['result_content'] status = result_header['status'] cpl = task['completed'] print("%s %s %s %i-%02i-%02i %02i:%02i:%02i" % (tmsg_id, string.ljust(status, 8), string.ljust(username, 10), cpl.year, cpl.month, cpl.day, cpl.hour, cpl.minute, cpl.second)) if result_header['status'] == 'error': print " Error was: " + result_content['evalue']
def main(): # initialize DrQueue client client = DrQueueClient() # fetch a list of all jobs jobs = client.query_job_list() # walk through tasks of every job for job in jobs: tasks = client.query_task_list(job['_id']) meantime, time_left, finish_time = client.job_estimated_finish_time( job['_id']) frame = job['startframe'] print("\nJob \"%s\" (ID: %s):" % (job['name'], job['_id'])) print("Overall status: " + client.job_status(job['_id'])) print("Enabled: %s" % job['enabled']) print("Submit time: " + str(job['submit_time'])) if job['requeue_time'] != False: print("Requeue time: " + str(job['requeue_time'])) print("Time per task: " + str(meantime)) if client.query_job_tasks_left(job['_id']) > 0: print("Time left: " + str(time_left)) print("Estimated finish time: " + str(finish_time)) else: print("Finish time: " + str(finish_time)) if 'pool_name' in job['limits']: print("Pool: " + str(job['limits']['pool_name'])) else: print("Pool: Not set.") print("Task id\t\t\t\t\tframe\tstatus\towner\tcompleted at") for task in tasks: tmsg_id = task['msg_id'] theader = task['header'] username = theader['username'] if task['completed'] == None: status = "pending" print("%s\t%i\t%s\t%s" % (tmsg_id, frame, status, username)) else: result_header = task['result_header'] result_content = task['result_content'] print(result_header) status = result_content['status'] cpl = task['completed'] print("%s\t%i\t%s\t%s\t%i-%02i-%02i %02i:%02i:%02i" % (tmsg_id, frame, status, username, cpl.year, cpl.month, cpl.day, cpl.hour, cpl.minute, cpl.second)) if result_content['status'] == 'error': print(" Error was: " + result_content['evalue'] + "\n" + str(result_content['traceback'])) if int(job['blocksize']) > 1: frame += int(job['blocksize']) else: frame += 1
def main(): # initialize DrQueue client client = DrQueueClient() # fetch a list of all jobs jobs = client.query_job_list() # walk through tasks of every job for job in jobs: tasks = client.query_task_list(job['_id']) meantime, time_left, finish_time = client.job_estimated_finish_time(job['_id']) frame = job['startframe'] print("\nJob \"%s\" (ID: %s):" % (job['name'], job['_id'])) print("Overall status: " + client.job_status(job['_id'])) print("Enabled: %s" % job['enabled']) print("Submit time: " + str(job['submit_time'])) if job['requeue_time'] != False: print("Requeue time: "+ str(job['requeue_time'])) print("Time per task: " + str(meantime)) if client.query_job_tasks_left(job['_id']) > 0: print("Time left: " + str(time_left)) print("Estimated finish time: " + str(finish_time)) else: print("Finish time: " + str(finish_time)) if 'pool_name' in job['limits']: print("Pool: " + str(job['limits']['pool_name'])) else: print("Pool: Not set.") print("Task id\t\t\t\t\tframe\tstatus\towner\tcompleted at") for task in tasks: tmsg_id = task['msg_id'] theader = task['header'] username = theader['username'] if task['completed'] == None: status = "pending" print("%s\t%i\t%s\t%s" % (tmsg_id, frame, status, username)) else: result_header = task['result_header'] result_content = task['result_content'] print(result_header) status = result_content['status'] cpl = task['completed'] print("%s\t%i\t%s\t%s\t%i-%02i-%02i %02i:%02i:%02i" % (tmsg_id, frame, status, username, cpl.year, cpl.month, cpl.day, cpl.hour, cpl.minute, cpl.second)) if result_content['status'] == 'error': print(" Error was: " + result_content['evalue'] + "\n" + str(result_content['traceback'])) if int(job['blocksize']) > 1: frame += int(job['blocksize']) else: frame += 1
def main(): client = DrQueueClient() while True: jobs = DrQueueJob.query_job_status('ready') if jobs == []: print "Not find any jobs in data base!waiting...." time.sleep(60) continue for job in jobs: print "Process job %s" % job["name"] try: #pdb.set_trace() job["job_status"] = u'running' DrQueueJob.update_db(job) client.job_run(job) #print job['job_id'] except ValueError: print "Job's name %s " % job['name'] print("One of your the specified values produced an error:") #time.sleep(10) # tasks which have been created tasks = client.query_task_list(job['_id']) # wait for all tasks of job to finish if (tasks == []) and (client.query_computer_list() == []): print("Tasks have been sent but no render node is running at the moment.") exit(0) for task in tasks: ar = client.task_wait(task['msg_id']) # add some verbose output cpl = ar.metadata.completed msg_id = ar.metadata.msg_id status = ar.status engine_id = ar.metadata.engine_id print("Task %s finished with status '%s' on engine %i at %i-%02i-%02i %02i:%02i:%02i." % (msg_id, status, engine_id, cpl.year, cpl.month, cpl.day, cpl.hour, cpl.minute, cpl.second)) if ar.pyerr != None: print(ar.pyerr) job['job_status'] = 'completed' DrQueueJob.update_db(job) print("Job %s finished." % job['name'])
def main(): # initialize DrQueue client client = DrQueueClient() # fetch a list of all jobs jobs = client.query_job_list() # walk through tasks of every job for job in jobs: tasks = client.query_task_list(job['_id']) meantime, time_left, finish_time = client.job_estimated_finish_time(job['_id']) print("\nJob \"%s\" (ID: %s):" % (job['name'], job['_id'])) print("Overall status: " + client.job_status(job['_id'])) print("Submit time: "+ str(job['submit_time'])) if job['requeue_time'] != False: print("Requeue time: "+ str(job['requeue_time'])) print("Time per task: " + str(meantime)) if client.query_job_tasks_left(job['_id']) > 0: print("Time left: " + str(time_left)) print("Estimated finish time: " + str(finish_time)) else: print("Finish time: " + str(finish_time)) print("Task id status owner completed at") for task in tasks: tmsg_id = task['msg_id'] theader = task['header'] username = theader['username'] if task['completed'] == None: status = "pending" print("%s %s %s" % (tmsg_id, string.ljust(status, 8), string.ljust(username, 10))) else: result_header = task['result_header'] result_content = task['result_content'] status = result_header['status'] cpl = task['completed'] print("%s %s %s %i-%02i-%02i %02i:%02i:%02i" % (tmsg_id, string.ljust(status, 8), string.ljust(username, 10), cpl.year, cpl.month, cpl.day, cpl.hour, cpl.minute, cpl.second)) if result_header['status'] == 'error': print(" Error was: " + result_content['evalue'])
def main(): # parse arguments parser = OptionParser() parser.usage = "%prog [options] -n name -r renderer -f scenefile" parser.add_option("-s", "--startframe", dest="startframe", default=1, help="first frame") parser.add_option("-e", "--endframe", dest="endframe", default=1, help="last frame") parser.add_option("-b", "--blocksize", dest="blocksize", default=1, help="size of block") parser.add_option("-n", "--name", dest="name", default=None, help="name of job") parser.add_option("-r", "--renderer", dest="renderer", help="render type (maya|blender|mentalray)") parser.add_option("-f", "--scenefile", dest="scenefile", default=None, help="path to scenefile") parser.add_option("-p", "--pool", dest="pool", default=None, help="pool of computers") parser.add_option("-o", "--options", dest="options", default="{}", help="specific options for renderer as Python dict") parser.add_option("--retries", dest="retries", default=1, help="number of retries for every task") parser.add_option("--owner", dest="owner", default=getpass.getuser(), help="Owner of job. Default is current username.") parser.add_option("--os", dest="os", default=None, help="Operating system.") parser.add_option("--minram", dest="minram", default=0, help="Minimal RAM in GB.") parser.add_option("--mincores", dest="mincores", default=0, help="Minimal CPU cores.") parser.add_option("--send-email", action="store_true", dest="send_email", default=False, help="Send notification email when job is finished.") parser.add_option("--email-recipients", dest="email_recipients", default=None, help="Recipients for notification email.") parser.add_option("-w", "--wait", action="store_true", dest="wait", default=False, help="wait for job to finish") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") (options, args) = parser.parse_args() # initialize DrQueue client client = DrQueueClient() # set limits limits = dict() limits['pool_name'] = options.pool limits['os'] = options.os limits['minram'] = int(options.minram) limits['mincores'] = int(options.mincores) options_var = eval(options.options) options_var['send_email'] = options.send_email options_var['email_recipients'] = options.email_recipients # initialize DrQueue job job = DrQueueJob(options.name, int(options.startframe), int(options.endframe), int(options.blocksize), options.renderer, options.scenefile, options.retries, options.owner, options_var, "send_job.py", limits) # run job with client try: client.job_run(job) except ValueError: print("One of your the specified values produced an error:") raise exit(1) # tasks which have been created tasks = client.query_task_list(job['_id']) # wait for all tasks of job to finish if options.wait: if (tasks == []) and (client.query_engine_list() == []): print("Tasks have been sent but no render node is running at the moment.") exit(0) for task in tasks: ar = client.task_wait(task['msg_id']) # add some verbose output if options.verbose: cpl = ar.metadata.completed msg_id = ar.metadata.msg_id status = ar.status engine_id = ar.metadata.engine_id print("Task %s finished with status '%s' on engine %i at %i-%02i-%02i %02i:%02i:%02i." % (msg_id, status, engine_id, cpl.year, cpl.month, cpl.day, cpl.hour, cpl.minute, cpl.second)) if ar.pyerr != None: print(ar.pyerr) print("Job %s finished." % job['name'])
def main(): # parse arguments parser = OptionParser() parser.usage = "%prog [options] -n name -r renderer -f scenefile" parser.add_option("-s", "--startframe", dest="startframe", default=1, help="first frame") parser.add_option("-e", "--endframe", dest="endframe", default=1, help="last frame") parser.add_option("-b", "--blocksize", dest="blocksize", default=1, help="size of block") parser.add_option("-n", "--name", dest="name", default=None, help="name of job") parser.add_option("-r", "--renderer", dest="renderer", help="render type (maya|blender|mentalray)") parser.add_option("-f", "--scenefile", dest="scenefile", default=None, help="path to scenefile") parser.add_option("-p", "--pool", dest="pool", default=None, help="pool of computers") parser.add_option("-o", "--options", dest="options", default="{}", help="specific options for renderer as Python dict") parser.add_option("--retries", dest="retries", default=1, help="number of retries for every task") parser.add_option("--owner", dest="owner", default=getpass.getuser(), help="Owner of job. Default is current username.") parser.add_option("--os", dest="os", default=None, help="Operating system.") parser.add_option("--minram", dest="minram", default=0, help="Minimal RAM in GB.") parser.add_option("--mincores", dest="mincores", default=0, help="Minimal CPU cores.") parser.add_option("--send-email", action="store_true", dest="send_email", default=False, help="Send notification email when job is finished.") parser.add_option("--email-recipients", dest="email_recipients", default=None, help="Recipients for notification email.") parser.add_option("-w", "--wait", action="store_true", dest="wait", default=False, help="wait for job to finish") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose output") (options, args) = parser.parse_args() # initialize DrQueue client client = DrQueueClient() # set limits limits = dict() limits['pool_name'] = options.pool limits['os'] = options.os limits['minram'] = int(options.minram) limits['mincores'] = int(options.mincores) options_var = eval(options.options) options_var['send_email'] = options.send_email options_var['email_recipients'] = options.email_recipients # add default rendertype if missing if "rendertype" not in options_var: options_var['rendertype'] = "animation" # initialize DrQueue job job = DrQueueJob(options.name, int(options.startframe), int(options.endframe), int(options.blocksize), options.renderer, options.scenefile, options.retries, options.owner, options_var, "send_job.py", limits) # run job with client try: client.job_run(job) except ValueError: print("One of your the specified values produced an error:") raise exit(1) # tasks which have been created tasks = client.query_task_list(job['_id']) # wait for all tasks of job to finish if options.wait: if (tasks == []) and (client.query_computer_list() == []): print("Tasks have been sent but no render node is running at the moment.") exit(0) for task in tasks: ar = client.task_wait(task['msg_id']) # add some verbose output if options.verbose: cpl = ar.metadata.completed msg_id = ar.metadata.msg_id status = ar.status engine_id = ar.metadata.engine_id print("Task %s finished with status '%s' on engine %i at %i-%02i-%02i %02i:%02i:%02i." % (msg_id, status, engine_id, cpl.year, cpl.month, cpl.day, cpl.hour, cpl.minute, cpl.second)) if ar.pyerr != None: print(ar.pyerr) print("Job %s finished." % job['name'])