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


Python logging.info方法代码示例

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


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

示例1: _sample_random_goal

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def _sample_random_goal(self, streetlearn):
    """Randomly sets a new pano for the current goal according to a curriculum.

    Args:
      streetlearn: The StreetLearn environment.
    """
    # Sample a goal among the pano ids that is within that distance.
    goals = [goal for goal in streetlearn.graph
             if ((goal != self._current_goal_id) and
                 (goal != streetlearn.current_pano_id))]
    self._initial_distance_to_goal = float('inf')
    while self._initial_distance_to_goal > self._allowed_goal_distance:
      self._current_goal_id = np.random.choice(goals)
      self._min_distance_reached = streetlearn.engine.GetPanoDistance(
          streetlearn.current_pano_id, self._current_goal_id)
      self._initial_distance_to_goal = self._min_distance_reached
      logging.info(
          '%d CurriculumCourierGame: distance to goal: %f (max allowed: %f)',
          streetlearn.frame_count, self._initial_distance_to_goal,
          self._allowed_goal_distance) 
开发者ID:deepmind,项目名称:streetlearn,代码行数:22,代码来源:curriculum_courier_game.py

示例2: get_info

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def get_info(self, streetlearn):
    """"Returns current information about the state of the environment.

    Args:
      streetlearn: a StreetLearn instance.
    Returns:
      info: information from the environment at the last step.
    """
    info = super(CourierGame, self).get_info(streetlearn)
    info['num_steps_this_goal'] = self._num_steps_this_goal
    info['current_goal_id'] = self._current_goal_id
    info['min_distance_reached'] = self._min_distance_reached
    info['initial_distance_to_goal'] = self._initial_distance_to_goal
    info['reward_current_goal'] = self._reward_current_goal
    next_pano_id = self._panos_to_goal[streetlearn.current_pano_id]
    info['next_pano_id'] = next_pano_id
    bearing_to_next_pano = streetlearn.engine.GetPanoBearing(
        streetlearn.current_pano_id, next_pano_id) - streetlearn.engine.GetYaw()
    info['bearing_to_next_pano'] = (bearing_to_next_pano + 180) % 360 - 180
    return info 
开发者ID:deepmind,项目名称:streetlearn,代码行数:22,代码来源:courier_game.py

示例3: loop

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [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

示例4: DeployWebApp

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def DeployWebApp(self):
    """Bundle then deploy (or run locally) the web application."""
    self._BundleWebApp()

    if self.on_local:
      print('Run locally...')
    else:
      cmds = [
          'gcloud', 'app', 'deploy', '--no-promote', '--project={}'.format(
              self.project_id), '--version={}'.format(self.version)]
      for yaml_filename in self._yaml_files:
        cmds.append(self._GetYamlFile(yaml_filename))
      logging.info(
          'Deploying to the Google Cloud project: %s using gcloud...',
          self.project_id)
      _ExecuteCommand(cmds)

    if self.on_google_cloud_shell:
      self._CleanWebAppBackend() 
开发者ID:google,项目名称:loaner,代码行数:21,代码来源:deploy_impl.py

示例5: get_credentials

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def get_credentials(self, scopes):
    """Get the user credentials for deployment.

    Args:
      scopes: List[str], a list of the required scopes for this credential.

    Returns:
      A credentials.Credentials object for the authenticated user.
    """
    if os.path.isfile(self._config.local_credentials_file_path):
      creds = self._get_credentials_from_file(scopes)
      if creds:
        return creds
    else:
      logging.info(
          'Credentials were not found locally, requesting new credentials.')
    return self._request_new_credentials(scopes) 
开发者ID:google,项目名称:loaner,代码行数:19,代码来源:auth.py

示例6: _get_credentials_from_file

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def _get_credentials_from_file(self, scopes):
    """Gets the OAuth2 credential from file if it contains the scopes provided.

    Args:
      scopes: List[str], a list of the required scopes for this credential.

    Returns:
      A credentials.Credentials object for the authenticated user or None if the
          stored credential does not contain the provided scopes.
    """
    with open(
        self._config.local_credentials_file_path, 'r') as json_file:
      data = json.load(json_file)
      if data['scopes'] and set(scopes).issubset(set(data['scopes'])):
        logging.info('The requested scopes are authorized by this credential.')
        return credentials.Credentials.from_authorized_user_info(data, scopes)
      else:
        logging.info(
            'The requested scopes are not authorized by this credential. '
            'Requesting new credentials...')
    return None 
开发者ID:google,项目名称:loaner,代码行数:23,代码来源:auth.py

示例7: load_constants_from_storage

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def load_constants_from_storage(self):
    """Attempts to load constants from Google Cloud Storage."""
    try:
      constants = self._storage_api.get_blob(
          self._config.constants_storage_path,
          self._config.bucket,
      )
    except storage.NotFoundError as err:
      logging.error('Constants were not found in storage: %s', err)
    else:
      for name in self._constants.keys():
        try:
          self._constants[name].value = constants[name]
        except ValueError:
          logging.warning(
              'The value %r for %r stored in Google Cloud Storage does not meet'
              ' the requirements. Using the default value...',
              constants[name], name)
        except KeyError:
          logging.info(
              'The key %r was not found in the stored constants, this may be '
              'because a new constant was added since your most recent '
              'configuration. To resolve run `configure` in the main menu.',
              name) 
开发者ID:google,项目名称:loaner,代码行数:26,代码来源:gng_impl.py

示例8: lock

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def lock(self, user_email):
    """Disables a device via the Directory API.

    Args:
      user_email: str, email address of the user making the request.
    """
    logging.info(
        'Contacting Directory to lock (disable) Device %s.',
        self.identifier)
    client = directory.DirectoryApiClient(user_email)
    try:
      client.disable_chrome_device(self.chrome_device_id)
    except directory.DeviceAlreadyDisabledError as err:
      logging.error(_ALREADY_DISABLED_MSG, self.identifier, err)
    else:
      self.stream_to_bq(user_email, 'Disabling device %s.' % self.identifier)
    self.locked = True
    self.put() 
开发者ID:google,项目名称:loaner,代码行数:20,代码来源:device_model.py

示例9: unlock

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def unlock(self, user_email):
    """Re-enables a device via the Directory API.

    Args:
      user_email: str, email address of the user making the request.
    """
    logging.info(
        'Contacting Directory to unlock (re-enable) Device %s.',
        self.identifier)
    client = directory.DirectoryApiClient(user_email)
    client.reenable_chrome_device(self.chrome_device_id)
    if self.lost:
      self.lost = False
    self.locked = False
    self.move_to_default_ou(user_email=user_email)
    self.stream_to_bq(
        user_email, 'Re-enabling disabled device %s.' % self.identifier)
    self.put() 
开发者ID:google,项目名称:loaner,代码行数:20,代码来源:device_model.py

示例10: move_to_shelf

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def move_to_shelf(self, shelf, user_email):
    """Checks a device into a shelf.

    Args:
      shelf: shelf_model.Shelf obj, the shelf to check device into.
      user_email: str, the email of the user taking the action.

    Raises:
      UnableToMoveToShelfError: when a deivce can not be checked into a shelf.
    """
    if not shelf.enabled:
      raise UnableToMoveToShelfError(
          'Unable to check device {} to shelf. Shelf {} is not '
          'active.'.format(self.identifier, shelf.location))
    if self.assigned_user:
      self._loan_return(user_email=user_email)
    logging.info(
        'Checking device %s into shelf %s.', self.identifier, shelf.location)
    self.shelf = shelf.key
    self.last_known_healthy = datetime.datetime.utcnow()
    self.stream_to_bq(
        user_email, 'Placing device: %s on shelf: %s' % (
            self.identifier, shelf.location))
    self.put() 
开发者ID:google,项目名称:loaner,代码行数:26,代码来源:device_model.py

示例11: audit

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def audit(self, user_email, num_of_devices):
    """Marks a shelf audited.

    Args:
      user_email: str, email of the user auditing the shelf.
      num_of_devices: int, the number of devices on shelf.
    """
    self.last_audit_time = datetime.datetime.utcnow()
    self.last_audit_by = user_email
    self.audit_requested = False
    logging.info(_AUDIT_MSG, self.identifier, num_of_devices)
    event_action = 'shelf_audited'
    try:
      self = events.raise_event(event_action, shelf=self)
    except events.EventActionsError as err:
      # For any action that is implemented for shelf_audited that is required
      # for the rest of the logic an error should be raised. If all
      # actions are not required, eg sending a notification email only,
      # the error should only be logged.
      logging.error(_EVENT_ACTION_ERROR_MSG, event_action, err)
    self.put()
    self.stream_to_bq(
        user_email, _AUDIT_MSG % (self.identifier, num_of_devices)) 
开发者ID:google,项目名称:loaner,代码行数:25,代码来源:shelf_model.py

示例12: disable

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def disable(self, user_email):
    """Marks a shelf as disabled.

    Args:
      user_email: str, email of the user disabling the shelf.
    """
    self.enabled = False
    logging.info(_DISABLE_MSG, self.identifier)
    event_action = 'shelf_disable'
    try:
      self = events.raise_event(event_action, shelf=self)
    except events.EventActionsError as err:
      # For any action that is implemented for shelf_disable that is required
      # for the rest of the logic an error should be raised. If all
      # actions are not required, eg sending a notification email only,
      # the error should only be logged.
      logging.error(_EVENT_ACTION_ERROR_MSG, event_action, err)
    self.put()
    self.stream_to_bq(user_email, _DISABLE_MSG % self.identifier) 
开发者ID:google,项目名称:loaner,代码行数:21,代码来源:shelf_model.py

示例13: run

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def run(self, device=None):
    """Send an e-mail to the device assignee and remove reminder."""
    if not device:
      raise base_action.MissingDeviceError(
          'Cannot send mail. Task did not receive a device.')
    if not hasattr(device, 'next_reminder') or not device.next_reminder:
      raise base_action.BadDeviceError(
          'Cannot send mail without next_reminder on the following device: '
          '{}.'.format(device.identifier))
    reminder_event = event_models.ReminderEvent.get(device.next_reminder.level)
    if not reminder_event:
      raise base_action.BadDeviceError(
          'Cannot send mail. There is no ReminderEvent entity for level '
          '{}.'.format(device.next_reminder.level))
    if config_model.Config.get('loan_duration_email'):
      logging.info(
          'Sending email reminder at level %d to device %s.',
          device.next_reminder.level, device.identifier)
      send_email.send_user_email(device, reminder_event.template)
    device.set_last_reminder(device.next_reminder.level)
    device.next_reminder = None
    device.put() 
开发者ID:google,项目名称:loaner,代码行数:24,代码来源:send_reminder.py

示例14: _remind_for_devices

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def _remind_for_devices(self):
    """Find devices marked as being in a remindable state and raise event."""
    for device in device_model.Device.query(
        device_model.Device.next_reminder.time <= datetime.datetime.utcnow()
    ).fetch():
      logging.info(
          _DEVICE_REMINDING_NOW_MSG, device.identifier,
          device.next_reminder.level)
      try:
        events.raise_event(
            event_name=event_models.ReminderEvent.make_name(
                device.next_reminder.level),
            device=device)
      except events.EventActionsError as err:
        # We log the error so that a single device does not disrupt all other
        # devices that need reminders set.
        logging.error(_EVENT_ACTION_ERROR_MSG, err) 
开发者ID:google,项目名称:loaner,代码行数:19,代码来源:run_reminder_events.py

示例15: main

# 需要导入模块: from absl import logging [as 别名]
# 或者: from absl.logging import info [as 别名]
def main(unused_argv):
  generate.init_modules(FLAGS.train_split)

  output_dir = os.path.expanduser(FLAGS.output_dir)
  if os.path.exists(output_dir):
    logging.fatal('output dir %s already exists', output_dir)
  logging.info('Writing to %s', output_dir)
  os.makedirs(output_dir)

  for regime, flat_modules in six.iteritems(generate.filtered_modules):
    regime_dir = os.path.join(output_dir, regime)
    os.mkdir(regime_dir)
    per_module = generate.counts[regime]
    for module_name, module in six.iteritems(flat_modules):
      path = os.path.join(regime_dir, module_name + '.txt')
      with open(path, 'w') as text_file:
        for _ in range(per_module):
          problem, _ = generate.sample_from_module(module)
          text_file.write(str(problem.question) + '\n')
          text_file.write(str(problem.answer) + '\n')
      logging.info('Written %s', path) 
开发者ID:deepmind,项目名称:mathematics_dataset,代码行数:23,代码来源:generate_to_file.py


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