ML Metadata (MLMD) is a library for recording and retrieving metadata associated with ML developer and data scientist workflows.
NOTE: ML Metadata may be backwards incompatible before version 1.0.
For more background on MLMD and instructions on using it, see the getting started guide
The recommended way to install ML Metadata is to use the PyPI package:
pip install ml-metadataThen import the relevant packages:
from ml_metadata import metadata_store
from ml_metadata.proto import metadata_store_pb2ML Metadata (MLMD) also hosts nightly packages at https://pypi-nightly.tensorflow.org on Google Cloud. To install the latest nightly package, please use the following command:
pip install --extra-index-url https://pypi-nightly.tensorflow.org/simple ml-metadataThis is the recommended way to build ML Metadata under Linux, and is continuously tested at Google.
Please first install docker and docker-compose by following the directions:
docker;
docker-compose.
Then, run the following at the project root:
DOCKER_SERVICE=manylinux-python${PY_VERSION}
sudo docker compose build ${DOCKER_SERVICE}
sudo docker compose run ${DOCKER_SERVICE}where PY_VERSION is one of {39, 310, 311}.
A wheel will be produced under dist/, and installed as follows:
pip install dist/*.whlTo compile and use ML Metadata, you need to set up some prerequisites.
If Bazel is not installed on your system, install it now by following these directions.
If cmake is not installed on your system, install it now by following these directions.
git clone https://github.com/google/ml-metadata
cd ml-metadataNote that these instructions will install the latest master branch of ML
Metadata. If you want to install a specific branch (such as a release branch),
pass -b <branchname> to the git clone command.
ML Metadata uses Bazel to build the pip package from source:
python setup.py bdist_wheelYou can find the generated .whl file in the dist subdirectory.
pip install dist/*.whlML Metadata uses Bazel to build the c++ binary from source:
bazel build -c opt --define grpc_no_ares=true //ml_metadata/metadata_store:metadata_store_serverMLMD is built and tested on the following 64-bit operating systems:
- macOS 10.14.6 (Mojave) or later.
- Ubuntu 20.04 or later.
- [DEPRECATED] Windows 10 or later. For a Windows-compatible library, please refer to MLMD 1.14.0 or earlier versions.
Before releasing, you need to set up the PyPI environment and token once:
Step 1: Create PyPI environment
Create a new environment named pypi in the GitHub repository:
- Go to https://github.com/google/ml-metadata/settings/environments/new
- Name it
pypi - Click "Configure environment"
Step 2: Add PYPI_TOKEN secret
Add your PyPI token to the pypi environment:
- In the
pypienvironment settings, scroll to "Environment secrets" - Click "Add secret"
- Name:
PYPI_TOKEN(use this exact name) - Value: Your PyPI API token
- Click "Add secret"
Step 3: Commit and push your release branch
Ensure your release branch has the correct version set in ml_metadata/version.py, then:
git add ml_metadata/version.py
git commit -m "Prepare release vX.Y.Z"
git push origin your-release-branchThis method allows you to manually trigger a release from any branch without creating a GitHub release.
Steps (after completing setup above):
- Navigate to the GitHub Actions page: https://github.com/google/ml-metadata/actions
- Find and select the
Build ml-metadata with Condaworkflow: https://github.com/google/ml-metadata/actions/workflows/conda-build.yml - Click the "Run workflow" dropdown button.
- Select your release branch from the dropdown menu.
- Click "Run workflow".
The workflow will build wheels for all supported Python versions and automatically upload them to PyPI if the token is configured correctly.
This method creates a formal GitHub release with a tag, which automatically triggers the build and upload workflow.
Steps (after completing setup above):
- Go to the Releases tab: https://github.com/google/ml-metadata/releases
- Click the
Draft new releasebutton (you'll be redirected to https://github.com/google/ml-metadata/releases/new) - Click the
Select tagbutton and create a new tag for your release (e.g.,v1.18.0) - Click the
Targetdropdown and select your release branch - Fill in the Release title and Release notes sections
- Choose the release type:
- Check
Set as a pre-releaseif this is a beta/test release - Leave unchecked for
Set as the latest releasefor stable releases
- Check
- Click the
Publish releasebutton - Verify the workflow is running by going to the Actions tab: https://github.com/google/ml-metadata/actions/workflows/conda-build.yml
The Build ml-metadata with Conda workflow will automatically trigger and build/upload wheels to PyPI if the token is configured correctly.