[meta-tensorflow] tensorflow: fix logger issue on python 3.8

Submitted by Qi.Chen@windriver.com on Feb. 21, 2020, 7:50 a.m. | Patch ID: 170341

Details

Message ID 20200221075015.27270-1-Qi.Chen@windriver.com
State New
Headers show

Commit Message

Qi.Chen@windriver.com Feb. 21, 2020, 7:50 a.m.
We met the following error with python 3.8.

  TypeError: _logger_find_caller() takes from 0 to 1 positional arguments but 2 were given

Backport a patch to fix this issue.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 ...ensorFlow-on-Python-3.8-logger-issue.patch | 55 +++++++++++++++++++
 .../tensorflow/tensorflow-native_1.13.0.bb    |  1 +
 .../tensorflow/tensorflow_1.13.0.bb           |  1 +
 3 files changed, 57 insertions(+)
 create mode 100644 recipes-framework/tensorflow/files/0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch

Patch hide | download patch | download mbox

diff --git a/recipes-framework/tensorflow/files/0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch b/recipes-framework/tensorflow/files/0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch
new file mode 100644
index 0000000..714cfed
--- /dev/null
+++ b/recipes-framework/tensorflow/files/0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch
@@ -0,0 +1,55 @@ 
+From db8840ea06bee6c8384d88edba2faa027ed74c02 Mon Sep 17 00:00:00 2001
+From: Yong Tang <yong.tang.github@outlook.com>
+Date: Sun, 3 Nov 2019 19:52:04 +0000
+Subject: [PATCH] Fix TensorFlow on Python 3.8 logger issue
+
+This fix tries to address the issue raised in 33799
+where running tensorflow on python 3.8 (Ubuntu 18.04)
+raised the following error:
+```
+TypeError: _logger_find_caller() takes from 0 to 1 positional arguments but 2 were given
+```
+
+The issue was that findCaller changed in Python 3.8
+
+This PR fixes the issue.
+
+This PR fixes 33799
+
+Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
+
+Upstream-Status: Backport [https://github.com/tensorflow/tensorflow/pull/33953/commits/ea3063c929c69f738bf65bc99dad1159803e772f]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ tensorflow/python/platform/tf_logging.py | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/tensorflow/python/platform/tf_logging.py b/tensorflow/python/platform/tf_logging.py
+index 813bcb89be..4862e70e4d 100644
+--- a/tensorflow/python/platform/tf_logging.py
++++ b/tensorflow/python/platform/tf_logging.py
+@@ -57,9 +57,18 @@ def _get_caller(offset=3):
+     f = f.f_back
+   return None, None
+ 
+-
+ # The definition of `findCaller` changed in Python 3.2
+-if _sys.version_info.major >= 3 and _sys.version_info.minor >= 2:
++if _sys.version_info.major >= 3 and _sys.version_info.minor >= 8:
++  def _logger_find_caller(stack_info=False, stacklevel=1):  # pylint: disable=g-wrong-blank-lines
++    code, frame = _get_caller(4)
++    sinfo = None
++    if stack_info:
++      sinfo = '\n'.join(_traceback.format_stack())
++    if code:
++      return (code.co_filename, frame.f_lineno, code.co_name, sinfo)
++    else:
++      return '(unknown file)', 0, '(unknown function)', sinfo
++elif _sys.version_info.major >= 3 and _sys.version_info.minor >= 2:
+   def _logger_find_caller(stack_info=False):  # pylint: disable=g-wrong-blank-lines
+     code, frame = _get_caller(4)
+     sinfo = None
+-- 
+2.17.1
+
diff --git a/recipes-framework/tensorflow/tensorflow-native_1.13.0.bb b/recipes-framework/tensorflow/tensorflow-native_1.13.0.bb
index 48635a5..4aa76ba 100644
--- a/recipes-framework/tensorflow/tensorflow-native_1.13.0.bb
+++ b/recipes-framework/tensorflow/tensorflow-native_1.13.0.bb
@@ -9,6 +9,7 @@  SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r1.13 \
            file://0001-use-local-bazel-to-workaround-bazel-paralle-issue.patch \
            file://0001-grpc-Define-gettid-only-for-glibc-2.30.patch \
            file://0001-fix-compilation-error.patch \
+           file://0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch \
           "
 S = "${WORKDIR}/git"
 
diff --git a/recipes-framework/tensorflow/tensorflow_1.13.0.bb b/recipes-framework/tensorflow/tensorflow_1.13.0.bb
index e541895..7502f34 100644
--- a/recipes-framework/tensorflow/tensorflow_1.13.0.bb
+++ b/recipes-framework/tensorflow/tensorflow_1.13.0.bb
@@ -20,6 +20,7 @@  SRC_URI = "git://github.com/tensorflow/tensorflow.git;branch=r1.13 \
            file://CROSSTOOL.tpl \
            file://yocto_compiler_configure.bzl \
            file://0001-fix-compilation-error.patch \
+           file://0001-Fix-TensorFlow-on-Python-3.8-logger-issue.patch \
           "
 
 S = "${WORKDIR}/git"