Parses the session_run_index value from the event proto.

    Args:
      event: The event with metadata that contains the session_run_index.

    Returns:
      The int session_run_index value. Or
      constants.SENTINEL_FOR_UNDETERMINED_STEP if it could not be determined.

def _parse_session_run_index(self, event):
    """Parses the session_run_index value from the event proto.

    Args:
      event: The event with metadata that contains the session_run_index.

    Returns:
      The int session_run_index value. Or
      constants.SENTINEL_FOR_UNDETERMINED_STEP if it could not be determined.
    """
    metadata_string = event.log_message.message
    try:
      metadata = json.loads(metadata_string)
    except ValueError as e:
      logger.error(
          "Could not decode metadata string '%s' for step value: %s",
          metadata_string, e)
      return constants.SENTINEL_FOR_UNDETERMINED_STEP

    try:
      return metadata["session_run_index"]
    except KeyError:
      logger.error(
          "The session_run_index is missing from the metadata: %s",
          metadata_string)
      return constants.SENTINEL_FOR_UNDETERMINED_STEP