From 1bb9d09b5f8beb4a227149fd00c720a84adcb465 Mon Sep 17 00:00:00 2001 From: SeqIO Team Date: Thu, 26 Sep 2024 02:19:47 -0700 Subject: [PATCH] Make error message a bit more helpful and actionable. PiperOrigin-RevId: 679057319 --- seqio/feature_converters.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/seqio/feature_converters.py b/seqio/feature_converters.py index 3e64be16..c94600e0 100644 --- a/seqio/feature_converters.py +++ b/seqio/feature_converters.py @@ -346,8 +346,9 @@ def _validate_dataset( for feat in expected_features: if feat not in element_spec: raise ValueError( - "Dataset is missing an expected feature during " - f"{error_label} validation: '{feat}'" + "Dataset is missing an expected feature during" + f" {error_label} validation: '{feat}'. Received {element_spec}," + f" expected {expected_features}." ) if expected_features[feat].dtype != element_spec[feat].dtype: @@ -759,7 +760,7 @@ def _convert_features( """ def convert_example( - features: Mapping[str, tf.Tensor] + features: Mapping[str, tf.Tensor], ) -> Mapping[str, tf.Tensor]: # targets_segment_id is present only for a packed dataset. decoder_input_tokens = utils.make_autoregressive_inputs( @@ -1540,7 +1541,7 @@ def _convert_features( @utils.map_over_dataset def convert_example( - features: Mapping[str, tf.Tensor] + features: Mapping[str, tf.Tensor], ) -> Mapping[str, tf.Tensor]: inputs = features["inputs"] d = {