Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# (c) Stefan Countryman, 2019
3import os
4from copy import deepcopy
5from llama.dev.dv import (
6 __doc__,
7 REDUCERS,
8 print_descriptions,
9 print_defaults,
10 apply_default_cli_args,
11 run_workers,
12 Command,
13 get_droplets,
14 get_parser,
15)
18def main():
19 """Execute as a command-line utility."""
20 parser = get_parser()
21 args = parser.parse_args()
22 if args.descriptions:
23 print_descriptions()
24 exit()
25 if args.defaults:
26 print_defaults()
27 exit()
28 if args.cmd is None:
29 parser.print_help()
30 print("MUST PROVIDE A COMMAND!")
31 exit(1)
32 cmd = Command(args.cmd, args.local, args.args)
33 # apply defaults and overwrite args and cmd
34 args = apply_default_cli_args(cmd.defaults)
35 cmd = Command(args.cmd, args.local, args.args)
36 droplets = get_droplets(args.pattern)
37 env = deepcopy(os.environ)
38 env['DROPNUM'] = str(len(droplets))
39 cmd.setup(env)
40 outs = run_workers(cmd, droplets, args.format,
41 args.prelaunch, args.connections, args.timeout)
42 if args.reduce is not None:
43 REDUCERS[args.reduce](outs)
44 cmd.cleanup(env)
47if __name__ == '__main__':
48 main()