code: def run(self):
      from dvc.repo.metrics.show import to_relpath
      from dvc.utils import errored_revisions
  
      metrics = self.repo.metrics.show(
          self.args.targets,
          all_branches=self.args.all_branches,
          all_tags=self.args.all_tags,
          all_commits=self.args.all_commits,
      )
      metrics = {
          k: to_relpath(self.repo.fs, self.repo.root_dir, v)
          for k, v in metrics.items()
      }
  
      if errored := errored_revisions(metrics):
          ui.error_write(
              "DVC failed to load some metrics for following revisions:"
              f" '{', '.join(errored)}'."
          )
  
      if self.args.json:
          ui.write_json(metrics, default=encode_exception)
      else:
          from dvc.compare import show_metrics
  
          show_metrics(
              metrics,
              markdown=self.args.markdown,
              all_branches=self.args.all_branches,
              all_tags=self.args.all_tags,
              all_commits=self.args.all_commits,
              precision=self.args.precision or DEFAULT_PRECISION,
              round_digits=True,
          )
  
      return 0
  
file_path: dvc/dvc/commands/metrics.py
imports: from dvc.cli import completion, formatter
  from dvc.cli.command import CmdBase
  from dvc.cli.utils import append_doc_link
  from dvc.log import logger
  from dvc.ui import ui
  from dvc.utils.serialize import encode_exception
label_desc: Use image node_id 1 for calling the CmdMetricsShow obj's underlying member method code with example usage: obj.run() and returns: int