class_docstr: Google Artifact Registry helper for interacting with the registry.
  
  This helper should be constructed from either a uri or a repository,
  project, and optional image-name. If constructed from a uri, the uri
  must be of the form REGION-docker.pkg.dev/PROJECT/REPOSITORY/[IMAGE_NAME],
  with an optional https:// preceding.
class_docstr_tok: ["Google","Artifact","Registry","helper","for","interacting","with","the","registry",".","This","helper","should","be","constructed","from","either","a","uri","or","a","repository",",","project",",","and","optional","image-name",".","If","constructed","from","a","uri",",","the","uri","must","be","of","the","form","REGION-docker.pkg.dev\/PROJECT\/REPOSITORY\/","[","IMAGE_NAME","]",",","with","an","optional","https",":","\/\/","preceding","."]
docstr: Initialize the Google Artifact Registry.
  
  Either uri or repository and image_name must be provided. Project and
  region are optional, and will be inferred from the uri if provided, or
  from the default credentials if not.
  
  Arguments:
      uri (optional): The uri of the repository.
      repository (optional): The repository name.
      image_name (optional): The image name.
      project (optional): The GCP project name.
      region (optional): The GCP region name.
  
  Raises:
      LaunchError: If verify is True and the container registry or its
          environment have not been properly configured. Or if the environment
          is not an instance of GcpEnvironment.
docstr_tok: ["Initialize","the","Google","Artifact","Registry",".","Either","uri","or","repository","and","image_name","must","be","provided",".","Project","and","region","are","optional",",","and","will","be","inferred","from","the","uri","if","provided",",","or","from","the","default","credentials","if","not",".","Arguments",":","uri","(","optional",")",":","The","uri","of","the","repository",".","repository","(","optional",")",":","The","repository","name",".","image_name","(","optional",")",":","The","image","name",".","project","(","optional",")",":","The","GCP","project","name",".","region","(","optional",")",":","The","GCP","region","name",".","Raises",":","LaunchError",":","If","verify","is","True","and","the","container","registry","or","its","environment","have","not","been","properly","configured",".","Or","if","the","environment","is","not","an","instance","of","GcpEnvironment","."]
code: def __init__(
      self,
      uri: Optional[str] = None,
      repository: Optional[str] = None,
      image_name: Optional[str] = None,
      project: Optional[str] = None,
      region: Optional[str] = None,
  ) -> None:
      """Initialize the Google Artifact Registry.
  
      Either uri or repository and image_name must be provided. Project and
      region are optional, and will be inferred from the uri if provided, or
      from the default credentials if not.
  
      Arguments:
          uri (optional): The uri of the repository.
          repository (optional): The repository name.
          image_name (optional): The image name.
          project (optional): The GCP project name.
          region (optional): The GCP region name.
  
      Raises:
          LaunchError: If verify is True and the container registry or its
              environment have not been properly configured. Or if the environment
              is not an instance of GcpEnvironment.
      """
      _logger.info(
          f"Initializing Google Artifact Registry with repository {repository} "
          f"and image name {image_name}"
      )
  
      if uri is not None:
          self.uri = uri
          # Raise an error if any other kwargs were provided in addition to uri.
          if any([repository, image_name, project, region]):
              raise LaunchError(
                  "The Google Artifact Registry must be specified with either "
                  "the uri key or the repository, image-name, project and region "
                  "keys, but not both."
              )
          match = GCP_ARTIFACT_REGISTRY_URI_REGEX.match(self.uri)
          if not match:
              raise LaunchError(
                  f"The Google Artifact Registry uri {self.uri} is invalid. "
                  "Please provide a uri of the form "
                  "REGION-docker.pkg.dev/PROJECT/REPOSITORY/IMAGE_NAME."
              )
          self.project = match.group("project")
          self.region = match.group("region")
          self.repository = match.group("repository")
          self.image_name = match.group("image_name")
      else:
          if any(x is None for x in (repository, region, image_name)):
              raise LaunchError(
                  "The Google Artifact Registry must be specified with either "
                  "the uri key or the repository, image-name, project and region "
                  "keys."
              )
          self.project = project
          self.region = region
          self.repository = repository
          self.image_name = image_name
          self.uri = f"{self.region}-docker.pkg.dev/{self.project}/{self.repository}/{self.image_name}"
  
      _missing_kwarg_msg = (
          "The Google Artifact Registry is missing the {} kwarg. "
          "Please specify it by name or as part of the uri argument."
      )
      if not self.region:
          raise LaunchError(_missing_kwarg_msg.format("region"))
      if not self.repository:
          raise LaunchError(_missing_kwarg_msg.format("repository"))
      if not self.image_name:
          raise LaunchError(_missing_kwarg_msg.format("image-name"))
      # Try to load default project from the default credentials.
      self.credentials, project = google.auth.default()
      self.project = self.project or project
      self.credentials.refresh(google.auth.transport.requests.Request())
  
file_path: wandb/wandb/sdk/launch/registry/google_artifact_registry.py
imports: import logging
  from typing import Optional, Tuple
  import google.auth
  import google.cloud.artifactregistry
  from wandb.sdk.launch.errors import LaunchError
  from wandb.sdk.launch.utils import GCP_ARTIFACT_REGISTRY_URI_REGEX, event_loop_thread_exec
  from wandb.util import get_module
  from .abstract import AbstractRegistry
label_desc: Use image node_id 1 to create a new GoogleArtifactRegistry object from inherited base classes: AbstractRegistry with example: obj = GoogleArtifactRegistry(uri, repository, image_name, project, region)