code: def convert_2to3(
      path: str,
      drop_existing: bool = False,
      skip_failed_runs: bool = False,
      skip_checks: bool = False,
  ):
      lrepo_path, repo_path, lrepo_dump_path = setup_directories(path)
  
      def _rollback():
          shutil.rmtree(repo_path, ignore_errors=True)
          if os.environ.get(AIM_REPO_NAME):
              del os.environ[AIM_REPO_NAME]
  
      try:
          click.echo("Preparing new repository...")
          lrepo = LegacyRepo(
              mode=LegacyRepo.READING_MODE, repo_full_path=lrepo_path
          )
          repo = Repo.from_path(repo_path, init=True)
  
          click.echo("Analyzing legacy repository...")
          lruns = collect_runs(lrepo)
          click.echo(f"Collected {len(lruns)} runs.")
  
          legacy_run_map = {}
          with repo.structured_db:
              with click.progressbar(
                  lruns,
                  show_pos=True,
                  item_show_func=lambda r: (
                      f"Converting run {r.run_hash}" if r else ""
                  ),
              ) as legacy_runs:
                  for lrun in legacy_runs:
                      convert_run(
                          lrun,
                          repo,
                          legacy_run_map,
                          skip_failed=skip_failed_runs,
                      )
  
          if not skip_checks:
              click.echo("Checking repository integrity...")
              check_repo_integrity(repo, legacy_run_map)
              click.echo("Repository integrity check passed!")
          else:
              click.echo("WARN Skipping repository integrity checks.")
      except KeyboardInterrupt:
          click.echo("Convert interrupted by client. Rolling back...")
          _rollback()
          return
      except RepoIntegrityError:
          click.echo(
              "Repository integrity check failed. Rolling back...",
              err=True,
          )
          click.echo(
              "If you want to convert repository anyway, please rerun command with '--skip-checks' flag."
          )
          _rollback()
          return
      except Exception as e:
          click.echo(
              f"Failed to convert repository. " f"Reason: {str(e)}"
          )
          _rollback()
          return
      if drop_existing:
          click.echo("Removing legacy repository...")
          shutil.rmtree(lrepo_path)
      else:
          shutil.move(lrepo_path, lrepo_dump_path)
          click.echo(
              f"Legacy repository can be found at '{lrepo_dump_path}'."
          )
      shutil.move(repo_path, lrepo_path)
      if os.environ.get(AIM_REPO_NAME):
          del os.environ[AIM_REPO_NAME]
      click.echo("DONE")
      return repo
  
file_path: aim/aim/cli/upgrade/utils.py
imports: import os.path
  import click
  import shutil
  from aim.cli.upgrade._legacy_repo import AimRepo, Run, deserialize_pb, AIM_MAP_METRICS_KEYWORD
  from aim.sdk.configs import AIM_REPO_NAME
  from aim.sdk.utils import clean_repo_path
  from aim.sdk.run import Run
  from aim.sdk.repo import Repo
label_desc: Use image node_id 5 for calling a global function with example usage: convert_2to3(path, drop_existing, skip_failed_runs, skip_checks) and returns: repo