"""A libusb1-based fastboot implementation.""" import binascii import collections import cStringIO import gflags import logging import os import struct from . import usb_exceptions FLAGS = gflags.FLAGS gflags.DEFINE_integer('fastboot_download_chunk_size_kb', 1024, 'Size of chunks to send when downloading fastboot images') _LOG = logging.getLogger('fastboot') DEFAULT_MESSAGE_CALLBACK = lambda m: logging.info('Got %s from device', m) FastbootMessage = collections.namedtuple( # pylint: disable=invalid-name 'FastbootMessage', ['message', 'header']) class FastbootProtocol(object): """Encapsulates the fastboot protocol.""" FINAL_HEADERS = {'OKAY', 'DATA'} def __init__(self, usb): """Constructs a FastbootProtocol instance.
import sys import math logs = sys.stderr from collections import defaultdict import time from mytime import Mytime import gflags as flags FLAGS=flags.FLAGS flags.DEFINE_string("weights", None, "weights file (feature instances and weights)", short_name="w") flags.DEFINE_boolean("featstat", False, "print feature stats") flags.DEFINE_string("outputweights", None, "write weights (in short-hand format); - for STDOUT", short_name="ow") flags.DEFINE_boolean("autoeval", True, "use automatically generated eval module") flags.DEFINE_integer("doublehash", 1, "two-layer hash: weights[action][feature]") flags.DEFINE_boolean("use_template_id", True, "map template names (\"s0t-s1lct\") to integers") flags.DEFINE_boolean("tuplefeats", False, "(s0t, s1t) instead of \"s0t-s1t\"") #from vocab import Vocab from wvector import WVector # doublehash = 1 class Model(object): '''templates and weights.''' names = ["SHIFT", "LEFT", "RIGHT"] mapnames = {"SHIFT":0, "LEFT":1, "RIGHT":2} indent = " " * 4 eval_module = None # by default, use my handwritten static_eval() @staticmethod
from spinn.util.misc import recursively_set_device FLAGS = gflags.FLAGS def convert(inpt, outp, gpu=-1): ckpt = torch.load(inpt) if gpu < 0: ckpt['model_state_dict'] = { k: v.cpu() for k, v in ckpt['model_state_dict'].iteritems() } else: ckpt['model_state_dict'] = { k: v.cuda() for k, v in ckpt['model_state_dict'].iteritems() } ckpt['optimizer_state_dict'] = recursively_set_device( ckpt['optimizer_state_dict'], gpu) torch.save(ckpt, FLAGS.outp) if __name__ == '__main__': gflags.DEFINE_string("inpt", None, "") gflags.DEFINE_string("outp", None, "") gflags.DEFINE_integer("gpu", -1, "") FLAGS(sys.argv) convert(FLAGS.inpt, FLAGS.outp)
#!/usr/bin/env python from mincepie import mapreducer, launcher import gflags import os import cv2 from PIL import Image # gflags gflags.DEFINE_string( 'image_lib', 'opencv', 'OpenCV or PIL, case insensitive. The default value is the faster OpenCV.') gflags.DEFINE_string( 'input_folder', '', 'The folder that contains all input images, organized in synsets.') gflags.DEFINE_integer('output_side_length', 256, 'Expected side length of the output image.') gflags.DEFINE_string( 'output_folder', '', 'The folder that we write output resized and cropped images to') FLAGS = gflags.FLAGS class OpenCVResizeCrop: def resize_and_crop_image(self, input_file, output_file, output_side_length=256): '''Takes an image name, resize it and crop the center square ''' img = cv2.imread(input_file) height, width, depth = img.shape
from pysc2.lib import app from pysc2.lib import features from pysc2.lib import FUNCTIONS from s2clientprotocol import sc2api_pb2 as sc_pb FLAGS = flags.FLAGS flags.DEFINE_string(name='hq_replay_set', default='../high_quality_replays/Terran_vs_Terran.json', help='File storing replays list') flags.DEFINE_string(name='parsed_replays', default='../parsed_replays', help='Path for parsed actions') flags.DEFINE_string(name='infos_path', default='../replays_infos', help='Paths for infos of replays') flags.DEFINE_integer(name='step_mul', default=8, help='step size') flags.DEFINE_integer(name='skip', default=96, help='# of skipped frames') def sample_action_from_player(action_path): feat = features.Features(screen_size_px=(1, 1), minimap_size_px=(1, 1)) with open(action_path) as f: actions = json.load(f) frame_id = 0 result_frames = [] for action_strs in actions: action_name = None for action_str in action_strs: action = Parse(action_str, sc_pb.Action()) try:
import matplotlib.animation as animation from modules.control.proto import control_cmd_pb2 from modules.planning.proto import planning_pb2 LAST_TRAJ_DATA = [] LAST_TRAJ_T_DATA = [] CURRENT_TRAJ_DATA = [] CURRENT_TRAJ_T_DATA = [] INIT_V_DATA = [] INIT_T_DATA = [] begin_t = None last_t = None lock = threading.Lock() FLAGS = gflags.FLAGS gflags.DEFINE_integer("data_length", 500, "Planning plot data length") def callback(planning_pb): global INIT_V_DATA, INIT_T_DATA global CURRENT_TRAJ_DATA, LAST_TRAJ_DATA global CURRENT_TRAJ_T_DATA, LAST_TRAJ_T_DATA global begin_t, last_t lock.acquire() if begin_t is None: begin_t = planning_pb.header.timestamp_sec current_t = planning_pb.header.timestamp_sec if last_t is not None and abs(current_t - last_t) > 1: begin_t = planning_pb.header.timestamp_sec
import json import Queue import boto import boto.sdb import cloudydict from boto.sqs.connection import SQSConnection from boto.sqs.message import Message from StringIO import StringIO FLAGS = gflags.FLAGS from threading import Thread gflags.DEFINE_string('domain', 'foliage', 'Domain') gflags.DEFINE_integer('prefetch', 20, 'Images to prefetch') gflags.DEFINE_boolean('delete', False, 'Remove items from queue when done processing?') gflags.DEFINE_string('region', 'us-west-1', 'AWS region to connect to') gflags.DEFINE_string('source', 'foliage-outdoors4', 'Source queue for images') class Reader(Thread): def __init__(self, queue): Thread.__init__(self) self._queue = queue self.daemon = True def run(self): try:
""" import gflags import logging import time import traceback from pygaga.helpers.logger import log_init from pygaga.helpers.dbutils import get_db_engine from guang_crawler.taobao_item import TaobaoItem from guang_crawler.taobao_category import TaobaoCategory from guang_crawler.taobao_term import TermFactory logger = logging.getLogger('CrawlLogger') FLAGS = gflags.FLAGS gflags.DEFINE_boolean('all', False, "update all shop") gflags.DEFINE_integer('shopid', 0, "update shop id") gflags.DEFINE_integer('interval', 0, "crawl interval between items") gflags.DEFINE_boolean('force', False, "is update offline shops?") gflags.DEFINE_boolean('commit', False, "is commit data into database?") gflags.DEFINE_boolean('debug_parser', False, 'is debug?') gflags.DEFINE_string('path', "/space/wwwroot/image.guang.j.cn/ROOT/images/", "is upload to nfs?") SHOP_CRAWL_STATUS_NONE = 0 SHOP_CRAWL_STATUS_WAIT = 1 SHOP_CRAWL_STATUS_CRAWLING = 2 SHOP_CRAWL_STATUS_ERROR = 3 ITEM_STATUS_BLACKLIST = 3 ITEM_STATUS_OFFLINE = 2 ITEM_STATUS_ACTIVE = 1
# limitations under the License. # """Tool to print subsets supported by a given font file. """ import os import gflags as flags from gftools.util import google_fonts as fonts from google.apputils import app FLAGS = flags.FLAGS flags.DEFINE_integer( 'min_pct', 0, 'What percentage of subset codepoints have to be supported' ' for a non-ext subset.') flags.DEFINE_integer( 'min_pct_ext', 0, 'What percentage of subset codepoints have to be supported' ' for a -ext subset.') def main(argv): for arg in argv[1:]: subsets = fonts.SubsetsInFont(arg, FLAGS.min_pct, FLAGS.min_pct_ext) for (subset, available, total) in subsets: print '%s %s %d/%d' % (os.path.basename(arg), subset, available, total)
class SimpleData(ArithmeticDataType): LABELS = NUMBERS def is_label(self, x): try: return self.LABELS.index(x) except BaseException: return -1 if __name__ == '__main__': FLAGS = gflags.FLAGS gflags.DEFINE_integer("length", 5, "") gflags.DEFINE_integer("limit", 100, "") gflags.DEFINE_boolean("balance_length", False, "") gflags.DEFINE_string( "exclude", None, "If not None, exclude any example that appears in this file.") gflags.DEFINE_enum("data_type", "simple", ["simple", "sign"], "") FLAGS(sys.argv) limit = FLAGS.limit length = FLAGS.length if FLAGS.data_type == "simple": data_type = SimpleData() elif FLAGS.data_type == "sign": data_type = SignData()
# Alternatively, you can specify table properties. ./trig_lookup_tables.py \ --num_atan_samples=400 \ --num_sin_samples=513 \ --output_files=trig_lookup_tables.h """ import os import sys import gflags import makani import numpy gflags.DEFINE_integer('num_atan_samples', 400, 'Number of samples in the arctangent table between ' '0 and 1 inclusive.') # The sine and cosine lookup function runs significantly faster when # the number of samples is one more than a power of two. gflags.DEFINE_integer('num_sin_samples', 513, 'Number of samples in the sine table between ' '0 and pi/2 inclusive.') gflags.DEFINE_string('output_file', os.path.join(makani.HOME, 'avionics/common/fast_math/' 'trig_lookup_tables.h'), 'File name of the header file to output.') FLAGS = gflags.FLAGS
# coding: utf-8 import gflags import sys from pygaga.helpers.logger import log_init from guang_crawler.crawl_image_impl import crawl_image_main gflags.DEFINE_string('path', "/space/wwwroot/image.guang.j.cn/ROOT/images/", "image path") gflags.DEFINE_string('org_path', "/space/wwwroot/image.guang.j.cn/ROOT/org_images/", "org image path") gflags.DEFINE_string('crawl_path', "/space/crawler/image_crawler/static", "image path") gflags.DEFINE_integer('itemid', 0, "crawl item id") gflags.DEFINE_integer('numid', 0, "crawl item num id") gflags.DEFINE_integer('limit', 0, "limit crawl items count") gflags.DEFINE_string('where', "", "additional where sql, e.g. a=b and c=d") gflags.DEFINE_boolean('all', False, "crawl all items") gflags.DEFINE_boolean('pending', False, "crawl pending items") gflags.DEFINE_boolean('commit', True, "is commit data into database?") gflags.DEFINE_boolean('removetmp', False, "is remove temperary image files after crawl?") gflags.DEFINE_boolean('force', False, "is force crawl?") #gflags.DEFINE_boolean('uploadfastdfs', True, "is upload to fastdfs?") #gflags.DEFINE_boolean('uploadnfs', False, "is upload to nfs?") #gflags.DEFINE_boolean('uploadorg', True, "is upload origin image to nfs?") if __name__ == "__main__": log_init(["CrawlLogger", "urlutils"], "sqlalchemy.*")
matplotlib.use('QT4Agg') from matplotlib import pyplot # pylint: disable=g-import-not-at-top import numpy as np makani.SetRunfilesDirFromBinaryPath() _AERO_OUTPUTS = ['Cx', 'Cy', 'Cz', 'Cl', 'Cm', 'Cn', 'CL', 'CD'] _AERO_VARS = ['alpha', 'beta', 'p', 'q', 'r', 'ail', 'ele', 'rud'] _VALID_SPEC_DESCRIPTION = ( 'Valid specifiers are of the form "<output>" or "d<output>/d<var>", where ' '<output> is one of %s, and <var> is one of %s.' % (_AERO_OUTPUTS, _AERO_VARS)) gflags.DEFINE_float('re', 5e6, 'Reynolds number.') gflags.DEFINE_integer('fig_rows', 4, 'Number of rows in figure grid.') gflags.DEFINE_integer('fig_cols', 4, 'Number of columns in figure grid.') flag_types.DEFINE_linspace('alpha_degs', '0.0, 12.0, 49', 'Linspace of alpha values in degrees.') flag_types.DEFINE_linspace('beta_degs', '0.0, 0.0, 1', 'Linspace of beta values in degrees.') gflags.DEFINE_list( 'specs', [ 'CL', 'CD', 'Cy', 'Cl', 'Cm', 'Cn', 'dCL/dalpha', 'dCm/dalpha', 'dCm/dq', 'dCl/dail', 'dCm/dele', 'dCn/drud' ], 'Comma-separated list of specifiers for values to plot. ' + _VALID_SPEC_DESCRIPTION) gflags.DEFINE_float('thrust_coeff', 0.0, 'Total thrust coefficient.') FLAGS = gflags.FLAGS
import zmq import sys import gflags import time import multiprocessing import threading import msgpack import msgpack_numpy msgpack_numpy.patch() from .inference import find_controller gflags.DEFINE_string('addr', '', '') gflags.DEFINE_string('weights_file', '', '') gflags.DEFINE_string('class_path', '', 'If specified will use this class to load weights file.') gflags.DEFINE_integer('n_worker', 1, '') FLAGS = gflags.FLAGS FLAGS(sys.argv) def backend_process(listen_addr): context = zmq.Context() socket = context.socket(zmq.REP) socket.connect(listen_addr) if FLAGS.class_path != '': print('inference server class path:', FLAGS.class_path) # class_path is of the form: package1.[package2...].class_name toks = FLAGS.class_path.split('.') module_path = '.'.join(toks[:-1])
from model import Model from deptree import DepTree, DepVal from mytime import Mytime mytime = Mytime() import time # TODO : MERGE from wvector import WVector import gc import gflags as flags FLAGS=flags.FLAGS flags.DEFINE_integer("beam", 8, "beam width", short_name="b") flags.DEFINE_integer("leftbeam", 1000, "leftptrs beam width") # number of left items (predictors to be combined w/ current) flags.DEFINE_integer("kbest", 0, "kbest", short_name="k") flags.DEFINE_boolean("forest", False, "dump the forest") flags.DEFINE_integer("debuglevel", 0, "debug level (0: no debug info, 1: brief, 2: detailed)", short_name="D") flags.DEFINE_boolean("dp", True, "use dynamic programming (merging)") flags.DEFINE_boolean("newbeam", False, "new dp beaming") flags.DEFINE_boolean("merge", False, "new dp beaming") flags.DEFINE_boolean("naive", False, "do not merge at all") #flags.DEFINE_boolean("donotcarei", False, "left boundary i not included in signature (state equality)") #TODO: feature reengineering + learning #TODO: cube pruning #TODO: forest generation (and k-best)
result = self.client.Log(messages=[ log_entry, ]) if result != scribe.ResultCode.OK: raise ScribeLogError(result) self.transport.close() except TTransportException: raise def scribe_log(message, category='default', host='127.0.0.1', port=1463): s = Scribe(host=host, port=port, category=category) s.emit(message) if __name__ == "__main__": import gflags from pygaga.helpers.logger import log_init FLAGS = gflags.FLAGS gflags.DEFINE_string("cate", 'test', 'category name', short_name='c') gflags.DEFINE_string("msg", '', 'message', short_name='m') gflags.DEFINE_string("host", '127.0.0.1', 'host name', short_name='h') gflags.DEFINE_integer("port", 1463, 'port', short_name='p') log_init() scribe_log(FLAGS.msg, FLAGS.cate, FLAGS.host, FLAGS.port)
import paddle.v2 as paddle import paddle.trainer.config_parser as cp import time import data.sun3d as sun3d import utils.utils as uts from utils.vis import visualize_prediction import layers.cost_layers as cost_layers import network.demon_net as d_net from paddle.utils import preprocess_util from collections import OrderedDict import DemonPredictor as dp import matplotlib.pyplot as plt gflags.DEFINE_integer('gpu_id', 1, 'Gpu id used') FLAGS = gflags.FLAGS def test_video(): # PaddlePaddle init cv2.namedWindow("frame") cv2.namedWindow("depth") cv2.namedWindow("normal") base_path = '/home/peng/Data/videos/' video_names = preprocess_util.list_files(base_path) prefix_len = len(base_path) for name in video_names[0:]: name = name[prefix_len:] output_path = base_path + name[:-4] + '/' if os.path.exists(output_path):
from __future__ import with_statement import collections import gflags import itertools import multiprocessing FLAGS = gflags.FLAGS gflags.DEFINE_boolean('parallel', False, "Run in parallel mode", short_name='p') gflags.DEFINE_integer("max_cpu", multiprocessing.cpu_count() / 2 or 1, "Global limitation of CPU to run python in parallel.") class SimpleMapReduce(object): def __init__(self, map_func, reduce_func, num_workers=None): """ map_func Function to map inputs to intermediate data. Takes as argument one input value and returns a tuple with the key and a value to be reduced. reduce_func Function to reduce partitioned version of intermediate data to final output. Takes as argument a key as produced by map_func and a sequence of the values associated with that key. num_workers
'reduce', 'mapdone', 'reducedone', ]) TASK = Enum([ 'START', 'MAPPING', 'REDUCING', 'FINISHED', ]) # flags defined for connection gflags.DEFINE_string("password", "default", "The password for server client authentication") gflags.DEFINE_integer("port", 11235, "The port number for the mapreduce task") gflags.DEFINE_string("address", "127.0.0.1", "The address of the server") gflags.DEFINE_integer( "timeout", 60, "The number of seconds before a client stops reconnecting") gflags.DEFINE_integer( "report_interval", 10, "The interval between which we report the elapsed time of mapping") # FLAGS FLAGS = gflags.FLAGS class Protocol(asynchat.async_chat, object): """Communication protocol The Protocol class defines the basic protocol that both the server and
from ryu.ofproto import ofproto_parser from ryu.ofproto import ofproto_v1_0 from ryu.ofproto import ofproto_v1_0_parser from ryu.ofproto import ofproto_v1_2 from ryu.ofproto import ofproto_v1_2_parser from ryu.ofproto import nx_match from ryu.controller import dispatcher from ryu.controller import handler from ryu.controller import ofp_event LOG = logging.getLogger('ryu.controller.controller') FLAGS = gflags.FLAGS gflags.DEFINE_string('ofp_listen_host', '', 'openflow listen host') gflags.DEFINE_integer('ofp_tcp_listen_port', ofproto.OFP_TCP_PORT, 'openflow tcp listen port') class OpenFlowController(object): def __init__(self): super(OpenFlowController, self).__init__() # entry point def __call__(self): #LOG.debug('call') self.server_loop() def server_loop(self): server = StreamServer( (FLAGS.ofp_listen_host, FLAGS.ofp_tcp_listen_port), datapath_connection_factory)
# Identify non blank partition non_blank_partition = [] for j in range(batch_size): idx = get_non_blank_partition(batch['masked_im_1'][j], batch['masked_im_2'][j]) non_blank_partition.append(idx) batch['non_blank_partition'] = non_blank_partition yield batch if __name__ == "__main__": # Settings gflags.DEFINE_enum("resnet", "34", ["18", "34", "50", "101", "152"], "Specify Resnet variant.") gflags.DEFINE_boolean("improc_from_scratch", False, "Whether to train the image processor from scratch") gflags.DEFINE_boolean("vertical_mask", False, "Whether to just use a vertical mask on images. Otherwise the mask is random") gflags.DEFINE_integer("image_size", 128, "Width and height in pixels of the images to give to the agents") FLAGS(sys.argv) data_path = '/path/to/data/oneshape_simple_textselect' embed_path = '/path/to/embedding/glove-100d.txt' mode = 'train' size = 100 ds_type = 'agreement' name = 'oneshape_simple_textselect' batch_size = 20 random_seed = 12 img_feats = 'avgpool_512' shuffle = True cuda = False dataloader = load_shapeworld_dataset(data_path, embed_path, mode, size, ds_type, name, batch_size, random_seed, shuffle, img_feats, cuda, truncate_final_batch=False) for i_batch, batch in enumerate(dataloader):
# ./jain-krishna.py --num_species=40 --catalysis_proba=0.01282051282051282 --random_seed=0 --num_steps=2000 import collections import ctypes import itertools import json import os import struct import sys import gflags import numpy as np import scipy.linalg import scipy.sparse.linalg gflags.DEFINE_integer('num_species', None, '') gflags.DEFINE_float('catalysis_proba', None, '') gflags.DEFINE_float('m', None, '') gflags.DEFINE_integer('num_steps', None, '') gflags.DEFINE_integer('random_seed', None, '') gflags.DEFINE_string('out', None, '') gflags.DEFINE_string('out_format', None, '') gflags.DEFINE_boolean('out_buffering', True, '') gflags.DEFINE_boolean('debug', False, '') gflags.DEFINE_boolean('plot', False, '') FLAGS = gflags.FLAGS # Parameters # s # p / m # n
import gflags import cPickle import numpy as np root_dir = os.path.dirname(os.path.abspath("__file__")) + "/../../" sys.path.append(root_dir + "code/") if not gflags.FLAGS.has_key("model_dir"): gflags.DEFINE_string("model_dir", root_dir + "model/ResNet-%d/" % layer_num, "set model dir") if not gflags.FLAGS.has_key("feature_layer_names"): gflags.DEFINE_string("feature_layer_names", "['fc5']", "set feature layer names") if not gflags.FLAGS.has_key("device_id"): gflags.DEFINE_integer("device_id", 0, "set device id") if not gflags.FLAGS.has_key("ratio"): gflags.DEFINE_float("ratio", -1.0, "set image ratio") if not gflags.FLAGS.has_key("scale"): gflags.DEFINE_float("scale", 1.1, "set image scale") if not gflags.FLAGS.has_key("resize_height"): gflags.DEFINE_integer("resize_height", 144, "set image height") if not gflags.FLAGS.has_key("resize_width"): gflags.DEFINE_integer("resize_width", 144, "set image width") if not gflags.FLAGS.has_key("raw_scale"): gflags.DEFINE_float("raw_scale", 255.0, "set raw scale") if not gflags.FLAGS.has_key("input_scale"): gflags.DEFINE_float("input_scale", 0.0078125, "set raw scale") if not gflags.FLAGS.has_key("gray"): gflags.DEFINE_boolean("gray", False, "set gray") if not gflags.FLAGS.has_key("oversample"):
from pykeg.hw.kegboard import crc16 _DEVICES = glob.glob('/dev/ttyUSB*') + glob.glob('/dev/cu.usbserial*') if _DEVICES: _DEFAULT_PORT = _DEVICES[0] else: _DEFAULT_PORT = '/dev/ttyUSB0' FLAGS = gflags.FLAGS gflags.DEFINE_string( 'kegboard_device', _DEFAULT_PORT, 'An explicit device file (eg /dev/ttyUSB0) on which to listen for kegboard ' 'packets.') gflags.DEFINE_integer('kegboard_speed', 115200, 'Baud rate of device at --kegboard_device') KBSP_PREFIX = "KBSP v1:" KBSP_PAYLOAD_MAXLEN = 112 KBSP_TRAILER = "\r\n" class KegboardError(Exception): """Generic error with Kegboard""" class MessageError(KegboardError): """Generic error in Message class""" class UnknownMessageError(MessageError):
# import torchvision.models as models import models.hantman_feedforward as hantman_feedforward from torch.autograd import Variable import helpers.hungarian_matching as hungarian_matching DEBUG = False # flags for processing hantman files. gflags.DEFINE_string("out_dir", None, "Output directory path.") gflags.DEFINE_string("train_file", None, "Train data filename (hdf5).") gflags.DEFINE_string("test_file", None, "Test data filename (hdf5).") gflags.DEFINE_string("valid_file", None, "Valid data filename (hdf5).") gflags.DEFINE_string("display_dir", None, "Directory of videos for display.") gflags.DEFINE_string( "video_dir", None, "Directory for processing videos, (codecs might be different from display)") gflags.DEFINE_integer("total_iterations", 0, "Don't set for this version of the training code.") # gflags.DEFINE_boolean("debug", False, "Debug flag, work with less videos.") gflags.DEFINE_integer("update_iterations", 50, "Number of iterations to output logging information.") gflags.DEFINE_integer("iter_per_epoch", None, "Number of iterations per epoch. Leave empty.") gflags.DEFINE_integer("save_iterations", 10, ("Number of iterations to save the network (expensive " "to do this).")) gflags.DEFINE_integer("total_epochs", 500, "Total number of epochs.") gflags.DEFINE_integer("seq_len", 1500, "Sequence length.") gflags.DEFINE_string("load_network", None, "Cached network to load.") gflags.DEFINE_boolean("threaded", True, "Threaded Data loadered.") gflags.DEFINE_boolean("reweight", True, "Try re-weighting.") # gflags.DEFINE_float( # "hantman_weight_decay", 0.0001, "Weight decay value.")
#!/usr/bin/env python """Defines some flags.""" import gflags gflags.DEFINE_integer('num_replicas', 3, 'Number of replicas to start') gflags.DEFINE_boolean('rpc2', True, 'Turn on the usage of RPC2.')
StartCli handles connecting to a device, calling the expected method, and outputting the results. """ import cStringIO import inspect import re import sys import types import gflags import usb_exceptions gflags.DEFINE_integer('timeout_ms', 10000, 'Timeout in milliseconds.') gflags.DEFINE_list('port_path', [], 'USB port path integers (eg 1,2 or 2,1,1)') gflags.DEFINE_string('serial', None, 'Device serial to look for (host:port or USB serial)', short_name='s') gflags.DEFINE_bool( 'output_port_path', False, 'Affects the devices command only, outputs the port_path ' 'alongside the serial if true.') FLAGS = gflags.FLAGS _BLACKLIST = { 'Connect',
'', 'Username for logging into the devices. This ' 'will default to your own username.', short_name='u') gflags.DEFINE_string('command', '', 'Rather than a config file, you would like ' 'to issue a command and get a response.', short_name='C') gflags.DEFINE_string('suffix', '', 'Append suffix onto each target provided.', short_name='s') gflags.DEFINE_integer('threads', 20, 'Number of push worker threads.', short_name='t') gflags.DEFINE_bool('verbose', False, 'Display full error messages.', short_name='v') FORMAT = "%(asctime)-15s:%(levelname)s:%(filename)s:%(module)s:%(lineno)d %(message)s" logging.basicConfig(format=FORMAT) logging.basicConfig(filename='/tmp/push.log') class Error(Exception): """Base exception class."""
import threading from future.builtins import range # pylint: disable=redefined-builtin from pysc2 import maps from pysc2.env import available_actions_printer from loop import * from pysc2.env import sc2_env from pysc2.lib import stopwatch from pysc2.lib import app import gflags as flags FLAGS = flags.FLAGS flags.DEFINE_bool("render", True, "Whether to render with pygame.") flags.DEFINE_integer("screen_resolution", 84, "Resolution for screen feature layers.") flags.DEFINE_integer("minimap_resolution", 64, "Resolution for minimap feature layers.") flags.DEFINE_integer("max_agent_steps", 2500, "Total agent steps.") flags.DEFINE_integer("game_steps_per_episode", 0, "Game steps per episode.") flags.DEFINE_integer("step_mul", 8, "Game steps per agent step.") flags.DEFINE_string("agent", "pysc2.agents.random_agent.RandomAgent", "Which agent to run") flags.DEFINE_enum("agent_race", None, sc2_env.races.keys(), "Agent's race.") flags.DEFINE_enum("bot_race", None, sc2_env.races.keys(), "Bot's race.") flags.DEFINE_enum("difficulty", None, sc2_env.difficulties.keys(), "Bot's strength.") flags.DEFINE_bool("profile", False, "Whether to turn on code profiling.")
flags.DEFINE_string('azure_key', None, 'The key of the storage account for Azure.') flags.DEFINE_enum( 'scenario', 'OneByteRW', [ 'OneByteRW', 'ListConsistency', 'SingleStreamThroughput', 'CleanupBucket' ], 'The various scenarios to run. OneByteRW: read and write of single byte. ' 'ListConsistency: List-after-write and list-after-update consistency. ' 'SingleStreamThroughput: Throughput of single stream large object RW. ' 'CleanupBucket: Cleans up everything in a given bucket.') flags.DEFINE_integer( 'iterations', 1, 'The number of iterations to run for the ' 'particular test scenario. Currently only applicable to ' 'the ListConsistency scenario, ignored in others.') STORAGE_TO_SCHEMA_DICT = {'GCS': 'gs', 'S3': 's3', 'AZURE': 'azure'} # If more than 5% of our upload or download operations fail for an iteration, # there is an availability issue with the service provider or the connection # between the test VM and the service provider. For this reason, we consider # this particular iteration invalid, and we will print out an error message # instead of a set of benchmark numbers (which will be incorrect). FAILURE_TOLERANCE = 0.05 # Here are some constants used by various benchmark tests below. # The number of objects used by the one byte RW benchmarks. ONE_BYTE_OBJECT_COUNT = 1000