Skip to content

Commit 1344103

Browse files
achoumcopybara-github
authored andcommitted
Internal change
PiperOrigin-RevId: 408278219
1 parent b9feba2 commit 1344103

File tree

16 files changed

+152
-14
lines changed

16 files changed

+152
-14
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.2.1 - 2021-11-05
4+
5+
### Features
6+
7+
- Compatibility with TensorFlow 2.7.0.
8+
39
## 0.2.0 - 2021-10-29
410

511
### Features

WORKSPACE

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
99
http_archive(
1010
name = "org_tensorflow",
1111

12-
# sha256 = "4896b49c4088030f62b98264441475c09569ea6e49cfb270e2e1f3ef0f743a2f",
13-
# strip_prefix = "tensorflow-2.7.0-rc1",
14-
# urls = ["https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.7.0-rc1.zip"],
15-
16-
sha256 = "40d3203ab5f246d83bae328288a24209a2b85794f1b3e2cd0329458d8e7c1985",
17-
strip_prefix = "tensorflow-2.6.0",
18-
urls = ["https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.6.0.zip"],
12+
sha256 = "249b48ddee927801c7a4f8e5442cf1a3c860f6f46b85a2ff7a78b501507dd561",
13+
strip_prefix = "tensorflow-2.7.0",
14+
urls = ["https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.7.0.zip"],
1915

2016
#urls = ["https://github.com/tensorflow/tensorflow/archive/master.zip"],
2117
#strip_prefix = "tensorflow-master",

configure/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
from setuptools.command.install import install
2121
from setuptools.dist import Distribution
2222

23-
_VERSION = "0.2.0"
23+
_VERSION = "0.2.1"
2424

2525
with open("README.md", "r", encoding="utf-8") as fh:
2626
long_description = fh.read()
2727

2828
REQUIRED_PACKAGES = [
2929
"numpy",
3030
"pandas",
31-
"tensorflow~=2.6", # "tensorflow >= 2.7.0rc0, < 2.8'",
31+
"tensorflow~=2.7.0",
3232
"six",
3333
"absl_py",
3434
"wheel",

documentation/known_issues.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following table shows the compatibility between
4747

4848
tensorflow_decision_forests | tensorflow
4949
--------------------------- | ----------
50+
0.2.1 | 2.7
5051
0.2.0 | 2.6
5152
0.1.9 | 2.6
5253
0.1.1 - 0.1.8 | 2.5

tensorflow_decision_forests/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ py_library(
1616
"//tensorflow_decision_forests/component/model_plotter",
1717
"//tensorflow_decision_forests/component/py_tree",
1818
"//tensorflow_decision_forests/keras",
19+
"//tensorflow_decision_forests/tensorflow:check_version",
1920
],
2021
)
2122

tensorflow_decision_forests/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@
4545
4646
"""
4747

48-
__version__ = "0.2.0"
48+
__version__ = "0.2.1"
4949
__author__ = "Mathieu Guillame-Bert"
5050

51+
compatible_tf_versions = ["2.7.0"]
52+
53+
from tensorflow_decision_forests.tensorflow import check_version
54+
55+
check_version.check_version(__version__, compatible_tf_versions)
56+
5157
from tensorflow_decision_forests import keras
5258
from tensorflow_decision_forests.component import py_tree
5359
from tensorflow_decision_forests.component.builder import builder

tensorflow_decision_forests/tensorflow/BUILD

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ py_library(
8989
}),
9090
)
9191

92+
py_library(
93+
name = "check_version",
94+
srcs = ["check_version.py"],
95+
srcs_version = "PY3",
96+
deps = ["@org_tensorflow//tensorflow/python"],
97+
)
98+
9299
# Tests
93100
# =====
94101

@@ -104,3 +111,13 @@ py_test(
104111
"@ydf//yggdrasil_decision_forests/learner:abstract_learner_py_proto",
105112
],
106113
)
114+
115+
py_test(
116+
name = "check_version_test",
117+
srcs = ["check_version_test.py"],
118+
python_version = "PY3",
119+
deps = [
120+
":check_version",
121+
"@org_tensorflow//tensorflow/python",
122+
],
123+
)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright 2021 Google LLC.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Check that version of TensorFlow is compatible with TF-DF."""
16+
17+
import logging
18+
import tensorflow as tf
19+
20+
21+
def check_version(tf_df_version,
22+
compatible_tf_versions,
23+
tf_version=None,
24+
external_logic=False):
25+
"""Checks the compatibility of the TF version.
26+
27+
Prints a warning message and return False in care of likely incompatible
28+
versions.
29+
"""
30+
31+
if not external_logic:
32+
33+
if tf_version is None:
34+
tf_version = tf.__version__
35+
if tf_version not in compatible_tf_versions:
36+
logging.warning(
37+
"TensorFlow Decision Forests %s is compatible with the following "
38+
"TensorFlow Versions: %s. However, TensorFlow %s was detected. "
39+
"This can cause issues with the TF API and symbols in the custom C++ "
40+
"ops. See the TF and TF-DF compatibility table at "
41+
"https://github.com/tensorflow/decision-forests/blob/main/documentation/known_issues.md#compatibility-table.",
42+
tf_df_version, compatible_tf_versions, tf_version)
43+
return False
44+
return True
45+
46+
47+
def info_fail_to_load_custom_op(exception):
48+
logging.warning("Failure to load the custom c++ tensorflow ops. "
49+
"This error is likely caused the version of TensorFlow and "
50+
"TensorFlow Decision Forests are not compatible.")
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2021 Google LLC.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import tensorflow as tf
16+
17+
from tensorflow_decision_forests.tensorflow import check_version
18+
19+
20+
class CheckVersionTest(tf.test.TestCase):
21+
22+
def test_base(self):
23+
24+
tf_df_version = "1.2.3" # Does not matter.
25+
self.assertTrue(
26+
check_version.check_version(
27+
tf_df_version, ["2.6.0", "2.6.1"], "2.6.0", external_logic=True))
28+
self.assertFalse(
29+
check_version.check_version(
30+
tf_df_version, ["2.6.0", "2.6.1"],
31+
"2.8.0-dev20211105",
32+
external_logic=True))
33+
self.assertFalse(
34+
check_version.check_version(
35+
tf_df_version, ["2.6.0", "2.6.1"], "2.7.0-rc1",
36+
external_logic=True))
37+
38+
39+
if __name__ == "__main__":
40+
tf.test.main()

tensorflow_decision_forests/tensorflow/distribute/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ py_library(
2020
srcs_version = "PY3",
2121
deps = [
2222
"@org_tensorflow//tensorflow:tensorflow_py",
23+
"//tensorflow_decision_forests/tensorflow:check_version",
2324
],
2425
)
2526

0 commit comments

Comments
 (0)