class_docstr: Patches KubeflowV2DagRunner.run() with several customizations for CLI.
code: def _before_run(  # pytype: disable=signature-mismatch  # overriding-parameter-type-checks
      self,
      runner: tfx_runner.TfxRunner,
      pipeline: tfx_pipeline.Pipeline,
      context: MutableMapping[str, Any],
  ) -> None:
      runner = typing.cast(
          kubeflow_v2_dag_runner.KubeflowV2DagRunner, runner
      )
      runner_config = typing.cast(
          kubeflow_v2_dag_runner.KubeflowV2DagRunnerConfig,
          runner.config,
      )
      if self._build_image_fn is not None:
          # Replace the image for the pipeline with the newly built image name.
          # This new image name will include the sha256 image id.
          runner_config.default_image = self._build_image_fn(
              runner_config.default_image
          )
  
      # pylint: disable=protected-access
      if self._prepare_dir_fn is not None:
          runner._output_dir = self._prepare_dir_fn(
              context[self.PIPELINE_NAME]
          )
          runner._output_filename = OUTPUT_FILENAME
  
      context[self.OUTPUT_FILE_PATH] = os.path.join(
          runner._output_dir, runner._output_filename
      )
  
file_path: tfx/tfx/tools/cli/handler/kubeflow_v2_dag_runner_patcher.py
imports: import os
  import typing
  from typing import Any, Callable, MutableMapping, Optional, Type
  from tfx.orchestration import pipeline
  from tfx.orchestration import tfx_runner
  from tfx.orchestration.kubeflow.v2 import kubeflow_v2_dag_runner
  from tfx.tools.cli.handler import dag_runner_patcher
label_desc: Use image node_id 2 for calling the KubeflowV2DagRunnerPatcher obj's underlying member method code with example usage: obj._before_run(runner, pipeline, context) without return types