Commit 7f0d06c7 authored by Christopher Gearhart's avatar Christopher Gearhart

Implemented max_server_load functionality! It still needs to be thoroughly…

Implemented max_server_load functionality! It still needs to be thoroughly tested, but it seems stable.
parent 9446dd28
......@@ -93,7 +93,7 @@ class refreshNumAvailableServers(Operator):
elif self.state == 2:
self.updateAvailServerInfo()
scn = context.scene
self.report({"INFO"}, "Refresh process completed ({numAvailable} servers available)".format(numAvailable=str(scn.availableServers)))
self.report({"INFO"}, "Refresh process completed ({num} servers available)".format(num=str(scn.availableServers)))
return{"FINISHED"}
else:
self.report({"ERROR"}, "ERROR: Current state not recognized.")
......@@ -252,7 +252,11 @@ class sendFrame(Operator):
numRenderedFiles = getNumRenderedFiles("image", [bpy.props.imFrame], None)
if numRenderedFiles > 0:
averaged = True
bpy.props.nameAveragedImage = averageFrames(self, bpy.props.nameImOutputFiles)
aveName = averageFrames(self, bpy.props.nameImOutputFiles)
if aveName != None:
bpy.props.nameAveragedImage = aveName
else:
averaged = False
else:
averaged = False
# calculate number of samples represented in averaged image
......@@ -265,7 +269,7 @@ class sendFrame(Operator):
if area.type == "IMAGE_EDITOR":
area.spaces.active.image = bpy.data.images[bpy.props.nameAveragedImage]
break
self.report({"INFO"}, "Render completed at {numSamples} samples! View the rendered image in your UV/Image_Editor".format(numSamples=str(self.numSamples)))
self.report({"INFO"}, "Render completed at {num} samples! View the rendered image in your UV/Image_Editor".format(num=str(self.numSamples)))
else:
if bpy.data.images.find(bpy.props.nameAveragedImage) >= 0:
# open preview image in UV/Image_Editor
......@@ -276,7 +280,7 @@ class sendFrame(Operator):
self.previewed = True
break
self.processes[1] = False
previewString = "Render preview loaded ({numSamples} samples)".format(numSamples=str(self.numSamples))
previewString = "Render preview loaded ({num} samples)".format(num=str(self.numSamples))
self.report({"INFO"}, previewString)
appendViewable("image")
removeViewable("animation")
......
......@@ -43,7 +43,8 @@ def averageFrames(classObject, outputFileName, verbose=0):
imListNames = [filename for filename in allFiles if fnmatch.fnmatch(filename, inFileName)]
imList = [os.path.join(renderedFramesPath, im) for im in imListNames]
if not imList:
classObject.report({"ERROR"}, "No image files to average")
print("No image files to average")
return None
# Assuming all images are the same size, get dimensions of first image
imRef = bpy.data.images.load(imList[0])
......
......@@ -32,7 +32,7 @@ def getLibraryPath():
libraryPath = functionsPath[:-10]
if not os.path.exists(libraryPath):
raise NameError("Did not find addon from path {libraryPath}".format(libraryPath=libraryPath))
raise NameError("Did not find addon from path {}".format(libraryPath))
return libraryPath
def readFileFor(f, flagName):
......
This diff is collapsed.
#!/usr/bin/env python
"""
Copyright (C) 2017 Bricks Brought to Life
http://bblanimation.com/
......@@ -52,25 +54,25 @@ class JobHostManager():
jobAccepted = False
try:
while not self.jobs_complete() and not self.stop_now:
time.sleep(1)
# time.sleep(.25)
for aHost in self.hosts.keys():
if self.jobs_complete() or self.stop_now:
break
host = self.hosts[aHost]
while self.host_can_take_job(host=host) and len(self.jobs) > 0:
time.sleep(.5)
# time.sleep(.1)
hostname = host.get_hostname()
job = self.jobs.pop()
host.add_job(job)
if host not in self.hosts_with_jobs:
self.hosts_with_jobs[hostname] = host.get_task_count()
if not host.is_started() and not host.thread_stopped():
self.hosts_with_jobs[hostname] = host.get_job_count()
if not host.is_started():
host.start()
numQueued = str(len(self.jobs))
if self.verbose >= 3:
pflush("Running job {job} on host {host}. ({numQueued} jobs remain in queue)".format(job=job, host=hostname, numQueued=numQueued))
elif self.verbose >= 2:
pflush("Job sent to host '{hostname}' ({numQueued} jobs remain in queue)".format(hostname=hostname, numQueued=numQueued))
if self.jobs_complete() or self.stop_now:
break
self.stop_all_threads()
except (KeyboardInterrupt, SystemExit):
self.stop_all_threads()
......@@ -118,10 +120,8 @@ class JobHostManager():
def host_failed_job(self, hostname, job):
error_string = "Failed Job on {hostname}: {job}".format(hostname=hostname, job=job)
# eflush(error_string)
if self.verbose >= 3:
print(error_string)
# self.add_job(job)
self.job_status[job] = 1
......@@ -132,7 +132,7 @@ class JobHostManager():
host = self.hosts[hostname]
else:
return False
if host.get_task_count() < self.max_on_hosts and host.is_telnetable():
if host.can_take_job() and host.is_telnetable():
return True
return False
......@@ -141,7 +141,6 @@ class JobHostManager():
def print_jobs_status(self):
if self.jobs_complete():
print("Jobs completed successfully!")
if self.verbose >= 2:
print(self.get_cumulative_status())
else:
......@@ -150,7 +149,7 @@ class JobHostManager():
def stop_all_threads(self):
for hostname in self.hosts_with_jobs.keys():
tHost = self.hosts[hostname]
tHost.thread_stop()
tHost.kill()
self.stop()
def stop(self):
......@@ -168,13 +167,31 @@ if __name__ == '__main__':
verbose = 2
# jhm = JobHostManager(jobs=jobStrings,hosts=host_objects,function_args=job_args)
# jobs = ['blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 7 -e 7 -P /tmp/nwhite/test/blender_p.py -a' ,'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 6 -e 6 -P /tmp/nwhite/test/blender_p.py -a' ,'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 5 -e 5 -P /tmp/nwhite/test/blender_p.py -a' ,'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 4 -e 4 -P /tmp/nwhite/test/blender_p.py -a' , 'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 2 -e 2 -P /tmp/nwhite/test/blender_p.py -a' , 'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 1 -e 1 -P /tmp/nwhite/test/blender_p.py -a','blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 3 -e 3 -P /tmp/nwhite/test/blender_p.py -a' ]
jobs = ['blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 7 -e 7 -P /tmp/nwhite/test/blender_p.py -a']
kwargs = {'username':'nwhite', 'remoteProjectPath':'/tmp/nwhite/test', 'verbose':None, 'projectPath':'/tmp/nwhite/test', 'remoteSyncBack':'/tmp/nwhite/test/results', 'projectName':'test', 'projectSyncPath':'/tmp/nwhite/test/toRemote/', 'projectOutuptFile':'/tmp/nwhite/test/'}
jobs = [
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 1 -e 1 -P /tmp/nwhite/test/blender_p.py -a',
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 2 -e 2 -P /tmp/nwhite/test/blender_p.py -a',
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 3 -e 3 -P /tmp/nwhite/test/blender_p.py -a',
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 4 -e 4 -P /tmp/nwhite/test/blender_p.py -a',
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 5 -e 5 -P /tmp/nwhite/test/blender_p.py -a',
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 6 -e 6 -P /tmp/nwhite/test/blender_p.py -a',
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 7 -e 7 -P /tmp/nwhite/test/blender_p.py -a',
'blender -b /tmp/nwhite/test/test.blend -x 1 -o //results/test_####.png -s 8 -e 8 -P /tmp/nwhite/test/blender_p.py -a'
]
kwargs = {
'projectName':'test',
'projectSyncPath':'/tmp/nwhite/test/toRemote/',
'username':'nwhite',
'verbose':None,
'projectPath':'/tmp/nwhite/test',
'remoteResultsPath':'/tmp/nwhite/test/results',
'localResultsPath':'/tmp/nwhite/test/results'
}
cse217Host = JobHost(hostname='cse21701', thread_func=start_tasks, kwargs=kwargs, verbose=3 ,max_on_host=3)
hostObjects = [cse217Host]
jhm = JobHostManager(jobs=jobs, hosts=hostObjects)
cse217Host = JobHost(hostname='cse21701', thread_func=start_tasks, kwargs=kwargs, verbose=2)
cse10319 = JobHost(hostname='cse10319', thread_func=start_tasks, kwargs=kwargs, verbose=2)
cse10318 = JobHost(hostname='cse10318', thread_func=start_tasks, kwargs=kwargs, verbose=2)
hostObjects = [cse217Host, cse10319, cse10318]
jhm = JobHostManager(jobs=jobs, hosts=hostObjects, max_on_hosts=1)
jhm.print_jobs_status()
......@@ -89,8 +89,9 @@ def main():
hosts_online = list()
hosts_offline = list()
max_server_load = int(args.max_server_load)
for host in hosts:
jh = JobHost(hostname=host, timeout=float(args.connection_timeout), thread_func=start_tasks, verbose=verbose)
jh = JobHost(hostname=host, timeout=float(args.connection_timeout), thread_func=start_tasks, verbose=verbose, max_on_host=max_server_load)
if jh.is_reachable():
hosts_online.append(str(host))
else:
......@@ -210,7 +211,6 @@ def main():
job_args["frame"] = frames[0]
# Sets up kwargs, and callbacks on the hosts
max_server_load = int(args.max_server_load)
jhm = JobHostManager(jobs=jobStrings, hosts=host_objects, function_args=job_args, verbose=verbose, max_on_hosts=max_server_load)
jhm.start()
status = jhm.get_cumulative_status()
......
......@@ -63,11 +63,11 @@ class renderOnServersPanel(Panel):
if imRenderStatus != "None":
col = layout.column(align=True)
row = col.row(align=True)
row.label("Render Status: {imRenderStatus}".format(imRenderStatus=imRenderStatus))
row.label("Render Status: {status}".format(status=imRenderStatus))
elif animRenderStatus != "None":
col = layout.column(align=True)
row = col.row(align=True)
row.label("Render Status: {animRenderStatus}".format(animRenderStatus=animRenderStatus))
row.label("Render Status: {status}".format(status=animRenderStatus))
# display buttons to view render(s)
row = layout.row(align=True)
......
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