|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2022 Google LLC |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +set -e |
| 17 | +set -x |
| 18 | + |
| 19 | +PYENV_ROOT="/home/kbuilder/.pyenv" |
| 20 | +PYTHON_VERSION=${PYTHON_VERSION:-"3.11"} |
| 21 | + |
| 22 | +function force_tensorflow_version() { |
| 23 | + if [[ -z "${TF_VERSION}" ]]; then |
| 24 | + echo "TF_VERSION is not set. Not forcing tensorflow version." |
| 25 | + return |
| 26 | + fi |
| 27 | + |
| 28 | + pip install tensorflow=="${TF_VERSION}" --progress-bar off --upgrade |
| 29 | + if [[ "$TF_USE_LEGACY_KERAS" == 1 ]]; then |
| 30 | + pip install tf-keras=="${TF_VERSION}" --progress-bar off --upgrade |
| 31 | + fi |
| 32 | +} |
| 33 | + |
| 34 | +echo "Installing pyenv.." |
| 35 | +git clone https://github.com/pyenv/pyenv.git "$PYENV_ROOT" |
| 36 | +export PATH="/home/kbuilder/.local/bin:$PYENV_ROOT/bin:$PATH" |
| 37 | +eval "$(pyenv init --path)" |
| 38 | + |
| 39 | +echo "Python setup..." |
| 40 | +pyenv install -s "$PYTHON_VERSION" |
| 41 | +pyenv global "$PYTHON_VERSION" |
| 42 | + |
| 43 | +cd "${KOKORO_ARTIFACTS_DIR}/github/gnn/" |
| 44 | + |
| 45 | +PIP_TEST_PREFIX=bazel_pip |
| 46 | + |
| 47 | +python -m venv build_venv |
| 48 | +source build_venv/bin/activate |
| 49 | + |
| 50 | +# Debug messages to indicate the python version |
| 51 | +python --version |
| 52 | + |
| 53 | +# update pip |
| 54 | +pip install --upgrade pip |
| 55 | + |
| 56 | +# Install build |
| 57 | +pip install build |
| 58 | + |
| 59 | +TEST_ROOT=$(pwd)/${PIP_TEST_PREFIX} |
| 60 | +rm -rf "$TEST_ROOT" |
| 61 | +mkdir -p "$TEST_ROOT" |
| 62 | +ln -s "$(pwd)"/tensorflow_gnn "$TEST_ROOT"/tensorflow_gnn |
| 63 | + |
| 64 | +# Print the OS version |
| 65 | +cat /etc/os-release |
| 66 | + |
| 67 | +# Prepend common tag filters to a defined env_var |
| 68 | +# For example, tests for TF 2.8 shouldn't run RNG-dependent tests |
| 69 | +# These tag filters are enforced to start with a comma for separation |
| 70 | +tag_filters="-no_oss,-oss_excluded${TAG_FILTERS}" |
| 71 | + |
| 72 | +# Check that `bazel` does version selection as expected. |
| 73 | +if [[ -n "${USE_BAZEL_VERSION}" && $(bazel --version) != *${USE_BAZEL_VERSION}* ]]; then |
| 74 | + echo "Mismatch of configured and actual bazel version (see logged [[ command)" |
| 75 | + exit 1 |
| 76 | +fi |
| 77 | + |
| 78 | +bazel clean |
| 79 | +force_tensorflow_version |
| 80 | +python3 -m build --wheel |
| 81 | +deactivate |
| 82 | + |
| 83 | +# Start the test environment. |
| 84 | +python3 -m venv test_venv |
| 85 | +source test_venv/bin/activate |
| 86 | + |
| 87 | +# Check the python version |
| 88 | +python --version |
| 89 | + |
| 90 | +# update pip |
| 91 | +pip install --upgrade pip |
| 92 | +force_tensorflow_version |
| 93 | + |
| 94 | +if [[ "$TF_USE_LEGACY_KERAS" == 1 ]]; then |
| 95 | + pip install --group test-tf216plus --progress-bar off --upgrade |
| 96 | +else |
| 97 | + pip install --group test-pre-tf216 --progress-bar off --upgrade |
| 98 | +fi |
| 99 | + |
| 100 | +pip install dist/tensorflow_gnn-*.whl |
| 101 | + |
| 102 | +echo "Final packages after all pip commands:" |
| 103 | +pip list |
| 104 | + |
| 105 | +bazel test --test_env=TF_USE_LEGACY_KERAS --build_tag_filters="${tag_filters}" --test_tag_filters="${tag_filters}" --test_output=errors --verbose_failures=true --build_tests_only --define=no_tfgnn_py_deps=true --keep_going --experimental_repo_remote_exec //bazel_pip/tensorflow_gnn/... |
0 commit comments