code: def testPrepareContexts_PipelineAndPipelineRunContext(self):
      node_contexts = pipeline_pb2.NodeContexts()
      self.load_proto_from_text(
          os.path.join(
              self._testdata_dir,
              "node_context_spec_pipeline_and_pipeline_run_context.pbtxt",
          ),
          node_contexts,
      )
      with metadata.Metadata(
          connection_config=self._connection_config
      ) as m:
          context_lib.prepare_contexts(
              metadata_handle=m, node_contexts=node_contexts
          )
          # Duplicated call should succeed.
          contexts = context_lib.prepare_contexts(
              metadata_handle=m, node_contexts=node_contexts
          )
  
          # Check the created contexts.
          self.assertLen(contexts, 3)
          self.assertProtoEquals(
              contexts[0],
              m.store.get_context_by_type_and_name(
                  "pipeline", "pipeline-name"
              ),
          )
          self.assertEqual(
              contexts[1],
              m.store.get_context_by_type_and_name(
                  "pipeline_run", "run-20220912-213149-252011"
              ),
          )
          self.assertEqual(
              contexts[2],
              m.store.get_context_by_type_and_name(
                  "node", "pipeline-name.example-gen.import-example"
              ),
          )
  
          # Check the parent and child relationship between pipeline and pipeline
          # run contexts.
          self.assertCountEqual(
              [contexts[1]],
              m.store.get_children_contexts_by_context(contexts[0].id),
          )
          self.assertEqual(
              [contexts[0]],
              m.store.get_parent_contexts_by_context(contexts[1].id),
          )
  
file_path: tfx/tfx/orchestration/portable/mlmd/context_lib_test.py
imports: import os
  import tensorflow
  from tfx.orchestration import metadata
  from tfx.orchestration.portable.mlmd import context_lib
  from tfx.proto.orchestration import pipeline_pb2
  from tfx.utils import test_case_utils
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 3 for calling the ContextLibTest obj's underlying member method code with example usage: obj.testPrepareContexts_PipelineAndPipelineRunContext() without return types