code: def get_tfx_pipeline_metadata_store(
      tmp_db_path: str,
  ) -> mlmd.MetadataStore:
      """Copies and opens a metadata_store from the testdata tfx pipeline db.
  
      It migrates the db to the compatible schema at the head. In addition, it
      updates the stored artifacts' uri to the test data db path, so that the test
      code can open the testdata files mentioned in the database.
  
      Args:
        tmp_db_path: a temp path for copying the pipeline database.
  
      Returns:
        A ml-metadata store for the copied pipeline db.
      """
      testdata_db_path = os.path.join(_TEST_DATA_DIR, _TFX_0_21_DB_FILE)
      shutil.copyfile(testdata_db_path, tmp_db_path)
  
      connection_config = metadata_store_pb2.ConnectionConfig(
          sqlite=metadata_store_pb2.SqliteMetadataSourceConfig(
              filename_uri=tmp_db_path,
              connection_mode=metadata_store_pb2.SqliteMetadataSourceConfig.READWRITE,
          )
      )
      # The pipeline db is created with mlmd 0.21, the test run from the head
      # may include newer mlmd schema versions. We migrate the db to newer
      # mlmd schema if needed.
      store = mlmd.MetadataStore(
          connection_config, enable_upgrade_migration=True
      )
      # The pipeline db is generated with real pipelines in which the payloads of
      # the artifacts are stored in the file system when the pipeline ran. We fix
      # the uri to point to the testdata payloads generated by the pipeline.
      fixed_artifacts = []
      for artifact in store.get_artifacts():
          artifact.uri = artifact.uri.replace(
              _TFX_0_21_PAYLOAD_DIR, _TEST_DATA_DIR
          )
          fixed_artifacts.append(artifact)
      store.put_artifacts(fixed_artifacts)
      return store
  
imports: import os
  import shutil
  import ml_metadata
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: get_tfx_pipeline_metadata_store(tmp_db_path) and returns: store