docstr: Compiles and compare the actual JSON output against a golden file.
docstr_tok: ["Compiles","and","compare","the","actual","JSON","output","against","a","golden","file","."]
code: def _compare_against_testdata(
      self,
      runner: kubeflow_v2_dag_runner.KubeflowV2DagRunner,
      pipeline: tfx_pipeline.Pipeline,
      golden_file: str,
  ):
      """Compiles and compare the actual JSON output against a golden file."""
      actual_output = runner.run(pipeline=pipeline, write_out=True)
  
      expected_json = json.loads(
          test_utils.get_text_from_test_data(golden_file)
      )
      expected_json["pipelineSpec"]["sdkVersion"] = "tfx-{}".format(
          version.__version__
      )
      if "labels" in expected_json:
          expected_json["labels"][
              "tfx_version"
          ] = telemetry_utils._normalize_label(version.__version__)
  
      self.assertDictEqual(actual_output, expected_json)
  
      with open(
          os.path.join(_TEST_DIR, _TEST_FILE_NAME)
      ) as pipeline_json_file:
          actual_json = json.load(pipeline_json_file)
  
      self.assertDictEqual(actual_json, expected_json)
  
imports: import collections
  import datetime
  import json
  import os
  from unittest import mock
  import tensorflow
  from tfx import version
  from tfx.dsl.components.base import base_component
  from tfx.orchestration import pipeline
  from tfx.orchestration.kubeflow.v2 import kubeflow_v2_dag_runner
  from tfx.orchestration.kubeflow.v2 import test_utils
  from tfx.utils import telemetry_utils
  from tfx.utils import test_case_utils
label_desc: Use image node_id 2 for calling the KubeflowV2DagRunnerTest obj's underlying member method code with example usage: obj._compare_against_testdata(runner, pipeline, golden_file) without return types