ML Metadata

raw JSON →
1.17.1 verified Fri May 01 auth: no python

A library for maintaining and managing metadata for ML artifacts, executions, and contexts. Current version: 1.17.1. Supports Python 3.9-3.11. Release cadence: roughly quarterly.

pip install ml-metadata
error ImportError: cannot import name 'metadata_store' from 'ml_metadata'
cause Incorrect import path; top-level ml_metadata does not contain metadata_store directly.
fix
Use 'from ml_metadata.metadata_store import metadata_store'.
error AttributeError: module 'ml_metadata' has no attribute 'MetadataStore'
cause MetadataStore is a protobuf message, not a class in the ml_metadata module.
fix
Import the protobuf module: 'from ml_metadata.proto import metadata_store_pb2' and use 'metadata_store_pb2.MetadataStore'.
error TypeError: Can't instantiate abstract class MetadataStore with abstract methods...
cause Trying to instantiate metadata_store.MetadataStore with wrong connection config or missing SetInParent on fake database.
fix
Use 'connection_config.fake_database.SetInParent()' before creating the store.
breaking Deprecated GetLineageGraph API removed in v1.15.0; use GetLineageSubgraph instead.
fix Replace calls to GetLineageGraph with GetLineageSubgraph.
deprecated Windows OS support is deprecated as of v1.15.0.
fix Use Linux or macOS; consider running in a container.
deprecated Python 3.8 support dropped in v1.15.0; Python 3.7 support dropped in v1.13.0.
fix Use Python 3.9, 3.10, or 3.11.
gotcha Protobuf version constraints: v1.17.0+ requires protobuf>=4.25.2,<5 for Python 3.11; protobuf>4.21.6,<5 for 3.9/3.10.
fix Ensure protobuf is installed with correct version constraints.

Initialize a fake in-memory MLMD store to verify installation.

import ml_metadata as mlmd
from ml_metadata.metadata_store import metadata_store
from ml_metadata.proto import metadata_store_pb2

connection_config = metadata_store_pb2.ConnectionConfig()
connection_config.fake_database.SetInParent()
store = metadata_store.MetadataStore(connection_config)
print('ML Metadata store initialized successfully')