Skip to content

Commit

Permalink
[TF-DF] [YDF] Remove old Tensorflow Status compatibility
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 689818683
  • Loading branch information
rstz authored and copybara-github committed Oct 25, 2024
1 parent 932a4a3 commit 41a8f56
Show file tree
Hide file tree
Showing 16 changed files with 405 additions and 383 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## HEAD

### Fix

- Some errors are now InvalidArgumentError instead of UnknownError.

## 1.10.0 - 2024-08-21

### Fix
Expand Down
1 change: 0 additions & 1 deletion tensorflow_decision_forests/keras/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ py_test(
"@pypi_pandas//:pkg",
"@pypi_portpicker//:pkg",
"@release_or_nightly//:tensorflow_pkg",
"@release_or_nightly//:tf_keras_pkg",
# TensorFlow /distribute:distribute_lib,
"//tensorflow_decision_forests",
"@ydf//yggdrasil_decision_forests/learner/distributed_gradient_boosted_trees:dgbt_py_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def test_in_memory_not_supported(self):
model = tfdf.keras.DistributedGradientBoostedTreesModel(worker_logs=False)

with self.assertRaisesRegex(
tf.errors.UnknownError,
tf.errors.InvalidArgumentError,
"does not support training from in-memory datasets",
):
model.fit(dataset)
Expand Down
7 changes: 4 additions & 3 deletions tensorflow_decision_forests/keras/keras_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,8 @@ def test_node_format_blob_sequence(self):

def test_check_parameters(self):
with self.assertRaisesRegex(
ValueError, 'The parameter "num_trees" is smaller than the minimum'
tf.errors.InvalidArgumentError,
'The parameter "num_trees" is smaller than the minimum',
):
keras.RandomForestModel(num_trees=-10)

Expand Down Expand Up @@ -3041,7 +3042,7 @@ def test_monotonic_non_compatible_learner(self):
pd_dataset = pd.DataFrame({"f": [0, 1], "l": [0, 1]})
tf_dataset = keras.pd_dataframe_to_tf_dataset(pd_dataset, label="l")
with self.assertRaisesRegex(
tf.errors.UnknownError,
tf.errors.InvalidArgumentError,
"The learner CART does not support monotonic constraints",
):
model.fit(tf_dataset)
Expand All @@ -3053,7 +3054,7 @@ def test_monotonic_non_compatible_options(self):
pd_dataset = pd.DataFrame({"f": [0, 1], "l": [0, 1]})
tf_dataset = keras.pd_dataframe_to_tf_dataset(pd_dataset, label="l")
with self.assertRaisesRegex(
tf.errors.UnknownError,
tf.errors.InvalidArgumentError,
"Gradient Boosted Trees does not support monotonic constraints with"
" use_hessian_gain=false",
):
Expand Down
7 changes: 5 additions & 2 deletions tensorflow_decision_forests/tensorflow/ops/inference/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ cc_library(
name = "op",
srcs = OP_SRCS,
linkstatic = 1,
deps = OP_DEPS,
deps = OP_DEPS + [
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@ydf//yggdrasil_decision_forests/utils:status_macros",
],
alwayslink = 1,
)

Expand All @@ -133,7 +137,6 @@ cc_library(
"@ydf//yggdrasil_decision_forests/utils:compatibility",
"@ydf//yggdrasil_decision_forests/utils:distribution_cc_proto",
"@ydf//yggdrasil_decision_forests/utils:status_macros",
"@ydf//yggdrasil_decision_forests/utils:tensorflow",
] + select({
"@ydf//yggdrasil_decision_forests:tensorflow_with_header_lib": [
"@release_or_nightly//:tensorflow_libtensorflow_framework",
Expand Down
Loading

0 comments on commit 41a8f56

Please sign in to comment.