forked from jamesyonan/brenda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brenda-work
executable file
·112 lines (98 loc) · 4.89 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
#!/usr/bin/env python
# Brenda -- Render farm 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/>.
import sys, optparse
from brenda import config, work, version, utils
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:
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.
CREDENTIAL_PROFILE : Profile name to retrieve credentials from
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.
MESSAGE_RETENTION : Number of seconds that messages wil be kept in the queue (default=1209600, 14 days)
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)
parser.add_option("-c", "--config", dest="config", default=utils.config_file_name(), metavar="FILE",
help="Configuration file (default: %default)")
parser.add_option("-l", "--logfile", dest="logfile", metavar="FILE",
help="Save log to file")
parser.add_option("-v", "--loglevel", dest="loglevel",
help="Level of events to log (default: INFO)")
parser.add_option("-T", "--task-script", dest="task_script",
help="Script template file for a single task.")
parser.add_option("-s", "--start", type="int", dest="start", default=0,
help="Start frame to render, default=%default")
parser.add_option("-e", "--end", type="int", dest="end",
help="End frame to render")
parser.add_option("-j", "--step", type="int", dest="step", default=1,
help="Frame increment steps, default=%default")
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("-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("-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 >>sys.stderr, "no work, run with -h for usage"
sys.exit(2)
# Get configuration
conf = config.Config(opts.config, 'BRENDA_')
# print "CONFIG", conf
utils.setup_logger(opts, 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 >>sys.stderr, "unrecognized command:", args[0]
sys.exit(2)
main()