Python logging.fatal() Examples

The following are 30 code examples for showing how to use logging.fatal(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module logging , or try the search function .

Example 1
Project: DOTA_models   Author: ringringyi   File: vision_baseline_lstm.py    License: Apache License 2.0 6 votes vote down vote up
def combine_setup(name, combine_type, embed_img, embed_goal, num_img_neuorons=None,
                  num_goal_neurons=None):
  with tf.name_scope(name + '_' + combine_type):
    if combine_type == 'add':
      # Simple concat features from goal and image
      out = embed_img + embed_goal

    elif combine_type == 'multiply':
      # Multiply things together
      re_embed_img = tf.reshape(
          embed_img, shape=[-1, num_img_neuorons / num_goal_neurons,
                            num_goal_neurons])
      re_embed_goal = tf.reshape(embed_goal, shape=[-1, num_goal_neurons, 1])
      x = tf.matmul(re_embed_img, re_embed_goal, transpose_a=False, transpose_b=False)
      out = slim.flatten(x)
    elif combine_type == 'none' or combine_type == 'imgonly':
      out = embed_img
    elif combine_type == 'goalonly':
      out = embed_goal
    else:
      logging.fatal('Undefined combine_type: %s', combine_type)
  return out 
Example 2
Project: DOTA_models   Author: ringringyi   File: swiftshader_renderer.py    License: Apache License 2.0 6 votes vote down vote up
def init_display(self, width, height, fov, z_near, z_far, rgb_shader,
                   d_shader):
    self.init_renderer_egl(width, height)
    dir_path = os.path.dirname(os.path.realpath(__file__))
    if d_shader is not None and rgb_shader is not None:
      logging.fatal('Does not support setting both rgb_shader and d_shader.')
    
    if d_shader is not None:
      assert rgb_shader is None
      shader = d_shader
      self.modality = 'depth'
    
    if rgb_shader is not None:
      assert d_shader is None
      shader = rgb_shader
      self.modality = 'rgb'
    
    self.create_shaders(os.path.join(dir_path, shader+'.vp'),
                        os.path.join(dir_path, shader + '.fp'))
    aspect = width*1./(height*1.)
    self.set_camera(fov, z_near, z_far, aspect) 
Example 3
Project: DOTA_models   Author: ringringyi   File: config_cmp.py    License: Apache License 2.0 6 votes vote down vote up
def process_arch_str(args, arch_str):
  # This function modifies args.
  args.arch, args.mapper_arch = get_default_cmp_args()

  arch_vars = get_arch_vars(arch_str)

  args.navtask.task_params.outputs.ego_maps = True
  args.navtask.task_params.outputs.ego_goal_imgs = True
  args.navtask.task_params.outputs.egomotion = True
  args.navtask.task_params.toy_problem = False

  if arch_vars.var1 == 'lmap':
    args = process_arch_learned_map(args, arch_vars)

  elif arch_vars.var1 == 'pmap':
    args = process_arch_projected_map(args, arch_vars)

  else:
    logging.fatal('arch_vars.var1 should be lmap or pmap, but is %s', arch_vars.var1)
    assert(False)

  return args 
Example 4
Project: DOTA_models   Author: ringringyi   File: nav_env.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self, robot, env, task_params, category_list=None,
               building_name=None, flip=False, logdir=None,
               building_loader=None, r_obj=None):
    tt = utils.Timer()
    tt.tic()
    Building.__init__(self, building_name, robot, env, category_list,
                      small=task_params.toy_problem, flip=flip, logdir=logdir,
                      building_loader=building_loader)

    self.set_r_obj(r_obj)
    self.task_params = task_params
    self.task = None
    self.episode = None
    self._preprocess_for_task(self.task_params.building_seed)
    if hasattr(self.task_params, 'map_scales'):
      self.task.scaled_maps = resize_maps(
          self.traversible.astype(np.float32)*1, self.task_params.map_scales,
          self.task_params.map_resize_method)
    else:
      logging.fatal('VisualNavigationEnv does not support scale_f anymore.')
    self.task.readout_maps_scaled = resize_maps(
      self.traversible.astype(np.float32)*1,
      self.task_params.readout_maps_scales,
      self.task_params.map_resize_method)
    tt.toc(log_at=1, log_str='VisualNavigationEnv __init__: ') 
Example 5
Project: DOTA_models   Author: ringringyi   File: script_nav_agent_release.py    License: Apache License 2.0 6 votes vote down vote up
def get_args_for_config(config_name):
  configs = config_name.split('.')
  type = configs[0]
  config_name = '.'.join(configs[1:])
  if type == 'cmp':
    args = config_cmp.get_args_for_config(config_name)
    args.setup_to_run = cmp.setup_to_run
    args.setup_train_step_kwargs = cmp.setup_train_step_kwargs

  elif type == 'bl':
    args = config_vision_baseline.get_args_for_config(config_name)
    args.setup_to_run = vision_baseline_lstm.setup_to_run
    args.setup_train_step_kwargs = vision_baseline_lstm.setup_train_step_kwargs

  else:
    logging.fatal('Unknown type: {:s}'.format(type))
  return args 
Example 6
Project: browserscope   Author: elsigh   File: data_dump.py    License: Apache License 2.0 6 votes vote down vote up
def Send(self, path, params, method='POST', json_response=True):
    # Drop parameters with value=None. Otherwise, the string 'None' gets sent.
    rpc_params = dict((str(k), v) for k, v in params.items() if v is not None)
    logging.info(
        'http://%s%s%s', self.host, path, rpc_params and '?%s' % '&'.join(
        ['%s=%s' % (k, v) for k, v in sorted(rpc_params.items())]) or '')
    # "payload=None" would a GET instead a POST.
    if method == 'GET':
      response_data = self.rpc_server.Send(path, payload=None, **rpc_params)
    else:
      response_data = self.rpc_server.Send(
          path, payload=urllib.urlencode(rpc_params))
    if response_data.startswith('bailing'):
      logging.fatal(response_data)
      raise RuntimeError
    elif json_response:
      return simplejson.loads(response_data)
    else:
      return response_data 
Example 7
Project: browserscope   Author: elsigh   File: result_stats.py    License: Apache License 2.0 6 votes vote down vote up
def InsortBrowser(cls, browsers, browser):
        """Insert a browser, in-place, into a sorted list of browsers.

        Args:
            browsers: a list of strings (e.g. ['iPhone 3.1', 'Safari 4.1'])
            browser: a list of strings
        """
        browser_key = cls.BrowserKey(browser)
        low, high = 0, len(browsers)
        while low < high:
            mid = (low + high) / 2
            if browser_key < cls.BrowserKey(browsers[mid]):
                high = mid
            else:
                low = mid + 1
        if not hasattr(browsers, 'insert'):
            logging.fatal('Unexpected browsers list: %s', browsers)
        browsers.insert(low, browser) 
Example 8
Project: mongodb_consistent_backup   Author: Percona-Lab   File: Sharding.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self, config, timer, db):
        self.config             = config
        self.timer              = timer
        self.db                 = db
        self.balancer_wait_secs = self.config.sharding.balancer.wait_secs
        self.balancer_sleep     = self.config.sharding.balancer.ping_secs

        self.timer_name            = self.__class__.__name__
        self.config_server         = None
        self.config_db             = None
        self.mongos_db             = None
        self._balancer_state_start = None
        self.restored              = False

        # Get a DB connection
        try:
            if isinstance(self.db, DB):
                self.connection = self.db.connection()
                if not self.db.is_mongos() and not self.db.is_configsvr():
                    raise DBOperationError('MongoDB connection is not to a mongos or configsvr!')
            else:
                raise Error("'db' field is not an instance of class: 'DB'!")
        except Exception, e:
            logging.fatal("Could not get DB connection! Error: %s" % e)
            raise DBOperationError(e) 
Example 9
Project: mongodb_consistent_backup   Author: Percona-Lab   File: Sharding.py    License: Apache License 2.0 6 votes vote down vote up
def stop_balancer(self):
        logging.info("Stopping the balancer and waiting a max of %i sec" % self.balancer_wait_secs)
        wait_cnt = 0
        self.timer.start(self.timer_name)
        self.set_balancer(False)
        while wait_cnt < self.balancer_wait_secs:
            if self.check_balancer_running():
                wait_cnt += self.balancer_sleep
                logging.info("Balancer is still running, sleeping for %i sec(s)" % self.balancer_sleep)
                sleep(self.balancer_sleep)
            else:
                self.timer.stop(self.timer_name)
                logging.info("Balancer stopped after %.2f seconds" % self.timer.duration(self.timer_name))
                return
        logging.fatal("Could not stop balancer %s!" % self.db.uri)
        raise DBOperationError("Could not stop balancer %s" % self.db.uri) 
Example 10
Project: mongodb_consistent_backup   Author: Percona-Lab   File: Sharding.py    License: Apache License 2.0 6 votes vote down vote up
def get_configdb_hosts(self):
        try:
            cmdlineopts = self.db.admin_command("getCmdLineOpts")
            config_string = None
            if cmdlineopts.get('parsed').get('configdb'):
                config_string = cmdlineopts.get('parsed').get('configdb')
            elif cmdlineopts.get('parsed').get('sharding').get('configDB'):
                config_string = cmdlineopts.get('parsed').get('sharding').get('configDB')

            if config_string:
                return MongoUri(config_string, 27019)
            elif self.db.is_configsvr():
                return self.db.uri
            else:
                logging.fatal("Unable to locate config servers for %s!" % self.db.uri)
                raise OperationError("Unable to locate config servers for %s!" % self.db.uri)
        except Exception, e:
            raise OperationError(e) 
Example 11
Project: mongodb_consistent_backup   Author: Percona-Lab   File: Sharding.py    License: Apache License 2.0 6 votes vote down vote up
def get_config_server(self, force=False):
        if force or not self.config_server:
            configdb_uri = self.get_configdb_hosts()
            try:
                logging.info("Found sharding config server: %s" % configdb_uri)
                if self.db.uri.hosts() == configdb_uri.hosts():
                    self.config_db = self.db
                    logging.debug("Re-using seed connection to config server(s)")
                else:
                    self.config_db = DB(configdb_uri, self.config, True)
                if not self.config_db.is_replset():
                    raise OperationError("configsvrs must have replication enabled")
                self.config_server = Replset(self.config, self.config_db)
            except Exception, e:
                logging.fatal("Unable to locate config servers using %s: %s!" % (self.db.uri, e))
                raise OperationError(e) 
Example 12
Project: mongodb_consistent_backup   Author: Percona-Lab   File: Resolver.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self, manager, config, timer, base_dir, backup_dir, tailed_oplogs, backup_oplogs):
        super(Resolver, self).__init__(self.__class__.__name__, manager, config, timer, base_dir, backup_dir)
        self.tailed_oplogs = tailed_oplogs
        self.backup_oplogs = backup_oplogs

        self.compression_supported = ['none', 'gzip']
        self.resolver_summary      = {}
        self.resolver_state        = {}

        self.running   = False
        self.stopped   = False
        self.completed = False
        self._pool     = None
        self._pooled   = []
        self._results  = {}

        self.threads(self.config.oplog.resolver.threads)

        try:
            self._pool = Pool(processes=self.threads())
        except Exception, e:
            logging.fatal("Could not start oplog resolver pool! Error: %s" % e)
            raise Error(e) 
Example 13
Project: yolo_v2   Author: rky0930   File: vision_baseline_lstm.py    License: Apache License 2.0 6 votes vote down vote up
def combine_setup(name, combine_type, embed_img, embed_goal, num_img_neuorons=None,
                  num_goal_neurons=None):
  with tf.name_scope(name + '_' + combine_type):
    if combine_type == 'add':
      # Simple concat features from goal and image
      out = embed_img + embed_goal

    elif combine_type == 'multiply':
      # Multiply things together
      re_embed_img = tf.reshape(
          embed_img, shape=[-1, num_img_neuorons / num_goal_neurons,
                            num_goal_neurons])
      re_embed_goal = tf.reshape(embed_goal, shape=[-1, num_goal_neurons, 1])
      x = tf.matmul(re_embed_img, re_embed_goal, transpose_a=False, transpose_b=False)
      out = slim.flatten(x)
    elif combine_type == 'none' or combine_type == 'imgonly':
      out = embed_img
    elif combine_type == 'goalonly':
      out = embed_goal
    else:
      logging.fatal('Undefined combine_type: %s', combine_type)
  return out 
Example 14
Project: yolo_v2   Author: rky0930   File: swiftshader_renderer.py    License: Apache License 2.0 6 votes vote down vote up
def init_display(self, width, height, fov, z_near, z_far, rgb_shader,
                   d_shader):
    self.init_renderer_egl(width, height)
    dir_path = os.path.dirname(os.path.realpath(__file__))
    if d_shader is not None and rgb_shader is not None:
      logging.fatal('Does not support setting both rgb_shader and d_shader.')
    
    if d_shader is not None:
      assert rgb_shader is None
      shader = d_shader
      self.modality = 'depth'
    
    if rgb_shader is not None:
      assert d_shader is None
      shader = rgb_shader
      self.modality = 'rgb'
    
    self.create_shaders(os.path.join(dir_path, shader+'.vp'),
                        os.path.join(dir_path, shader + '.fp'))
    aspect = width*1./(height*1.)
    self.set_camera(fov, z_near, z_far, aspect) 
Example 15
Project: yolo_v2   Author: rky0930   File: config_cmp.py    License: Apache License 2.0 6 votes vote down vote up
def process_arch_str(args, arch_str):
  # This function modifies args.
  args.arch, args.mapper_arch = get_default_cmp_args()

  arch_vars = get_arch_vars(arch_str)

  args.navtask.task_params.outputs.ego_maps = True
  args.navtask.task_params.outputs.ego_goal_imgs = True
  args.navtask.task_params.outputs.egomotion = True
  args.navtask.task_params.toy_problem = False

  if arch_vars.var1 == 'lmap':
    args = process_arch_learned_map(args, arch_vars)

  elif arch_vars.var1 == 'pmap':
    args = process_arch_projected_map(args, arch_vars)

  else:
    logging.fatal('arch_vars.var1 should be lmap or pmap, but is %s', arch_vars.var1)
    assert(False)

  return args 
Example 16
Project: yolo_v2   Author: rky0930   File: nav_env.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self, robot, env, task_params, category_list=None,
               building_name=None, flip=False, logdir=None,
               building_loader=None, r_obj=None):
    tt = utils.Timer()
    tt.tic()
    Building.__init__(self, building_name, robot, env, category_list,
                      small=task_params.toy_problem, flip=flip, logdir=logdir,
                      building_loader=building_loader)

    self.set_r_obj(r_obj)
    self.task_params = task_params
    self.task = None
    self.episode = None
    self._preprocess_for_task(self.task_params.building_seed)
    if hasattr(self.task_params, 'map_scales'):
      self.task.scaled_maps = resize_maps(
          self.traversible.astype(np.float32)*1, self.task_params.map_scales,
          self.task_params.map_resize_method)
    else:
      logging.fatal('VisualNavigationEnv does not support scale_f anymore.')
    self.task.readout_maps_scaled = resize_maps(
      self.traversible.astype(np.float32)*1,
      self.task_params.readout_maps_scales,
      self.task_params.map_resize_method)
    tt.toc(log_at=1, log_str='VisualNavigationEnv __init__: ') 
Example 17
Project: yolo_v2   Author: rky0930   File: script_nav_agent_release.py    License: Apache License 2.0 6 votes vote down vote up
def get_args_for_config(config_name):
  configs = config_name.split('.')
  type = configs[0]
  config_name = '.'.join(configs[1:])
  if type == 'cmp':
    args = config_cmp.get_args_for_config(config_name)
    args.setup_to_run = cmp.setup_to_run
    args.setup_train_step_kwargs = cmp.setup_train_step_kwargs

  elif type == 'bl':
    args = config_vision_baseline.get_args_for_config(config_name)
    args.setup_to_run = vision_baseline_lstm.setup_to_run
    args.setup_train_step_kwargs = vision_baseline_lstm.setup_train_step_kwargs

  else:
    logging.fatal('Unknown type: {:s}'.format(type))
  return args 
Example 18
Project: Gun-Detector   Author: itsamitgoel   File: vision_baseline_lstm.py    License: Apache License 2.0 6 votes vote down vote up
def combine_setup(name, combine_type, embed_img, embed_goal, num_img_neuorons=None,
                  num_goal_neurons=None):
  with tf.name_scope(name + '_' + combine_type):
    if combine_type == 'add':
      # Simple concat features from goal and image
      out = embed_img + embed_goal

    elif combine_type == 'multiply':
      # Multiply things together
      re_embed_img = tf.reshape(
          embed_img, shape=[-1, num_img_neuorons / num_goal_neurons,
                            num_goal_neurons])
      re_embed_goal = tf.reshape(embed_goal, shape=[-1, num_goal_neurons, 1])
      x = tf.matmul(re_embed_img, re_embed_goal, transpose_a=False, transpose_b=False)
      out = slim.flatten(x)
    elif combine_type == 'none' or combine_type == 'imgonly':
      out = embed_img
    elif combine_type == 'goalonly':
      out = embed_goal
    else:
      logging.fatal('Undefined combine_type: %s', combine_type)
  return out 
Example 19
Project: Gun-Detector   Author: itsamitgoel   File: swiftshader_renderer.py    License: Apache License 2.0 6 votes vote down vote up
def init_display(self, width, height, fov, z_near, z_far, rgb_shader,
                   d_shader):
    self.init_renderer_egl(width, height)
    dir_path = os.path.dirname(os.path.realpath(__file__))
    if d_shader is not None and rgb_shader is not None:
      logging.fatal('Does not support setting both rgb_shader and d_shader.')
    
    if d_shader is not None:
      assert rgb_shader is None
      shader = d_shader
      self.modality = 'depth'
    
    if rgb_shader is not None:
      assert d_shader is None
      shader = rgb_shader
      self.modality = 'rgb'
    
    self.create_shaders(os.path.join(dir_path, shader+'.vp'),
                        os.path.join(dir_path, shader + '.fp'))
    aspect = width*1./(height*1.)
    self.set_camera(fov, z_near, z_far, aspect) 
Example 20
Project: Gun-Detector   Author: itsamitgoel   File: config_cmp.py    License: Apache License 2.0 6 votes vote down vote up
def process_arch_str(args, arch_str):
  # This function modifies args.
  args.arch, args.mapper_arch = get_default_cmp_args()

  arch_vars = get_arch_vars(arch_str)

  args.navtask.task_params.outputs.ego_maps = True
  args.navtask.task_params.outputs.ego_goal_imgs = True
  args.navtask.task_params.outputs.egomotion = True
  args.navtask.task_params.toy_problem = False

  if arch_vars.var1 == 'lmap':
    args = process_arch_learned_map(args, arch_vars)

  elif arch_vars.var1 == 'pmap':
    args = process_arch_projected_map(args, arch_vars)

  else:
    logging.fatal('arch_vars.var1 should be lmap or pmap, but is %s', arch_vars.var1)
    assert(False)

  return args 
Example 21
Project: Gun-Detector   Author: itsamitgoel   File: nav_env.py    License: Apache License 2.0 6 votes vote down vote up
def __init__(self, robot, env, task_params, category_list=None,
               building_name=None, flip=False, logdir=None,
               building_loader=None, r_obj=None):
    tt = utils.Timer()
    tt.tic()
    Building.__init__(self, building_name, robot, env, category_list,
                      small=task_params.toy_problem, flip=flip, logdir=logdir,
                      building_loader=building_loader)

    self.set_r_obj(r_obj)
    self.task_params = task_params
    self.task = None
    self.episode = None
    self._preprocess_for_task(self.task_params.building_seed)
    if hasattr(self.task_params, 'map_scales'):
      self.task.scaled_maps = resize_maps(
          self.traversible.astype(np.float32)*1, self.task_params.map_scales,
          self.task_params.map_resize_method)
    else:
      logging.fatal('VisualNavigationEnv does not support scale_f anymore.')
    self.task.readout_maps_scaled = resize_maps(
      self.traversible.astype(np.float32)*1,
      self.task_params.readout_maps_scales,
      self.task_params.map_resize_method)
    tt.toc(log_at=1, log_str='VisualNavigationEnv __init__: ') 
Example 22
Project: Gun-Detector   Author: itsamitgoel   File: script_nav_agent_release.py    License: Apache License 2.0 6 votes vote down vote up
def get_args_for_config(config_name):
  configs = config_name.split('.')
  type = configs[0]
  config_name = '.'.join(configs[1:])
  if type == 'cmp':
    args = config_cmp.get_args_for_config(config_name)
    args.setup_to_run = cmp.setup_to_run
    args.setup_train_step_kwargs = cmp.setup_train_step_kwargs

  elif type == 'bl':
    args = config_vision_baseline.get_args_for_config(config_name)
    args.setup_to_run = vision_baseline_lstm.setup_to_run
    args.setup_train_step_kwargs = vision_baseline_lstm.setup_train_step_kwargs

  else:
    logging.fatal('Unknown type: {:s}'.format(type))
  return args 
Example 23
Project: rnn-speech   Author: inikdom   File: LanguageModel.py    License: MIT License 6 votes vote down vote up
def create_forward_rnn(self):
        """
        Create the forward-only RNN

        Parameters
        -------
        :return: the logits
        """
        if self.rnn_created:
            logging.fatal("Trying to create the language RNN but it is already.")

        # Set placeholders for input
        self.inputs_ph = tf.placeholder(tf.float32, shape=[self.max_input_seq_length, None, self.input_dim],
                                        name="inputs_ph")

        self.input_seq_lengths_ph = tf.placeholder(tf.int32, shape=[None], name="input_seq_lengths_ph")

        # Build the RNN
        self.global_step, logits, self.prediction, self.rnn_keep_state_op, self.rnn_state_zero_op, \
            _, _, self.rnn_tuple_state = self._build_base_rnn(self.inputs_ph, self.input_seq_lengths_ph, True)

        # Add the saving and restore operation
        self.saver_op = self._add_saving_op()

        return logits 
Example 24
Project: rnn-speech   Author: inikdom   File: AcousticModel.py    License: MIT License 6 votes vote down vote up
def create_forward_rnn(self):
        """
        Create the forward-only RNN

        Parameters
        -------
        :return: the logits
        """
        if self.rnn_created:
            logging.fatal("Trying to create the acoustic RNN but it is already.")

        # Set placeholders for input
        self.inputs_ph = tf.placeholder(tf.float32, shape=[self.max_input_seq_length, None, self.input_dim],
                                        name="inputs_ph")

        self.input_seq_lengths_ph = tf.placeholder(tf.int32, shape=[None], name="input_seq_lengths_ph")

        # Build the RNN
        self.global_step, logits, self.prediction, self.rnn_keep_state_op, self.rnn_state_zero_op,\
            _, _, self.rnn_tuple_state = self._build_base_rnn(self.inputs_ph, self.input_seq_lengths_ph, True)

        # Add the saving and restore operation
        self.saver_op = self._add_saving_op()

        return logits 
Example 25
Project: tor   Author: GrafeasGroup   File: config.py    License: MIT License 6 votes vote down vote up
def redis(self):
        """
        Lazy-loaded redis connection
        """
        from redis import StrictRedis
        import redis.exceptions

        try:
            url = os.environ.get('REDIS_CONNECTION_URL',
                                 'redis://localhost:6379/0')
            conn = StrictRedis.from_url(url)
            conn.ping()
        except redis.exceptions.ConnectionError:
            logging.fatal("Redis server is not running")
            raise
        return conn 
Example 26
Project: dnspod-ddns   Author: strahe   File: config.py    License: Apache License 2.0 6 votes vote down vote up
def check_config():
    if not (
            cfg['login_token'] and
            cfg['domain'] and
            cfg['sub_domain']):
        logging.fatal('config error: need login info')
        exit()
    try:
        if not(int(cfg["interval"])):
            logging.fatal('interval error')
            exit()
        if not(int(cfg["ip_count"])):
            logging.fatal('ip_count error')            
            exit()
    except:
        logging.fatal('config error')
        exit()
    logging.info('config checked') 
Example 27
Project: abseil-py   Author: abseil   File: __init__.py    License: Apache License 2.0 6 votes vote down vote up
def value(self, v):
    if v in _CPP_LEVEL_TO_NAMES:
      # --stderrthreshold also accepts numberic strings whose values are
      # Abseil C++ log levels.
      cpp_value = int(v)
      v = _CPP_LEVEL_TO_NAMES[v]  # Normalize to strings.
    elif v.lower() in _CPP_NAME_TO_LEVELS:
      v = v.lower()
      if v == 'warn':
        v = 'warning'  # Use 'warning' as the canonical name.
      cpp_value = int(_CPP_NAME_TO_LEVELS[v])
    else:
      raise ValueError(
          '--stderrthreshold must be one of (case-insensitive) '
          "'debug', 'info', 'warning', 'error', 'fatal', "
          "or '0', '1', '2', '3', not '%s'" % v)

    self._value = v 
Example 28
Project: abseil-py   Author: abseil   File: __init__.py    License: Apache License 2.0 6 votes vote down vote up
def set_verbosity(v):
  """Sets the logging verbosity.

  Causes all messages of level <= v to be logged,
  and all messages of level > v to be silently discarded.

  Args:
    v: int|str, the verbosity level as an integer or string. Legal string values
        are those that can be coerced to an integer as well as case-insensitive
        'debug', 'info', 'warning', 'error', and 'fatal'.
  """
  try:
    new_level = int(v)
  except ValueError:
    new_level = converter.ABSL_NAMES[v.upper()]
  FLAGS.verbosity = new_level 
Example 29
Project: DOTA_models   Author: ringringyi   File: config_common.py    License: Apache License 2.0 5 votes vote down vote up
def adjust_args_for_mode(args, mode):
  if mode == 'train':
    args.control.train = True
  
  elif mode == 'val1':
    # Same settings as for training, to make sure nothing wonky is happening
    # there.
    args.control.test = True
    args.control.test_mode = 'val'
    args.navtask.task_params.batch_size = 32

  elif mode == 'val2':
    # No data augmentation, not sampling but taking the argmax action, not
    # sampling from the ground truth at all.
    args.control.test = True
    args.arch.action_sample_type = 'argmax'
    args.arch.sample_gt_prob_type = 'zero'
    args.navtask.task_params.data_augment = \
      utils.Foo(lr_flip=0, delta_angle=0, delta_xy=0, relight=False,
                relight_fast=False, structured=False)
    args.control.test_mode = 'val'
    args.navtask.task_params.batch_size = 32

  elif mode == 'bench':
    # Actually testing the agent in settings that are kept same between
    # different runs.
    args.navtask.task_params.batch_size = 16
    args.control.test = True
    args.arch.action_sample_type = 'argmax'
    args.arch.sample_gt_prob_type = 'zero'
    args.navtask.task_params.data_augment = \
      utils.Foo(lr_flip=0, delta_angle=0, delta_xy=0, relight=False,
                relight_fast=False, structured=False)
    args.summary.test_iters = 250
    args.control.only_eval_when_done = True
    args.control.reset_rng_seed = True
    args.control.test_mode = 'test'
  else:
    logging.fatal('Unknown mode: %s.', mode)
    assert(False)
  return args 
Example 30
Project: DOTA_models   Author: ringringyi   File: factory.py    License: Apache License 2.0 5 votes vote down vote up
def get_split(self, split_name):
    if self.ver == 'sbpd':
      return self._get_split(split_name)
    else:
      logging.fatal('Unknown version.')