当前位置: 首页>>代码示例>>Python>>正文


Python flags.FLAGS属性代码示例

本文整理汇总了Python中absl.flags.FLAGS属性的典型用法代码示例。如果您正苦于以下问题:Python flags.FLAGS属性的具体用法?Python flags.FLAGS怎么用?Python flags.FLAGS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在absl.flags的用法示例。


在下文中一共展示了flags.FLAGS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(_):
  """Runs `text_utils.simplify_nq_example` over all shards of a split.

  Prints simplified examples to a single gzipped file in the same directory
  as the input shards.
  """
  split = os.path.basename(FLAGS.data_dir)
  outpath = os.path.join(FLAGS.data_dir,
                         "simplified-nq-{}.jsonl.gz".format(split))
  with gzip.open(outpath, "wb") as fout:
    num_processed = 0
    start = time.time()
    for inpath in glob.glob(os.path.join(FLAGS.data_dir, "nq-*-??.jsonl.gz")):
      print("Processing {}".format(inpath))
      with gzip.open(inpath, "rb") as fin:
        for l in fin:
          utf8_in = l.decode("utf8", "strict")
          utf8_out = json.dumps(
              text_utils.simplify_nq_example(json.loads(utf8_in))) + u"\n"
          fout.write(utf8_out.encode("utf8"))
          num_processed += 1
          if not num_processed % 100:
            print("Processed {} examples in {}.".format(num_processed,
                                                        time.time() - start)) 
开发者ID:google-research-datasets,项目名称:natural-questions,代码行数:26,代码来源:simplify_nq_data.py

示例2: noise_input_fn

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def noise_input_fn(params):
    """Input function for generating samples for PREDICT mode.

  Generates a single Tensor of fixed random noise. Use tf.data.Dataset to
  signal to the estimator when to terminate the generator returned by
  predict().

  Args:
    params: param `dict` passed by TPUEstimator.

  Returns:
    1-element `dict` containing the randomly generated noise.
  """

    # random noise
    np.random.seed(0)
    noise_dataset = tf.data.Dataset.from_tensors(tf.constant(
        np.random.randn(params['batch_size'], FLAGS.noise_dim), dtype=tf.float32))
    noise = noise_dataset.make_one_shot_iterator().get_next()
    return {'random_noise': noise}, None 
开发者ID:acheketa,项目名称:cwavegan,代码行数:22,代码来源:preview.py

示例3: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(unused_argv):
  servers = []
  server_creds = loas2.loas2_server_credentials()
  port = FLAGS.port
  if not FLAGS.run_on_borg:
    port = 20000 + FLAGS.server_id
  server = grpc.server(
      futures.ThreadPoolExecutor(max_workers=10), ports=(port,))
  servicer = ars_evaluation_service.ParameterEvaluationServicer(
      FLAGS.config_name, worker_id=FLAGS.server_id)
  ars_evaluation_service_pb2_grpc.add_EvaluationServicer_to_server(
      servicer, server)
  server.add_secure_port("[::]:{}".format(port), server_creds)
  servers.append(server)
  server.start()
  print("Start server {}".format(FLAGS.server_id))

  # prevent the main thread from exiting
  try:
    while True:
      time.sleep(_ONE_DAY_IN_SECONDS)
  except KeyboardInterrupt:
    for server in servers:
      server.stop(0) 
开发者ID:utra-robosoccer,项目名称:soccer-matlab,代码行数:26,代码来源:ars_server.py

示例4: RunBuild

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def RunBuild(self):
    """Perform the build."""
    title.set_title()
    self._build_info.BeyondCorp()

    task_list = self._SetupTaskList()

    if not os.path.exists(task_list):
      root_path = FLAGS.config_root_path or '/'
      try:
        b = builder.ConfigBuilder(self._build_info)
        b.Start(out_file=task_list, in_path=root_path)
      except builder.ConfigBuilderError as e:
        _LogFatal(str(e))

    try:
      r = runner.ConfigRunner(self._build_info)
      r.Start(task_list=task_list)
    except runner.ConfigRunnerError as e:
      _LogFatal(str(e)) 
开发者ID:google,项目名称:glazier,代码行数:22,代码来源:autobuild.py

示例5: _SetUrl

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def _SetUrl(self, url: Text):
    """Simple helper function to determine signed URL.

    Args:
      url: the url we want to download from.

    Returns:
      A string with the applicable URLs

    Raises:
      DownloadError: Failed to obtain SignedURL.
    """
    if not FLAGS.use_signed_url:
      return url
    config_server = '%s%s' % (FLAGS.config_server, '/')
    try:
      return self._beyondcorp.GetSignedUrl(
          url[url.startswith(config_server) and len(config_server):])
    except beyondcorp.BCError as e:
      raise DownloadError(e) 
开发者ID:google,项目名称:glazier,代码行数:22,代码来源:download.py

示例6: loop

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def loop(env, screen, pano_ids_yaws):
  """Main loop of the scan agent."""
  for (pano_id, yaw) in pano_ids_yaws:

    # Retrieve the observation at a specified pano ID and heading.
    logging.info('Retrieving view at pano ID %s and yaw %f', pano_id, yaw)
    observation = env.goto(pano_id, yaw)

    current_yaw = observation["yaw"]
    view_image = interleave(observation["view_image"],
                            FLAGS.width, FLAGS.height)
    graph_image = interleave(observation["graph_image"],
                             FLAGS.width, FLAGS.height)
    screen_buffer = np.concatenate((view_image, graph_image), axis=1)
    pygame.surfarray.blit_array(screen, screen_buffer)
    pygame.display.update()

    for event in pygame.event.get():
      if (event.type == pygame.QUIT or
          (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE)):
        return
    if FLAGS.save_images:
      filename = 'scan_agent_{}_{}.bmp'.format(pano_id, yaw)
      pygame.image.save(screen, filename) 
开发者ID:deepmind,项目名称:streetlearn,代码行数:26,代码来源:scan_agent.py

示例7: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(argv):
  config = {'width': FLAGS.width,
            'height': FLAGS.height,
            'field_of_view': FLAGS.field_of_view,
            'graph_width': FLAGS.width,
            'graph_height': FLAGS.height,
            'graph_zoom': 1,
            'full_graph': True,
            'proportion_of_panos_with_coins': 0.0,
            'action_spec': 'streetlearn_fast_rotate',
            'observations': ['view_image', 'graph_image', 'yaw']}
  with open(FLAGS.list_pano_ids_yaws, 'r') as f:
    lines = f.readlines()
    pano_ids_yaws = [(line.split('\t')[0], float(line.split('\t')[1]))
                     for line in lines]
  config = default_config.ApplyDefaults(config)
  game = coin_game.CoinGame(config)
  env = streetlearn.StreetLearn(FLAGS.dataset_path, config, game)
  env.reset()
  pygame.init()
  screen = pygame.display.set_mode((FLAGS.width, FLAGS.height * 2))
  loop(env, screen, pano_ids_yaws) 
开发者ID:deepmind,项目名称:streetlearn,代码行数:24,代码来源:scan_agent.py

示例8: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(argv):
  config = {'width': FLAGS.width,
            'height': FLAGS.height,
            'field_of_view': FLAGS.field_of_view,
            'graph_width': FLAGS.width,
            'graph_height': FLAGS.height,
            'graph_zoom': FLAGS.graph_zoom,
            'goal_timeout': FLAGS.frame_cap,
            'frame_cap': FLAGS.frame_cap,
            'full_graph': (FLAGS.start_pano == ''),
            'start_pano': FLAGS.start_pano,
            'min_graph_depth': FLAGS.graph_depth,
            'max_graph_depth': FLAGS.graph_depth,
            'proportion_of_panos_with_coins':
                FLAGS.proportion_of_panos_with_coins,
            'action_spec': 'streetlearn_fast_rotate',
            'observations': ['view_image', 'graph_image', 'yaw', 'pitch']}
  config = default_config.ApplyDefaults(config)
  game = courier_game.CourierGame(config)
  env = streetlearn.StreetLearn(FLAGS.dataset_path, config, game)
  env.reset()
  pygame.init()
  screen = pygame.display.set_mode((FLAGS.width, FLAGS.height * 2))
  loop(env, screen) 
开发者ID:deepmind,项目名称:streetlearn,代码行数:26,代码来源:oracle_agent.py

示例9: _get_all_constants

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def _get_all_constants(module=__name__, func=None):
  """Returns a dictionary of all constants.

  This function will return all of the flags configured above as `Constant`
  objects. By default, the default value of the flag will be used.

  Args:
    module: str, the name of the module to get the constants from.
    func: Callable, a function that returns the value of each constant given the
        name of the flag.

  Returns:
    A dictionary of all key flags in this module represented as Constants,
        keyed by the name of the constant.
  """
  constants = {}

  for flag in FLAGS.get_key_flags_for_module(sys.modules[module]):
    value = FLAGS[flag.name].default
    if func:
      value = func(flag.name)
    constants[flag.name] = Constant(
        flag.name, flag.help, value, _PARSERS.get(flag.name))
  return constants 
开发者ID:google,项目名称:loaner,代码行数:26,代码来源:app_constants.py

示例10: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(argv):
  del argv  # Unused.
  utils.clear_screen()
  utils.write('Welcome to the Grab n Go management script!\n')

  try:
    _Manager.new(
        FLAGS.config_file_path,
        FLAGS.prefer_gcs,
        project_key=FLAGS.project,
        version=FLAGS.app_version,
    ).run()
  except KeyboardInterrupt as err:
    logging.error('Manager received CTRL-C, exiting: %s', err)
    exit_code = 1
  else:
    exit_code = 0

  sys.exit(exit_code) 
开发者ID:google,项目名称:loaner,代码行数:21,代码来源:gng_impl.py

示例11: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(_):
  private_map = {
      'tfl': ['python'],
      'tfl.aggregation_layer': ['Aggregation'],
      'tfl.categorical_calibration_layer': ['CategoricalCalibration'],
      'tfl.lattice_layer': ['Lattice'],
      'tfl.linear_layer': ['Linear'],
      'tfl.pwl_calibration_layer': ['PWLCalibration'],
      'tfl.parallel_combination_layer': ['ParallelCombination'],
      'tfl.rtl_layer': ['RTL'],
  }
  doc_generator = generate_lib.DocGenerator(
      root_title='TensorFlow Lattice 2.0',
      py_modules=[('tfl', tfl)],
      base_dir=os.path.dirname(tfl.__file__),
      code_url_prefix=FLAGS.code_url_prefix,
      search_hints=FLAGS.search_hints,
      site_path=FLAGS.site_path,
      private_map=private_map,
      callbacks=[local_definitions_filter])

  sys.exit(doc_generator.build(output_dir=FLAGS.output_dir)) 
开发者ID:tensorflow,项目名称:lattice,代码行数:24,代码来源:build_docs.py

示例12: _SanityCheck

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def _SanityCheck(path):
  """Runs various sanity checks on the font family under path.

  Args:
    path: A directory containing a METADATA.pb file.
  Returns:
    A list of ResultMessageTuple's.
  """
  try:
    fonts.Metadata(path)
  except ValueError as e:
    return [_SadResult('Bad METADATA.pb: ' + e.message, path)]

  results = []
  if FLAGS.check_metadata:
    results.extend(_CheckLicense(path))
    results.extend(_CheckNameMatching(path))

  if FLAGS.check_font:
    results.extend(_CheckFontInternalValues(path))

  return results 
开发者ID:googlefonts,项目名称:gftools,代码行数:24,代码来源:gftools-sanity-check.py

示例13: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(argv):
  result_code = 0
  all_results = []
  paths = [_DropEmptyPathSegments(os.path.expanduser(p)) for p in argv[1:]]
  for path in paths:
    if not os.path.isdir(path):
      raise ValueError('Not a directory: %s' % path)

  for path in paths:
    for font_dir in fonts.FontDirs(path):
      results = _SanityCheck(font_dir)
      all_results.extend(results)
      for result in results:
        result_msg = 'pass'
        if not result.happy:
          result_code = 1
          result_msg = 'FAIL'
        if not result.happy or not FLAGS.suppress_pass:
          print('%s: %s (%s)' % (result_msg, result.message, font_dir))

  if FLAGS.repair_script:
    _WriteRepairScript(FLAGS.repair_script, all_results)

  sys.exit(result_code) 
开发者ID:googlefonts,项目名称:gftools,代码行数:26,代码来源:gftools-sanity-check.py

示例14: main

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def main(argv):
  if len(argv) < 2:
    sys.exit('Must specify one or more font files.')

  cps = set()
  for filename in argv[1:]:
    if not os.path.isfile(filename):
      sys.exit('%s is not a file' % filename)
    cps |= fonts.CodepointsInFont(filename)

  for cp in sorted(cps):
    show_char = ''
    if FLAGS.show_char:
      show_char = (' ' + unichr(cp).strip() + ' ' +
                   unicodedata.name(unichr(cp), ''))
    show_subset = ''
    if FLAGS.show_subsets:
      show_subset = ' subset:%s' % ','.join(fonts.SubsetsForCodepoint(cp))

    print(u'0x%04X%s%s' % (cp, show_char, show_subset)) 
开发者ID:googlefonts,项目名称:gftools,代码行数:22,代码来源:gftools-ttf2cp.py

示例15: CompareDirs

# 需要导入模块: from absl import flags [as 别名]
# 或者: from absl.flags import FLAGS [as 别名]
def CompareDirs(font1, font2):
  """Compares fonts by assuming font1/2 are dirs containing METADATA.pb."""

  m1 = fonts.Metadata(font1)
  m2 = fonts.Metadata(font2)

  subsets_to_compare = fonts.UniqueSort(m1.subsets, m2.subsets)
  subsets_to_compare.remove('menu')
  subsets_to_compare.append('all')

  font_filename1 = os.path.join(font1, fonts.RegularWeight(m1))
  font_filename2 = os.path.join(font2, fonts.RegularWeight(m2))

  if FLAGS.diff_coverage:
    print('Subset Coverage Change (codepoints)')
    for subset in subsets_to_compare:
      DiffCoverage(font_filename1, font_filename2, subset)

  print(CompareSize(font_filename1, font_filename2)) 
开发者ID:googlefonts,项目名称:gftools,代码行数:21,代码来源:gftools-compare-font.py


注:本文中的absl.flags.FLAGS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。