def batch_execute(args: dict): # get list of commands from batch file: bare_cmd_lines = [] from batch import Batch batch = Batch(args['batch_file']) batch_commands = batch.get_commands() # the not-yet-expanded commands for command in batch_commands: bare_cmd_lines.extend(command.get_cmd_lines()) # assemble command lines and experiment data output directories: cmd_lines = [] batch_offset = 1 for bare_cmd_line in bare_cmd_lines: # experiment data path: expname = '%s-%04d-%s' % (args['expname'], batch_offset, os.path.basename(bare_cmd_line[0])) # command: cmd_line = [sys.argv[0]] # recursively call ourselves: if args['dry_run']: cmd_line.extend(['--dry-run']) cmd_line.extend(['--monitor-port', '%d' % (args['monitor_port'] + batch_offset)]) cmd_line.extend(['--vnc-display', '%d' % (args['vnc_display'] + batch_offset)]) cmd_line.extend(['--build', utils.BUILD]) cmd_line.extend(['--network', args['network']]) cmd_line.extend(['--memory', args['memory']]) cmd_line.extend([args['VM[:snapshot]']]) cmd_line.extend(['sym']) cmd_line.extend(['--command-port', '%d' % (args['command_port'] + batch_offset)]) cmd_line.extend(['--expname', expname]) cmd_line.extend(['--config-file', command.config]) if args['timeout']: cmd_line.extend(['--timeout', '%d' % args['timeout']]) if args['env_var']: cmd_line.extend(['--env-var', args['env_var']]) cmd_line.extend([args['snapshot']]) cmd_line.extend(bare_cmd_line) cmd_lines.append(' '.join(cmd_line)) # counter: batch_offset += 1 utils.execute(assemble_parallel_cmd_line(args), stdin='\n'.join(cmd_lines))