[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1728] trunk/py/scripts/addons: Moving netrender to addons
Martin Poirier
theeth at yahoo.com
Tue Mar 22 02:42:06 CET 2011
Revision: 1728
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1728
Author: theeth
Date: 2011-03-22 01:42:06 +0000 (Tue, 22 Mar 2011)
Log Message:
-----------
Moving netrender to addons
Added Paths:
-----------
trunk/py/scripts/addons/netrender/
trunk/py/scripts/addons/netrender/__init__.py
trunk/py/scripts/addons/netrender/balancing.py
trunk/py/scripts/addons/netrender/client.py
trunk/py/scripts/addons/netrender/master.py
trunk/py/scripts/addons/netrender/master_html.py
trunk/py/scripts/addons/netrender/model.py
trunk/py/scripts/addons/netrender/netrender.css
trunk/py/scripts/addons/netrender/netrender.js
trunk/py/scripts/addons/netrender/operators.py
trunk/py/scripts/addons/netrender/repath.py
trunk/py/scripts/addons/netrender/slave.py
trunk/py/scripts/addons/netrender/thumbnail.py
trunk/py/scripts/addons/netrender/ui.py
trunk/py/scripts/addons/netrender/utils.py
trunk/py/scripts/addons/netrender/versioning.py
Added: trunk/py/scripts/addons/netrender/__init__.py
===================================================================
--- trunk/py/scripts/addons/netrender/__init__.py (rev 0)
+++ trunk/py/scripts/addons/netrender/__init__.py 2011-03-22 01:42:06 UTC (rev 1728)
@@ -0,0 +1,81 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# This directory is a Python package.
+
+bl_info = {
+ "name": "Network Renderer",
+ "author": "Martin Poirier",
+ "version": (1, 3),
+ "blender": (2, 5, 6),
+ "api": 35011,
+ "location": "Render > Engine > Network Render",
+ "description": "Distributed rendering for Blender",
+ "warning": "Stable but still work in progress",
+ "wiki_url": "http://wiki.blender.org/index.php/Doc:2.5/Manual/Render/Engines/Netrender",
+ "category": "Render"}
+
+
+# To support reload properly, try to access a package var, if it's there, reload everything
+if "init_data" in locals():
+ import imp
+ imp.reload(model)
+ imp.reload(operators)
+ imp.reload(client)
+ imp.reload(slave)
+ imp.reload(master)
+ imp.reload(master_html)
+ imp.reload(utils)
+ imp.reload(balancing)
+ imp.reload(ui)
+ imp.reload(repath)
+ imp.reload(versioning)
+else:
+ from netrender import model
+ from netrender import operators
+ from netrender import client
+ from netrender import slave
+ from netrender import master
+ from netrender import master_html
+ from netrender import utils
+ from netrender import balancing
+ from netrender import ui
+ from netrender import repath
+ from netrender import versioning
+
+jobs = []
+slaves = []
+blacklist = []
+
+init_file = ""
+valid_address = False
+init_data = True
+
+
+def register():
+ import bpy
+ bpy.utils.register_module(__name__)
+
+ scene = bpy.context.scene
+ if scene:
+ ui.init_data(scene.network_render)
+
+
+def unregister():
+ import bpy
+ bpy.utils.unregister_module(__name__)
Property changes on: trunk/py/scripts/addons/netrender/__init__.py
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/py/scripts/addons/netrender/balancing.py
===================================================================
--- trunk/py/scripts/addons/netrender/balancing.py (rev 0)
+++ trunk/py/scripts/addons/netrender/balancing.py 2011-03-22 01:42:06 UTC (rev 1728)
@@ -0,0 +1,195 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+import time
+
+from netrender.utils import *
+import netrender.model
+
+class RatingRule:
+ def __init__(self):
+ self.enabled = True
+
+ def id(self):
+ return str(id(self))
+
+ def rate(self, job):
+ return 0
+
+class ExclusionRule:
+ def __init__(self):
+ self.enabled = True
+
+ def id(self):
+ return str(id(self))
+
+ def test(self, job):
+ return False
+
+class PriorityRule:
+ def __init__(self):
+ self.enabled = True
+
+ def id(self):
+ return str(id(self))
+
+ def test(self, job):
+ return False
+
+class Balancer:
+ def __init__(self):
+ self.rules = []
+ self.priorities = []
+ self.exceptions = []
+
+ def ruleByID(self, rule_id):
+ for rule in self.rules:
+ if rule.id() == rule_id:
+ return rule
+ for rule in self.priorities:
+ if rule.id() == rule_id:
+ return rule
+ for rule in self.exceptions:
+ if rule.id() == rule_id:
+ return rule
+
+ return None
+
+ def addRule(self, rule):
+ self.rules.append(rule)
+
+ def addPriority(self, priority):
+ self.priorities.append(priority)
+
+ def addException(self, exception):
+ self.exceptions.append(exception)
+
+ def applyRules(self, job):
+ return sum((rule.rate(job) for rule in self.rules if rule.enabled))
+
+ def applyPriorities(self, job):
+ for priority in self.priorities:
+ if priority.enabled and priority.test(job):
+ return True # priorities are first
+
+ return False
+
+ def applyExceptions(self, job):
+ for exception in self.exceptions:
+ if exception.enabled and exception.test(job):
+ return True # exceptions are last
+
+ return False
+
+ def sortKey(self, job):
+ return (1 if self.applyExceptions(job) else 0, # exceptions after
+ 0 if self.applyPriorities(job) else 1, # priorities first
+ self.applyRules(job))
+
+ def balance(self, jobs):
+ if jobs:
+ # use inline copy to make sure the list is still accessible while sorting
+ jobs[:] = sorted(jobs, key=self.sortKey)
+ return jobs[0]
+ else:
+ return None
+
+# ==========================
+
+class RatingUsage(RatingRule):
+ def __str__(self):
+ return "Usage per job"
+
+ def rate(self, job):
+ # less usage is better
+ return job.usage / job.priority
+
+class RatingUsageByCategory(RatingRule):
+ def __init__(self, get_jobs):
+ super().__init__()
+ self.getJobs = get_jobs
+
+ def __str__(self):
+ return "Usage per category"
+
+ def rate(self, job):
+ total_category_usage = sum([j.usage for j in self.getJobs() if j.category == job.category])
+ maximum_priority = max([j.priority for j in self.getJobs() if j.category == job.category])
+
+ # less usage is better
+ return total_category_usage / maximum_priority
+
+class NewJobPriority(PriorityRule):
+ def __init__(self, limit = 1):
+ super().__init__()
+ self.limit = limit
+
+ def setLimit(self, value):
+ self.limit = int(value)
+
+ def str_limit(self):
+ return "less than %i frame%s done" % (self.limit, "s" if self.limit > 1 else "")
+
+ def __str__(self):
+ return "Priority to new jobs"
+
+ def test(self, job):
+ return job.countFrames(status = DONE) < self.limit
+
+class MinimumTimeBetweenDispatchPriority(PriorityRule):
+ def __init__(self, limit = 10):
+ super().__init__()
+ self.limit = limit
+
+ def setLimit(self, value):
+ self.limit = int(value)
+
+ def str_limit(self):
+ return "more than %i minute%s since last" % (self.limit, "s" if self.limit > 1 else "")
+
+ def __str__(self):
+ return "Priority to jobs that haven't been dispatched recently"
+
+ def test(self, job):
+ return job.countFrames(status = DISPATCHED) == 0 and (time.time() - job.last_dispatched) / 60 > self.limit
+
+class ExcludeQueuedEmptyJob(ExclusionRule):
+ def __str__(self):
+ return "Exclude non queued or empty jobs"
+
+ def test(self, job):
+ return job.status != JOB_QUEUED or job.countFrames(status = QUEUED) == 0
+
+class ExcludeSlavesLimit(ExclusionRule):
+ def __init__(self, count_jobs, count_slaves, limit = 0.75):
+ super().__init__()
+ self.count_jobs = count_jobs
+ self.count_slaves = count_slaves
+ self.limit = limit
+
+ def setLimit(self, value):
+ self.limit = float(value)
+
+ def str_limit(self):
+ return "more than %.0f%% of all slaves" % (self.limit * 100)
+
+ def __str__(self):
+ return "Exclude jobs that would use too many slaves"
+
+ def test(self, job):
+ return not ( self.count_jobs() == 1 or self.count_slaves() <= 1 or float(job.countSlaves() + 1) / self.count_slaves() <= self.limit )
Property changes on: trunk/py/scripts/addons/netrender/balancing.py
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/py/scripts/addons/netrender/client.py
===================================================================
--- trunk/py/scripts/addons/netrender/client.py (rev 0)
+++ trunk/py/scripts/addons/netrender/client.py 2011-03-22 01:42:06 UTC (rev 1728)
@@ -0,0 +1,376 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+import bpy
+import sys, os, re
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list