code: def check_repo_integrity(repo: Repo, legacy_run_map: dict):
      try:
          ok = True
          with click.progressbar(
              repo.iter_runs(),
              item_show_func=lambda r: (
                  f"Checking run {r.hash}" if r else ""
              ),
          ) as runs:
              for run in runs:
                  legacy_hash = run.get(["v2_params", "run_hash"])
                  run_metrics = legacy_run_map.pop(legacy_hash)
                  for metric_name, ctx, _ in run.iter_metrics_info():
                      idx = run_metrics[metric_name].index(
                          ctx.to_dict()
                      )
                      run_metrics[metric_name].pop(idx)
                      if not run_metrics[metric_name]:
                          del run_metrics[metric_name]
                  if run_metrics:
                      click.echo(
                          f"Run '{run.hash}' ['{legacy_hash}'] missing metrics '{run_metrics.keys()}'."
                      )
                      ok = False
          if legacy_run_map:
              click.echo(
                  f"Repo missing runs '{legacy_run_map.keys()}'."
              )
              ok = False
      except (KeyError, ValueError):
          ok = False
      if not ok:
          raise RepoIntegrityError
  
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 4 for calling a global function with example usage: check_repo_integrity(repo, legacy_run_map) without return types