Skip to content

Commit 1260fdf

Browse files
gustavocidornelaswhoseoyster
authored andcommitted
Allow None values in token column
1 parent 627a8a8 commit 1260fdf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

openlayer/validators/dataset_validators.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,16 @@ def _validate_latencies(self):
330330
"is one of int32, int64, float32, or float64."
331331
)
332332

333-
def _values_are_numbers(self, dataset_df: pd.DataFrame, column_name: str) -> bool:
333+
def _values_are_numbers(
334+
self, dataset_df: pd.DataFrame, column_name: str, allow_none: bool = False
335+
) -> bool:
334336
"""Checks whether the values in the column are numbers (ints or floats)."""
335337
if dataset_df[column_name].dtype.name in (
336338
"int64",
337339
"int32",
338340
"float32",
339341
"float64",
340-
):
342+
) or (allow_none and dataset_df[column_name].dtype.name == "object"):
341343
return True
342344
return False
343345

@@ -829,7 +831,7 @@ def _validate_num_of_token(self):
829831
"specified as `numOfTokenColumnName` is not in the dataset."
830832
)
831833
elif not self._values_are_numbers(
832-
self.dataset_df, self.num_of_token_column_name
834+
self.dataset_df, self.num_of_token_column_name, allow_none=True
833835
):
834836
self.failed_validations.append(
835837
f"The number of tokens in the column `{self.num_of_token_column_name}`"

0 commit comments

Comments
 (0)