class_docstr: Kubeflow V2 pipeline runner (currently for managed pipelines).
  
  Builds a pipeline job spec in json format based on TFX pipeline DSL object.
class_docstr_tok: ["Kubeflow","V2","pipeline","runner","(","currently","for","managed","pipelines",")",".","Builds","a","pipeline","job","spec","in","json","format","based","on","TFX","pipeline","DSL","object","."]
docstr: Compiles a pipeline DSL object into pipeline file.
  
  Args:
    pipeline: TFX pipeline object.
    parameter_values: mapping from runtime parameter names to its values.
    write_out: set to True to actually write out the file to the place
      designated by output_dir and output_filename. Otherwise return the
      JSON-serialized pipeline job spec.
  
  Returns:
    Returns the JSON pipeline job spec.
  
  Raises:
    RuntimeError: if trying to write out to a place occupied by an existing
    file.
docstr_tok: ["Compiles","a","pipeline","DSL","object","into","pipeline","file",".","Args",":","pipeline",":","TFX","pipeline","object",".","parameter_values",":","mapping","from","runtime","parameter","names","to","its","values",".","write_out",":","set","to","True","to","actually","write","out","the","file","to","the","place","designated","by","output_dir","and","output_filename",".","Otherwise","return","the","JSON-serialized","pipeline","job","spec",".","Returns",":","Returns","the","JSON","pipeline","job","spec",".","Raises",":","RuntimeError",":","if","trying","to","write","out","to","a","place","occupied","by","an","existing","file","."]
code: def run(
      self,
      pipeline: tfx_pipeline.Pipeline,
      parameter_values: Optional[Dict[str, Any]] = None,
      write_out: Optional[bool] = True,
  ) -> Dict[str, Any]:
      """Compiles a pipeline DSL object into pipeline file.
  
      Args:
        pipeline: TFX pipeline object.
        parameter_values: mapping from runtime parameter names to its values.
        write_out: set to True to actually write out the file to the place
          designated by output_dir and output_filename. Otherwise return the
          JSON-serialized pipeline job spec.
  
      Returns:
        Returns the JSON pipeline job spec.
  
      Raises:
        RuntimeError: if trying to write out to a place occupied by an existing
        file.
      """
      for component in pipeline.components:
          # TODO(b/187122662): Pass through pip dependencies as a first-class
          # component flag.
          if isinstance(component, base_component.BaseComponent):
              component._resolve_pip_dependencies(  # pylint: disable=protected-access
                  pipeline.pipeline_info.pipeline_root
              )
  
      # TODO(b/166343606): Support user-provided labels.
      # TODO(b/169095387): Deprecate .run() method in favor of the unified API
      # client.
      display_name = (
          self._config.display_name
          or pipeline.pipeline_info.pipeline_name
      )
      pipeline_spec = pipeline_builder.PipelineBuilder(
          tfx_pipeline=pipeline,
          default_image=self._config.default_image,
          default_commands=self._config.default_commands,
          exit_handler=self._exit_handler,
      ).build()
      pipeline_spec.sdk_version = "tfx-{}".format(version.__version__)
      pipeline_spec.schema_version = _SCHEMA_VERSION
      runtime_config = pipeline_builder.RuntimeConfigBuilder(
          pipeline_info=pipeline.pipeline_info,
          parameter_values=parameter_values,
      ).build()
      with telemetry_utils.scoped_labels(
          {telemetry_utils.LABEL_TFX_RUNNER: "kubeflow_v2"}
      ):
          result = pipeline_spec_pb2.PipelineJob(
              display_name=display_name
              or pipeline.pipeline_info.pipeline_name,
              labels=telemetry_utils.make_labels_dict(),
              runtime_config=runtime_config,
          )
      result.pipeline_spec.update(
          json_format.MessageToDict(pipeline_spec)
      )
      pipeline_json_dict = json_format.MessageToDict(result)
      if write_out:
          if fileio.exists(self._output_dir) and not fileio.isdir(
              self._output_dir
          ):
              raise RuntimeError(
                  "Output path: %s is pointed to a file."
                  % self._output_dir
              )
          if not fileio.exists(self._output_dir):
              fileio.makedirs(self._output_dir)
  
          with fileio.open(
              os.path.join(self._output_dir, self._output_filename),
              "wb",
          ) as f:
              f.write(json.dumps(pipeline_json_dict, sort_keys=True))
  
      return pipeline_json_dict
  
imports: import datetime
  import json
  import os
  from typing import Any, Dict, List, Optional, Union, MutableMapping
  from absl import logging
  from kfp.pipeline_spec import pipeline_spec_pb2
  from tfx import version
  from tfx.dsl.components.base import base_component
  from tfx.dsl.components.base import base_node
  from tfx.dsl.io import fileio
  from tfx.orchestration import pipeline
  from tfx.orchestration import tfx_runner
  from tfx.orchestration.config import pipeline_config
  from tfx.orchestration.kubeflow.v2 import pipeline_builder
  from tfx.utils import telemetry_utils
  from tfx.utils import version_utils
  from google.protobuf import json_format
label_desc: Use image node_id 3 for calling the KubeflowV2DagRunner obj's underlying member method code with example usage: obj.run(pipeline, parameter_values, write_out) and returns: pipeline_json_dict