code: def execute_component_from_config(
      config: "TaskConfigSpec", output_path
  ):
      import json
      import logging
      import traceback
  
      from fate.arch import CipherKit, Context
      from fate.arch.trace import profile_ends, profile_start
      from fate.components.core import (
          ComponentExecutionIO,
          Role,
          Stage,
          load_component,
          load_computing,
          load_device,
          load_federation,
          load_metric_handler,
          is_root_worker,
      )
  
      logger = logging.getLogger(__name__)
      logger.debug(f"logging final status to  `{output_path}`")
      try:
          party_task_id = config.party_task_id
          device = load_device(config.conf.device)
          computing = load_computing(
              config.conf.computing, config.conf.logger.config
          )
          if is_root_worker():
              federation = load_federation(
                  config.conf.federation, computing
              )
          else:
              federation = None
              logger.info(
                  "skip federation initialization for non-root worker"
              )
          cipher = CipherKit(device=device)
          ctx = Context(
              device=device,
              computing=computing,
              federation=federation,
              cipher=cipher,
          )
          role = Role.from_str(config.role)
          stage = Stage.from_str(config.stage)
          logger.debug(f"component={config.component}, context={ctx}")
          logger.debug("running...")
  
          # get correct component_desc/subcomponent handle stage
          component = load_component(config.component, stage)
  
          # enable profiling
          profile_start()
  
          # prepare
          execution_io = ComponentExecutionIO(
              ctx, component, role, stage, config
          )
  
          # register metric handler
          metrics_handler = load_metric_handler(
              execution_io.get_metric_writer()
          )
          ctx.set_metric_handler(metrics_handler)
  
          # execute
          component.execute(ctx, role, **execution_io.get_kwargs())
  
          # finalize metric handler
          metrics_handler.finalize()
          # final execution io meta
          execution_io_meta = execution_io.dump_io_meta()
          try:
              with open(output_path, "w") as fw:
                  json.dump(
                      dict(
                          status=dict(code=0), io_meta=execution_io_meta
                      ),
                      fw,
                      indent=4,
                  )
          except Exception as e:
              raise RuntimeError(
                  f"failed to dump execution io meta to `{output_path}`: meta={execution_io_meta}"
              ) from e
  
          profile_ends()
          logger.debug(
              "done without error, waiting signal to terminate"
          )
          logger.debug("terminating, bye~")
  
      except Exception as e:
          logger.error(e, exc_info=True)
          with open(output_path, "w") as fw:
              json.dump(
                  dict(
                      status=dict(
                          code=-1, exceptions=traceback.format_exc()
                      )
                  ),
                  fw,
              )
          raise e
  
imports: import os
  import typing
  import click
label_desc: Use image node_id 2 for calling a global function with example usage: execute_component_from_config(config, output_path) without return types