code: def _describe_migration_if_necessary(session):
      """
      If the targeted database contains any metric entries, this function emits important,
      database-specific information about the ``create_latest_metrics_table`` migration.
      If the targeted database does *not* contain any metric entries, this output is omitted
      in order to avoid superfluous log output when initializing a new Tracking database.
      """
      num_metric_entries = session.query(SqlMetric).count()
      if num_metric_entries <= 0:
          return
  
      _logger.warning(
          "**IMPORTANT**: This migration creates a `latest_metrics` table and populates it with the"
          " latest metric entry for each unique (run_id, metric_key) tuple. Latest metric entries are"
          " computed based on step, timestamp, and value. This migration may take a long time for"
          " databases containing a large number of metric entries. Please refer to {readme_link} for"
          " information about this migration, including how to estimate migration size and how to"
          " restore your database to its original state if the migration is unsuccessful. If you"
          " encounter failures while executing this migration, please file a GitHub issue at"
          " {issues_link}.".format(
              readme_link=(
                  "https://github.com/mlflow/mlflow/blob/master/mlflow/store/db_migrations/README.md"
                  "#89d4b8295536_create_latest_metrics_table"
              ),
              issues_link="https://github.com/mlflow/mlflow/issues",
          )
      )
  
      num_metric_keys = (
          session.query(SqlMetric.run_uuid, SqlMetric.key)
          .group_by(SqlMetric.run_uuid, SqlMetric.key)
          .count()
      )
      num_runs_containing_metrics = session.query(
          distinct(SqlMetric.run_uuid)
      ).count()
      _logger.info(
          "This tracking database has {num_metric_entries} total metric entries for {num_metric_keys}"
          " unique metrics across {num_runs} runs.".format(
              num_metric_entries=num_metric_entries,
              num_metric_keys=num_metric_keys,
              num_runs=num_runs_containing_metrics,
          )
      )
  
file_path: mlflow/mlflow/store/db_migrations/versions/89d4b8295536_create_latest_metrics_table.py
imports: import time
  import logging
  from alembic import op
  from sqlalchemy import orm, func, distinct, and_
  from sqlalchemy import Column, String, ForeignKey, Float, BigInteger, PrimaryKeyConstraint, Boolean
  from mlflow.store.tracking.dbmodels.models import SqlMetric, SqlLatestMetric
label_desc: Use image node_id 1 for calling a global function with example usage: _describe_migration_if_necessary(session) without return types