forked from msmith93/brenda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brenda-work
executable file
·122 lines (107 loc) · 5.29 KB
/
brenda-work
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/python
# Brenda -- Blender render tool for Amazon Web Services
# Copyright (C) 2013 James Yonan <[email protected]>
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys, os, optparse
from brenda import config, work, aws, version
def main():
usage = """"\
usage: %s [options] push|status|reset
Version:
Brenda %s
Synopsis:
Manage render farm work queue.
Commands:
push : push tasks to SQS queue to be executed by render farm.
status : show the number of outstanding tasks in SQS queue.
reset : clear all tasks in SQS queue.
Required config vars:
AWS_ACCESS_KEY : Amazon Web Services access key.
AWS_SECRET_KEY : Amazon Web Services secret key.
WORK_QUEUE : name of SQS queue (e.g. sqs://QUEUE) used to stage render
work. Will be automatically created if it doesn't exist.
Optional config vars:
SQS_REGION : SQS region name, defaults to US standard.
VISIBILITY_TIMEOUT : SQS visibility timeout in seconds (default=120).
SQS will return a task to the queue if the brenda-node
worker doesn't acknowledge or complete the pending
task over this period of time.
Sample task script (single frame render):
blender -b *.blend -F PNG -o $OUTDIR/frame_###### -s $START -e $END -j $STEP -t 0 -a
Sample task script (subframe render):
cat >subframe.py <<EOF
import bpy
bpy.context.scene.render.border_min_x = $SF_MIN_X
bpy.context.scene.render.border_max_x = $SF_MAX_X
bpy.context.scene.render.border_min_y = $SF_MIN_Y
bpy.context.scene.render.border_max_y = $SF_MAX_Y
bpy.context.scene.render.use_border = True
EOF
blender -b *.blend -P subframe.py -F PNG -o $OUTDIR/frame_######_X-$SF_MIN_X-$SF_MAX_X-Y-$SF_MIN_Y-$SF_MAX_Y -s $START -e $END -j $STEP -t 0 -a
Examples:
Using a task script such as "single frame render" above, push a separate
task to render each frame from 1 to 1440:
$ brenda-work -T [SINGLE_FRAME_TASK_SCRIPT] -e 1440 push
You want to render a 16 minute short (21,600 frames), but each frame takes
an average of 4 computer hours to render, so you want to break each frame
into 16 subframes (4x4) to reduce the subframe render time to 15 minutes:
$ ./brenda-work -T [SUBFRAME_TASK_SCRIPT] -e 21600 -X 4 -Y 4 -d push
Show number of pending tasks in work queue:
$ brenda-work status
Remove all tasks from queue, reseting task queue to empty state:
$ brenda-work reset""" % (sys.argv[0], version.VERSION)
parser = optparse.OptionParser(usage)
defconf = aws.config_file_name()
parser.add_option("-c", "--config", dest="config", default=defconf,
help="Configuration file (default: %default)")
parser.add_option("-d", "--dry-run", action="store_true", dest="dry_run",
help="Show tasks that would be pushed to work queue, but don't actually push anything")
parser.add_option("-T", "--task-script", dest="task_script",
help="Script template file for a single task. Macros: $OUTDIR: render output directory, $START, $END, $STEP: frame parameters.")
parser.add_option("-s", "--start", type="int", dest="start", default=1,
help="Start frame to render, default=%default")
parser.add_option("-e", "--end", type="int", dest="end",
help="End frame to render")
parser.add_option("-X", "--subdiv-x", type="int", dest="subdiv_x", default=0,
help="Render subframes, number of subdivisions on X axis")
parser.add_option("-Y", "--subdiv-y", type="int", dest="subdiv_y", default=0,
help="Render subframes, number of subdivisions on Y axis")
parser.add_option("-S", "--task-size", type="int", dest="task_size", default=1,
help="Number of frames per task, default=%default")
parser.add_option("-r", "--randomize", action="store_true", dest="randomize",
help="Randomize tasks before pushing to work queue")
parser.add_option("-H", "--hard", action="store_true", dest="hard",
help="For reset, delete the SQS queue itself")
# Get command line arguments...
( opts, args ) = parser.parse_args()
#print "OPTS", (opts, args)
if not args:
print("no work, run with -h for usage", file=sys.stderr)
sys.exit(2)
# Get configuration
conf = config.Config(opts.config, 'BRENDA_')
#print "CONFIG", conf
# dispatch
if args[0] == 'push':
work.push(opts, args, conf)
elif args[0] == 'status':
work.status(opts, args, conf)
elif args[0] == 'reset':
work.reset(opts, args, conf)
else:
print("unrecognized command:", args[0], file=sys.stderr)
sys.exit(2)
main()