code: def convert_run(
      lrun: LegacyRun, repo: Repo, legacy_run_map, skip_failed
  ):
      try:
          run = Run(
              repo=repo, system_tracking_interval=None
          )  # do not track system metrics as they already logged if needed
  
          lrun.open_storage()
          if lrun.params.get(AIM_MAP_METRICS_KEYWORD):
              del lrun.params[
                  AIM_MAP_METRICS_KEYWORD
              ]  # set internally. no need to copy
          run[...] = lrun.params
          run["v2_params"] = {"run_hash": lrun.run_hash}
          if "process" in lrun.config:
              run["v2_params", "start_date"] = lrun.config["process"][
                  "start_date"
              ]
              run["v2_params", "finish_date"] = lrun.config["process"][
                  "finish_date"
              ]
  
          run.experiment = lrun.experiment_name
          if lrun.config.get("archived"):
              run.archived = True
  
          run_metrics = {}
          legacy_run_map[lrun.run_hash] = run_metrics
          for metric in lrun.get_all_metrics().values():
              try:
                  metric.open_artifact()
                  run_metrics[metric.name] = []
                  for trace in metric.get_all_traces():
                      metric_name = metric.name
                      context = trace.context
                      run_metrics[metric.name].append(context)
                      for r in trace.read_records(slice(0, None, 1)):
                          step_record, metric_record = deserialize_pb(r)
                          # no need to track in a separate thread. use _track_impl directly.
                          run._track_impl(
                              metric_record.value,
                              step_record.timestamp,
                              metric_name,
                              step_record.step,
                              step_record.epoch,
                              context=context,
                          )
              except Exception:
                  metric.close_artifact()
                  raise
              finally:
                  metric.close_artifact()
          del run
      except Exception as e:
          click.echo(
              f"\nFailed to convert run {lrun.run_hash}. Reason: {str(e)}.",
              err=True,
          )
          if not skip_failed:
              raise
      finally:
          lrun.close_storage()
  
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 3 for calling a global function with example usage: convert_run(lrun, repo, legacy_run_map, skip_failed) without return types