in src/dfcx_scrapi/tools/datastore_scraper.py [0:0]
def validate_queryset(self, queryset: pd.DataFrame) -> None:
"Validates the queryset and raises exception in case of invalid input."
# validate input schema
try:
queryset[INPUT_SCHEMA_REQUIRED_COLUMNS]
except KeyError as err:
raise UserWarning(
"Ensure your input data contains the following columns:"
f" {INPUT_SCHEMA_REQUIRED_COLUMNS}"
) from err
# validate if conversationd_id and turn_id is unique identifier
if not (
queryset["conversation_id"].astype(str)
+ "_"
+ queryset["turn_index"].astype(str)
).is_unique:
raise UserWarning(
"Ensure that 'conversation_id' and 'turn_index' are unique "
"identifiers"
)
# validate turn_index
try:
queryset["turn_index"].astype(int)
except ValueError as err:
raise UserWarning(
"Ensure that 'turn_index' is set as integer"
) from err
if not queryset["turn_index"].astype(int).gt(0).all():
raise UserWarning("Ensure that 'turn_index' is in [1, inf)")