Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ build --protocopt=--experimental_allow_proto3_optional
# parameter 'user_link_flags' is deprecated and will be removed soon.
# It may be temporarily re-enabled by setting --incompatible_require_linker_input_cc_api=false
build --incompatible_require_linker_input_cc_api=false

build:macos --apple_platform_type=macos
build:macos_arm64 --cpu=darwin_arm64
97 changes: 97 additions & 0 deletions .github/workflows/conda-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build ml-metadata with Conda

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}

- name: Display environment info
shell: bash -l {0}
run: |
micromamba info
micromamba list

- name: Install Bazel
shell: bash -l {0}
run: |
# Install Bazelisk (manages Bazel versions)
if [ "$RUNNER_OS" == "Linux" ]; then
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64
elif [ "$RUNNER_OS" == "macOS" ]; then
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64
fi
chmod +x /tmp/bazelisk
sudo mv /tmp/bazelisk /usr/local/bin/bazel
echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV
bazel --version

- name: Build the package
shell: bash -l {0}
run: |
python setup.py bdist_wheel

- name: Repair wheel (Linux)
if: runner.os == 'Linux'
shell: bash -l {0}
run: |
WHEEL_PATH="$(ls dist/*.whl)"
WHEEL_DIR=$(dirname "${WHEEL_PATH}")
auditwheel repair --plat manylinux2014_x86_64 -w "${WHEEL_DIR}" "${WHEEL_PATH}"
rm "${WHEEL_PATH}"

- name: Upload wheel artifact
uses: actions/upload-artifact@v4.4.0
with:
name: ml-metadata-wheel-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/*.whl

upload_to_pypi:
name: Upload to PyPI
runs-on: ubuntu-latest
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/ml-metadata/
permissions:
id-token: write
steps:
- name: Retrieve wheels
uses: actions/download-artifact@v4.1.8
with:
merge-multiple: true
path: wheels

- name: List the build artifacts
run: |
ls -lAs wheels/

- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
with:
packages_dir: wheels/
69 changes: 69 additions & 0 deletions .github/workflows/conda-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Test ml-metadata with Conda

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ci/environment.yml
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}

- name: Display environment info
shell: bash -l {0}
run: |
micromamba info
micromamba list

- name: Install Bazel
shell: bash -l {0}
run: |
# Install Bazelisk (manages Bazel versions)
if [ "$RUNNER_OS" == "Linux" ]; then
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64
elif [ "$RUNNER_OS" == "macOS" ]; then
curl -Lo /tmp/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-darwin-amd64
fi
chmod +x /tmp/bazelisk
sudo mv /tmp/bazelisk /usr/local/bin/bazel
echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV
bazel --version

- name: Build the package
shell: bash -l {0}
run: |
python setup.py bdist_wheel

- name: Install built wheel (Linux/macOS)
shell: bash -l {0}
run: |
pip install dist/*.whl

- name: Run tests
shell: bash -l {0}
run: |
# cleanup (interferes with tests)
rm -rf bazel-*
# run tests
pytest -vv
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@ ml_metadata_workspace()

# Specify the minimum required bazel version.
load("@bazel_skylib//lib:versions.bzl", "versions")
versions.check("6.1.0")
versions.check("6.5.0")
22 changes: 22 additions & 0 deletions ci/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Conda environment for building and testing ml-metadata on Linux
name: mlmd-dev
channels:
- conda-forge
dependencies:
# Note: Bazel is installed separately via official installer (conda package is unreliable)
- setuptools
- wheel
- pip
- numpy
- pytest
- pytest-cov
- patchelf # For wheel repair on Linux
- cmake=3.29

# C/C++ compilers - GCC 8.x to match manylinux2014 devtoolset-8
- gcc_linux-64=8.5.0
- gxx_linux-64=8.5.0
- sysroot_linux-64=2.17 # CentOS 7/manylinux2014 compatible glibc headers

- pip:
- auditwheel # For manylinux wheel compliance
2 changes: 1 addition & 1 deletion ml_metadata/.bazelversion
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
6.1.0
6.5.0
2 changes: 1 addition & 1 deletion ml_metadata/tools/docker_build/Dockerfile.manylinux2010
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# Dockerfile for building a manylinux2010 MLMD wheel.

# This docker image is essentially pypa/manylinux2010 + bazel.
FROM gcr.io/tfx-oss-public/manylinux2014-bazel:bazel-6.1.0
FROM gcr.io/tfx-oss-public/manylinux2014-bazel:bazel-6.5.0
WORKDIR /build
CMD ["ml_metadata/tools/docker_build/build_manylinux.sh"]
2 changes: 1 addition & 1 deletion ml_metadata/tools/docker_build/build_manylinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
WORKING_DIR=$PWD

function setup_environment() {
source scl_source enable devtoolset-8
source scl_source enable devtoolset-10
source scl_source enable rh-python38
if [[ -z "${PYTHON_VERSION}" ]]; then
echo "Must set PYTHON_VERSION env to 39|310|311|"; exit 1;
Expand Down