class_docstr: Operations with repos
class_docstr_tok: ["Operations","with","repos"]
code: def load(
      self,
      repo_dir: PathLike,
      local: bool = False,
      init: bool = False,
      git_identity_file: Optional[PathLike] = None,
      oauth_token: Optional[str] = None,
  ) -> Union[RemoteRepo, LocalRepo]:
      # """
      # Loads the repo from the local directory using global config
      #
      # Args:
      #     repo_dir: repo root directory
      #     local: do not try to load `RemoteRepo` first
      #     init: initialize the repo if it's not initialized
      #     git_identity_file: path to an SSH private key to access the remote repo
      #     oauth_token: GitHub OAuth token to access the remote repo
      #
      # Raises:
      #     ConfigurationError: if the repo is not initialized and `init` is `False`
      #
      # Returns:
      #     repo: initialized repo
      # """
      config = ConfigManager()
      if not init:
          logger.debug("Loading repo config")
          repo_config = config.get_repo_config(repo_dir)
          if repo_config is None:
              raise ConfigurationError(
                  f"The repo is not initialized. Run `dstack init` to initialize the repo."
              )
          repo = load_repo(repo_config)
          try:
              self._api_client.repos.get(
                  self._project, repo.repo_id, include_creds=False
              )
          except requests.HTTPError as e:
              if "404" in e.args[0]:
                  raise ConfigurationError(
                      f"The repo is not initialized. Run `dstack init` to initialize the repo."
                  )
              raise
      else:
          logger.debug("Initializing repo")
          repo = LocalRepo(repo_dir=repo_dir)  # default
          if not local:
              try:
                  repo = RemoteRepo(local_repo_dir=repo_dir)
              except InvalidGitRepositoryError:
                  pass  # use default
          self.init(repo, git_identity_file, oauth_token)
          config.save_repo_config(
              repo.repo_dir,
              repo.repo_id,
              RepoType(repo.run_repo_data.repo_type),
              get_ssh_keypair(None, config.dstack_key_path),
          )
      return repo
  
file_path: dstack/src/dstack/api/_public/repos.py
imports: from pathlib import Path
  from typing import Optional, Union
  import giturlparse
  import requests
  from git import InvalidGitRepositoryError
  from dstack._internal.core.errors import ConfigurationError
  from dstack._internal.core.models.repos import LocalRepo, RemoteRepo
  from dstack._internal.core.models.repos.base import Repo, RepoType
  from dstack._internal.core.services.configs import ConfigManager
  from dstack._internal.core.services.repos import InvalidRepoCredentialsError, get_local_repo_credentials, load_repo
  from dstack._internal.utils.crypto import generate_rsa_key_pair
  from dstack._internal.utils.logging import get_logger
  from dstack._internal.utils.path import PathLike
  from dstack.api.server import APIClient
label_desc: Use image node_id 4 for calling the RepoCollection obj's underlying member method code with example usage: obj.load(repo_dir, local, init, git_identity_file, oauth_token) and returns: repo