import re


def _parse_gcs_path(gcs_path):
  """Parse GCS path into bucket and path.

  Args:
    gcs_path: a GCS path, e.g. gs://bucket/foo/bar
  Returns:
    (bucket, path), e.g. ('bucket', 'foo/bar') for gs://bucket/foo/bar'.
  Raises:
    ValueError: if gcs_path is not a GCS path.
  """
  m = re.match("^gs://([^/]+)(?:/(.*))?$", gcs_path)
  if m is None:
    raise ValueError('Not a gcs path: "{}"'.format(gcs_path))
  return (m.group(1), m.group(2) or "")