[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3659] trunk/py/scripts/tools/bi_farm: - option to render absolute number of frames per job

Campbell Barton ideasman42 at gmail.com
Mon Jul 30 10:58:43 CEST 2012


Revision: 3659
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3659
Author:   campbellbarton
Date:     2012-07-30 08:58:43 +0000 (Mon, 30 Jul 2012)
Log Message:
-----------
- option to render absolute number of frames per job
- option to render sparse order

Modified Paths:
--------------
    trunk/py/scripts/tools/bi_farm/master_ui.py
    trunk/py/scripts/tools/bi_farm/new_blend_2_frames.py
    trunk/py/scripts/tools/bi_farm/new_master.py

Modified: trunk/py/scripts/tools/bi_farm/master_ui.py
===================================================================
--- trunk/py/scripts/tools/bi_farm/master_ui.py	2012-07-30 07:34:42 UTC (rev 3658)
+++ trunk/py/scripts/tools/bi_farm/master_ui.py	2012-07-30 08:58:43 UTC (rev 3659)
@@ -78,9 +78,11 @@
 
 class Job:
     priority_types = ('Low', 'Medium', 'High', 'Critical', 'Final')
-    step_types = ('1', '2', '3', '5', '10')
+    step_types = ('1', '2', '3', '5', '10',  # step option
+                  '-3', '-5', '-7', '-13')   # total frame option
     quality_types = ('File settings', 'Final 4K', 'Final 2K', 'Final 1K', 'Final 0.5k', 'Final HD', 'Preview 1K', 'NoShading 1K', 'Simplified 1K')
     status_types = ('Disabled', 'In Progress', 'Done!')
+    order_types = ('SEQUENTIAL', 'SPARSE')
     processor_types = ('CPU', 'CUDA') # could add openal later?
 
     def __init__(self, id, revision, quality, step, processor):
@@ -93,6 +95,7 @@
         self.enabled = False
         self.stats = ""
         self.step = step
+        self.order = 'SEQUENTIAL'
         self.processor = processor
 
     @staticmethod
@@ -120,6 +123,8 @@
                     job.step = 1
                 if not hasattr(job, "processor"):
                     job.processor = 'CPU'
+                if not hasattr(job, "order"):
+                    job.processor = 'SEQUENTIAL'
             f.close()
         except IOError:
             print("No jobs file, starting with 0 jobs.")
@@ -170,6 +175,12 @@
     Job.dump()
 
 
+def job_set_order(id, order):
+    # changes in priority are detected in master loop
+    Job.find(id).order = order
+    Job.dump()
+
+
 def job_add(id, revision, quality, step, processor):
     # master loop will find the new job when refreshes it's jobs list in
     # the outer loop, so actually starting to render may take a while
@@ -462,7 +473,7 @@
 
             # jobs
             section("Jobs")
-            table_begin("", "File", "Revision", "Quality", "Status", "Progress", "Stats", "Priority", "Step", "Processor", "")
+            table_begin("", "File", "Revision", "Quality", "Status", "Progress", "Stats", "Priority", "Step", "Processor", "Order", "")
 
             for job in JOBS:
                 output("<tr>\n")
@@ -494,8 +505,14 @@
                 # output("<td>")
                 # dropdown('job_set_processor', job.id, job.processor, Job.processor_types)
                 # output("%d" % job.processor)
+                # output("</td>\n")
                 output("<td>" + job.processor + "</td>\n")
 
+                output("<td>")
+                dropdown('job_set_order', job.id, job.order, Job.order_types)
+                output("%d" % job.order)
+                output("</td>\n")
+
                 output("<td id='td-toggle'>")
                 action('job_remove(\\"%s\\")' % job.id, "X", "Are you sure you want to remove this job?")
                 output("</td>\n")

Modified: trunk/py/scripts/tools/bi_farm/new_blend_2_frames.py
===================================================================
--- trunk/py/scripts/tools/bi_farm/new_blend_2_frames.py	2012-07-30 07:34:42 UTC (rev 3658)
+++ trunk/py/scripts/tools/bi_farm/new_blend_2_frames.py	2012-07-30 08:58:43 UTC (rev 3659)
@@ -28,16 +28,32 @@
 
 # internal access only
 def _blend_2_frames_start_end(path, start, end, step=1):
+    """Negative step for absolute frame count"""
     images = []
     fname = os.path.splitext(os.path.basename(path))[0]
     assert(step != 0)
 
     format_string = os.path.join(REND_DIR, fname, fname + "_%.6d.exr")
-    frame = start
-    while frame <= end:
-        images.append((frame, format_string % frame))
-        frame += step
+    
+    # negative steps means total number
+    if step < 0:
+        if (-step >= (end - start)):
+            step = 1
 
+
+    if step > 0:
+        frame = start
+        while frame <= end:
+            images.append((frame, format_string % frame))
+            frame += step        
+    else:
+        total = -step
+        for i in range(total):
+            fac = i / (total - 1)
+            frame = start + int(fac * (end - start))
+            images.append((frame, format_string % frame))
+            
+
     return images
 
 

Modified: trunk/py/scripts/tools/bi_farm/new_master.py
===================================================================
--- trunk/py/scripts/tools/bi_farm/new_master.py	2012-07-30 07:34:42 UTC (rev 3658)
+++ trunk/py/scripts/tools/bi_farm/new_master.py	2012-07-30 08:58:43 UTC (rev 3659)
@@ -218,6 +218,26 @@
     return kill_non_critical
 
 
+def _sparse_shuffle(ls):
+    # could use nicer algo
+    # main point is first frames are first/last/mid
+    import array
+    check = array.array('b', [False]) * len(ls)
+    permute = []
+    step_fac = 1.0
+    while len(permute) < len(ls):
+        step = int(step_fac * len(ls))
+        if step < 1:
+            step = 1
+        for i in range(0, len(ls), step):
+            if not check[i]:
+                permute.append(i)
+                check[i] = 1
+        step_fac *= 0.5
+
+    ls[:] = [ls[i] for i in permute]
+
+
 def job_find(slaves_state, do_finals, num_frames,
              filter_job=None):
 
@@ -248,6 +268,9 @@
         # list images for this job
         images = job_images(job)
 
+        if job.order == 'SPARSE':
+            _sparse_shuffle(images)
+
         # find frame that is not finished yet
         for frame, path in images:
             if not os.path.exists(path):



More information about the Bf-extensions-cvs mailing list