code: def migration(*, override_config: dict[str, t.Any]):
      # We will use a flattened config to make it easier to migrate,
      # Then we will convert it back to a nested config.
      if depth(override_config) > 1:
          raise ValueError(
              "'override_config' must be a flattened dictionary."
          ) from None
  
      if "version" not in override_config:
          override_config["version"] = 1
  
      # First we migrate api_server field
      # 1. remove api_server.max_request_size (deprecated)
      rename_fields(
          override_config,
          current="api_server.max_request_size",
          remove_only=True,
      )
  
      # 2. migrate api_server.[host|port] -> api_server.http.[host|port]
      for f in ["host", "port"]:
          rename_fields(
              override_config,
              current=f"api_server.{f}",
              replace_with=f"api_server.http.{f}",
          )
  
      # 3. migrate api_server.cors.[access_control_*] -> api_server.http.cors.[*]
      rename_fields(
          override_config,
          current="api_server.cors.enabled",
          replace_with="api_server.http.cors.enabled",
      )
      for f in [
          "allow_origin",
          "allow_credentials",
          "allow_headers",
          "allow_methods",
          "max_age",
          "expose_headers",
      ]:
          rename_fields(
              override_config,
              current=f"api_server.cors.access_control_{f}",
              replace_with=f"api_server.http.cors.access_control_{f}",
          )
  
      rename_fields(
          override_config,
          current="api_server.http.cors.access_control_allow_origin",
          replace_with="api_server.http.cors.access_control_allow_origins",
      )
  
      # 4. if ssl is present, in version 2 we introduce a api_server.ssl.enabled field to determine
      # whether user want to enable SSL.
      if (
          len(
              [
                  f
                  for f in override_config
                  if f.startswith("api_server.ssl")
              ]
          )
          != 0
      ):
          override_config["api_server.ssl.enabled"] = True
  
      # 5. migrate all tracing fields to api_server.tracing
      # 5.1. migrate tracing.type -> api_server.tracing.expoerter_type
      rename_fields(
          override_config,
          current="tracing.type",
          replace_with="tracing.exporter_type",
      )
      # 5.2. for Zipkin and OTLP, migrate tracing.[exporter].url -> api_server.tracing.[exporter].endpoint
      for exporter in ["zipkin", "otlp"]:
          rename_fields(
              override_config,
              current=f"tracing.{exporter}.url",
              replace_with=f"tracing.{exporter}.endpoint",
          )
      # 5.3. For Jaeger, migrate tracing.jaeger.[address|port] -> api_server.tracing.jaeger.thrift.[agent_host_name|agent_port]
      rename_fields(
          override_config,
          current="tracing.jaeger.address",
          replace_with="tracing.jaeger.thrift.agent_host_name",
      )
      rename_fields(
          override_config,
          current="tracing.jaeger.port",
          replace_with="tracing.jaeger.thrift.agent_port",
      )
      # we also need to choose which protocol to use for jaeger.
      if (
          len(
              [
                  f
                  for f in override_config
                  if f.startswith("api_server.tracing.jaeger.thrift")
              ]
          )
          != 0
      ):
          override_config["tracing.jaeger.protocol"] = "thrift"
      # 6. Last but not least, moving logging.formatting.* -> api_server.logging.access.format.*
      for f in ["trace_id", "span_id"]:
          rename_fields(
              override_config,
              current=f"logging.formatting.{f}_format",
              replace_with=f"api_server.logging.access.format.{f}",
          )
      # 7. move timeout to traffic.timeout
      for namespace in ("api_server", "runners"):
          rename_fields(
              override_config,
              current=f"{namespace}.timeout",
              replace_with=f"{namespace}.traffic.timeout",
          )
      for key in list(override_config):
          if key.startswith("runners."):
              runner_name = key.split(".")[1]
              if any(
                  key.schema == runner_name for key in _RUNNER_CONFIG
              ):
                  continue
              rename_fields(
                  override_config,
                  current=f"runners.{runner_name}.timeout",
                  replace_with=f"runners.{runner_name}.traffic.timeout",
              )
      return unflatten(override_config)
  
file_path: BentoML/grpc-client/bentoml/_internal/configuration/v1/__init__.py
imports: from __future__ import annotations
  import re
  import typing
  import schema
  from ...utils.metrics import DEFAULT_BUCKET
  from ...utils.unflatten import unflatten
  from ..helpers import depth
  from ..helpers import ensure_iterable_type
  from ..helpers import ensure_larger_than
  from ..helpers import ensure_larger_than_zero
  from ..helpers import ensure_range
  from ..helpers import is_valid_ip_address
  from ..helpers import rename_fields
  from ..helpers import validate_otlp_protocol
  from ..helpers import validate_tracing_type
label_desc: Use image node_id 1 for calling a global function with example usage: migration() and returns: unflatten