Skip to content

Commit

Permalink
Make error message a bit more helpful and actionable.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 679231341
  • Loading branch information
SeqIO Team authored and SeqIO committed Sep 26, 2024
1 parent 0d6370a commit bbb5ba3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions seqio/feature_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit bbb5ba3

Please sign in to comment.