mirror of
https://github.com/zebrajr/tensorflow.git
synced 2026-01-15 12:15:41 +00:00
Fix Python 3.13 wheel test and requirements
PiperOrigin-RevId: 772980569
This commit is contained in:
committed by
TensorFlower Gardener
parent
d0921d0023
commit
95de5353e5
@@ -4,9 +4,9 @@
|
||||
#
|
||||
# bazel run //ci/official/requirements_updater:requirements.update
|
||||
#
|
||||
absl-py==2.2.1 \
|
||||
--hash=sha256:4c7bc50d42d021c12d4f31b7001167925e0bd71ade853069f64af410f5565ff9 \
|
||||
--hash=sha256:ca8209abd5005ae6e700ef36e2edc84ad5338678f95625a3f15275410a89ffbc
|
||||
absl-py==2.3.0 \
|
||||
--hash=sha256:d96fda5c884f1b22178852f30ffa85766d50b99e00775ea626c23304f582fc4f \
|
||||
--hash=sha256:9824a48b654a306168f63e0d97714665f8490b8d89ec7bf2efc24bf67cf579b3
|
||||
# via
|
||||
# dm-tree
|
||||
# keras-nightly
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"""Tests for parser module."""
|
||||
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import gast
|
||||
@@ -292,7 +293,11 @@ string""")
|
||||
"""
|
||||
|
||||
f = self._eval_code(parser.dedent_block(code), 'f')
|
||||
self.assertEqual(f.__doc__, '\n Docstring.\n ')
|
||||
if sys.version_info >= (3, 13):
|
||||
self.assertEqual(f.__doc__.strip(), 'Docstring.')
|
||||
else:
|
||||
self.assertEqual(f.__doc__, '\n Docstring.\n ')
|
||||
|
||||
self.assertEqual(f(), '\n 1\n 2\n 3')
|
||||
|
||||
def test_dedent_block_multiline_expression(self):
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import functools
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -1373,15 +1374,21 @@ def parent_frame_arguments():
|
||||
|
||||
# Remove the *varargs, and flatten the **kwargs. Both are
|
||||
# nested lists.
|
||||
local_vars.pop(variable_arg_name, {})
|
||||
keyword_args = local_vars.pop(keyword_arg_name, {})
|
||||
if sys.version_info >= (3, 13):
|
||||
keyword_args = local_vars.get(keyword_arg_name, {})
|
||||
else:
|
||||
local_vars.pop(variable_arg_name, {})
|
||||
keyword_args = local_vars.pop(keyword_arg_name, {})
|
||||
|
||||
final_args = {}
|
||||
# Copy over arguments and their values. In general, local_vars
|
||||
# may contain more than just the arguments, since this method
|
||||
# can be called anywhere in a function.
|
||||
for arg_name in arg_names:
|
||||
final_args[arg_name] = local_vars.pop(arg_name)
|
||||
if sys.version_info >= (3, 13):
|
||||
final_args[arg_name] = local_vars[arg_name]
|
||||
else:
|
||||
final_args[arg_name] = local_vars.pop(arg_name)
|
||||
final_args.update(keyword_args)
|
||||
|
||||
return final_args
|
||||
|
||||
@@ -1155,27 +1155,31 @@ def update_docstrings_with_api_lists():
|
||||
`dispatch_for_binary_elementwise_apis`, by replacing the string '<<API_LIST>>'
|
||||
with a list of APIs that have been registered for that decorator.
|
||||
"""
|
||||
_update_docstring_with_api_list(dispatch_for_unary_elementwise_apis,
|
||||
_UNARY_ELEMENTWISE_APIS)
|
||||
_update_docstring_with_api_list(dispatch_for_binary_elementwise_apis,
|
||||
_BINARY_ELEMENTWISE_APIS)
|
||||
_update_docstring_with_api_list(dispatch_for_binary_elementwise_assert_apis,
|
||||
_BINARY_ELEMENTWISE_ASSERT_APIS)
|
||||
_update_docstring_with_api_list(dispatch_for_api,
|
||||
_TYPE_BASED_DISPATCH_SIGNATURES)
|
||||
_update_docstring_with_api_list(
|
||||
dispatch_for_unary_elementwise_apis, _UNARY_ELEMENTWISE_APIS)
|
||||
_update_docstring_with_api_list(
|
||||
dispatch_for_binary_elementwise_apis, _BINARY_ELEMENTWISE_APIS)
|
||||
_update_docstring_with_api_list(
|
||||
dispatch_for_binary_elementwise_assert_apis,
|
||||
_BINARY_ELEMENTWISE_ASSERT_APIS)
|
||||
_update_docstring_with_api_list(
|
||||
dispatch_for_api, _TYPE_BASED_DISPATCH_SIGNATURES)
|
||||
|
||||
|
||||
def _update_docstring_with_api_list(target, api_list):
|
||||
"""Replaces `<<API_LIST>>` in target.__doc__ with the given list of APIs."""
|
||||
lines = []
|
||||
for func in api_list:
|
||||
if isinstance(func, dict):
|
||||
func = list(func.keys())[0]
|
||||
name = tf_export_lib.get_canonical_name_for_symbol(
|
||||
func, add_prefix_to_v1_names=True)
|
||||
func, add_prefix_to_v1_names=True
|
||||
)
|
||||
if name is not None:
|
||||
params = tf_inspect.signature(func).parameters.keys()
|
||||
lines.append(f" * `tf.{name}({', '.join(params)})`")
|
||||
lines.sort()
|
||||
target.__doc__ = target.__doc__.replace(" <<API_LIST>>", "\n".join(lines))
|
||||
target.__doc__ = target.__doc__.replace("<<API_LIST>>", "\n".join(lines))
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
@@ -1143,21 +1143,22 @@ class DispatchV2Test(test_util.TensorFlowTestCase):
|
||||
dispatch.update_docstrings_with_api_lists()
|
||||
self.assertRegex(
|
||||
dispatch.dispatch_for_api.__doc__,
|
||||
r"(?s) The TensorFlow APIs that may be overridden "
|
||||
r"by `@dispatch_for_api` are:\n\n.*"
|
||||
r" \* `tf\.concat\(values, axis, name\)`\n.*"
|
||||
r" \* `tf\.math\.add\(x, y, name\)`\n.*")
|
||||
r"(?s)The TensorFlow APIs that may be overridden "
|
||||
r"by `@dispatch_for_api` are:.*"
|
||||
r"\* `tf\.concat\(values, axis, name\)`.*"
|
||||
r"\* `tf\.math\.add\(x, y, name\)`.*")
|
||||
self.assertRegex(
|
||||
dispatch.dispatch_for_unary_elementwise_apis.__doc__,
|
||||
r"(?s) The unary elementwise APIs are:\n\n.*"
|
||||
r" \* `tf\.math\.abs\(x, name\)`\n.*"
|
||||
r" \* `tf\.math\.cos\(x, name\)`\n.*")
|
||||
r"(?s)The unary elementwise APIs are:.*"
|
||||
r"\* `tf\.math\.abs\(x, name\)`.*"
|
||||
r"\* `tf\.math\.cos\(x, name\)`.*")
|
||||
self.assertRegex(
|
||||
dispatch.dispatch_for_binary_elementwise_apis.__doc__,
|
||||
r"(?s) The binary elementwise APIs are:\n\n.*"
|
||||
r" \* `tf\.math\.add\(x, y, name\)`\n.*"
|
||||
r" \* `tf\.math\.multiply\(x, y, name\)`\n.*")
|
||||
r"(?s)The binary elementwise APIs are:.*"
|
||||
r"\* `tf\.math\.add\(x, y, name\)`.*"
|
||||
r"\* `tf\.math\.multiply\(x, y, name\)`.*")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
googletest.main()
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# ==============================================================================
|
||||
"""Tests for traceback_utils."""
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
from tensorflow.python.eager import def_function
|
||||
@@ -46,7 +47,10 @@ class TracebackUtilsTest(test.TestCase):
|
||||
self.assertGreater(trace_line_count, 0)
|
||||
|
||||
if filtering_enabled:
|
||||
self.assertLess(trace_line_count, count)
|
||||
if sys.version_info >= (3, 13):
|
||||
self.assertLessEqual(trace_line_count, count)
|
||||
else:
|
||||
self.assertLess(trace_line_count, count)
|
||||
else:
|
||||
self.assertGreater(trace_line_count, count)
|
||||
|
||||
@@ -96,7 +100,10 @@ class TracebackUtilsTest(test.TestCase):
|
||||
def fn():
|
||||
wrapped_fn([0, 1])
|
||||
|
||||
self.assert_trace_line_count(fn, count=15, filtering_enabled=True)
|
||||
if sys.version_info >= (3, 13):
|
||||
self.assert_trace_line_count(fn, count=16, filtering_enabled=True)
|
||||
else:
|
||||
self.assert_trace_line_count(fn, count=15, filtering_enabled=True)
|
||||
self.assert_trace_line_count(fn, count=25, filtering_enabled=False)
|
||||
|
||||
def test_variable_constructor(self):
|
||||
|
||||
Reference in New Issue
Block a user