mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Bump tensorflow to 2.16.* (#11696)
This commit is contained in:
@@ -7,7 +7,7 @@ set -euxo pipefail
|
||||
|
||||
# Whenever you update TENSORFLOW_VERSION here, version should be updated
|
||||
# in stubs/tensorflow/METADATA.toml and vice-versa.
|
||||
TENSORFLOW_VERSION=2.12.1
|
||||
TENSORFLOW_VERSION=2.16.1
|
||||
MYPY_PROTOBUF_VERSION=3.6.0
|
||||
|
||||
# brew install coreutils wget
|
||||
@@ -30,6 +30,9 @@ python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
python3 -m pip install grpcio-tools pre-commit mypy-protobuf=="$MYPY_PROTOBUF_VERSION"
|
||||
|
||||
# Empty target folders or the mv command below will fail
|
||||
rm -rf "$REPO_ROOT/stubs/tensorflow/tensorflow/tsl/"
|
||||
rm -rf "$REPO_ROOT/stubs/tensorflow/tensorflow/compiler/xla/"
|
||||
# Remove existing pyi
|
||||
find "$REPO_ROOT/stubs/tensorflow/" -name "*_pb2.pyi" -delete
|
||||
|
||||
@@ -38,32 +41,42 @@ find "$REPO_ROOT/stubs/tensorflow/" -name "*_pb2.pyi" -delete
|
||||
PROTOC_VERSION=$(python3 -m grpc_tools.protoc --version)
|
||||
echo $PROTOC_VERSION
|
||||
python3 -m grpc_tools.protoc \
|
||||
--proto_path="$TENSORFLOW_DIR/third_party/xla/third_party/tsl" \
|
||||
--proto_path="$TENSORFLOW_DIR/third_party/xla" \
|
||||
--proto_path="$TENSORFLOW_DIR" \
|
||||
--mypy_out "relax_strict_optional_primitives:$REPO_ROOT/stubs/tensorflow" \
|
||||
$TENSORFLOW_DIR/tensorflow/compiler/xla/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/compiler/xla/service/*.proto \
|
||||
$TENSORFLOW_DIR/third_party/xla/xla/*.proto \
|
||||
$TENSORFLOW_DIR/third_party/xla/xla/service/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/core/example/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/core/framework/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/core/protobuf/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/core/protobuf/tpu/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/core/util/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/python/keras/protobuf/*.proto \
|
||||
$TENSORFLOW_DIR/tensorflow/tsl/protobuf/*.proto \
|
||||
$TENSORFLOW_DIR/third_party/xla/third_party/tsl/tsl/protobuf/*.proto \
|
||||
|
||||
# Cleanup after ourselves, this is a temp dir, but it can still grow fast if run multiple times
|
||||
rm -rf "$TMP_DIR"
|
||||
|
||||
# Must be in a git repository to run pre-commit
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
# These protos exist in a folder with protos used in python, but are not
|
||||
# included in the python wheel. They are likely only used for other
|
||||
# language builds. stubtest was used to identify them by looking for
|
||||
# ModuleNotFoundError.
|
||||
rm \
|
||||
# Move third-party and fix imports
|
||||
mv stubs/tensorflow/tsl/ stubs/tensorflow/tensorflow/
|
||||
find stubs/tensorflow/ -name '*_pb2.pyi' | xargs sed --in-place="" -r "s/(\[|\s)tsl\./\1tensorflow\.tsl\./"
|
||||
mv stubs/tensorflow/xla/ stubs/tensorflow/tensorflow/compiler/
|
||||
find stubs/tensorflow/ -name '*_pb2.pyi' | xargs sed --in-place="" -r "s/(\[|\s)xla\./\1tensorflow\.compiler\.xla\./"
|
||||
|
||||
# These protos exist in a folder with protos used in python,
|
||||
# but are not included in the python wheel.
|
||||
# They are likely only used for other language builds.
|
||||
# stubtest was used to identify them by looking for ModuleNotFoundError.
|
||||
# (comment out ".*_pb2.*" from the allowlist)
|
||||
rm -r \
|
||||
stubs/tensorflow/tensorflow/compiler/xla/autotune_results_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/compiler/xla/autotuning_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/compiler/xla/service/buffer_assignment_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/compiler/xla/service/hlo_execution_profile_data_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/compiler/xla/service/hlo_profile_printer_data_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/compiler/xla/service/test_compilation_environment_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/compiler/xla/xla_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/core/protobuf/autotuning_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/core/protobuf/conv_autotuning_pb2.pyi \
|
||||
stubs/tensorflow/tensorflow/core/protobuf/critical_section_pb2.pyi \
|
||||
@@ -80,7 +93,7 @@ sed --in-place="" \
|
||||
"s/extra_description = .*$/extra_description = \"\
|
||||
Partially generated using [mypy-protobuf==$MYPY_PROTOBUF_VERSION](https:\/\/github.com\/nipunn1313\/mypy-protobuf\/tree\/v$MYPY_PROTOBUF_VERSION) \
|
||||
and $PROTOC_VERSION \
|
||||
on tensorflow==$TENSORFLOW_VERSION.\"/" \
|
||||
on tensorflow==$TENSORFLOW_VERSION .\"/" \
|
||||
stubs/tensorflow/METADATA.toml
|
||||
|
||||
# use `|| true` so the script still continues even if a pre-commit hook
|
||||
|
||||
Reference in New Issue
Block a user