Skip to content

Rapidata validation set

RapidataValidationSet #

RapidataValidationSet(
    validation_set_id,
    name: str,
    openapi_service: OpenAPIService,
)

A class for interacting with a Rapidata validation set.

Represents a set of all the validation tasks that can be added to an order.

When added to an order, the tasks will be selected randomly from the set.

Attributes:

Name Type Description
id str

The ID of the validation set.

name str

The name of the validation set.

Source code in src/rapidata/rapidata_client/validation/rapidata_validation_set.py
def __init__(self, validation_set_id, name: str, openapi_service: OpenAPIService):
    self.id = validation_set_id
    self.name = name
    self.validation_set_details_page = (
        f"https://app.{openapi_service.environment}/validation-set/detail/{self.id}"
    )
    self.__openapi_service = openapi_service

add_rapid #

add_rapid(rapid: Rapid)

Add a Rapid to the validation set.

Parameters:

Name Type Description Default
rapid Rapid

The Rapid to add to the validation set.

required
Source code in src/rapidata/rapidata_client/validation/rapidata_validation_set.py
def add_rapid(self, rapid: Rapid):
    """Add a Rapid to the validation set.

    Args:
        rapid (Rapid): The Rapid to add to the validation set.
    """
    with tracer.start_as_current_span("RapidataValidationSet.add_rapid"):
        logger.debug("Adding rapid %s to validation set %s", rapid, self.id)
        rapid._add_to_validation_set(self.id, self.__openapi_service)
    return self

update_dimensions #

update_dimensions(dimensions: list[str])

Update the dimensions of the validation set.

Parameters:

Name Type Description Default
dimensions list[str]

The new dimensions of the validation set.

required
Source code in src/rapidata/rapidata_client/validation/rapidata_validation_set.py
def update_dimensions(self, dimensions: list[str]):
    """Update the dimensions of the validation set.

    Args:
        dimensions (list[str]): The new dimensions of the validation set.
    """
    with tracer.start_as_current_span("RapidataValidationSet.update_dimensions"):
        logger.debug(
            "Updating dimensions for validation set %s to %s", self.id, dimensions
        )
        self.__openapi_service.validation_api.validation_set_validation_set_id_patch(
            self.id, UpdateValidationSetModel(dimensions=dimensions)
        )
        return self

update_should_alert #

update_should_alert(should_alert: bool)

Determines whether users should be alerted if they answer incorrectly.

Parameters:

Name Type Description Default
should_alert bool

Specifies whether users should be alerted for incorrect answers. Defaults to True if not specifically overridden by this method.

required
Note

The userScore dimensions which are updated when a user answers a validation task are updated regardless of the value of should_alert.

Source code in src/rapidata/rapidata_client/validation/rapidata_validation_set.py
def update_should_alert(self, should_alert: bool):
    """Determines whether users should be alerted if they answer incorrectly.

    Args:
        should_alert (bool): Specifies whether users should be alerted for incorrect answers. Defaults to True if not specifically overridden by this method.

    Note:
        The userScore dimensions which are updated when a user answers a validation task are updated regardless of the value of `should_alert`.
    """
    with tracer.start_as_current_span("RapidataValidationSet.update_should_alert"):
        logger.debug(
            "Setting shouldAlert for validation set %s to %s", self.id, should_alert
        )
        self.__openapi_service.validation_api.validation_set_validation_set_id_patch(
            self.id, UpdateValidationSetModel(shouldAlert=should_alert)
        )
        return self

view #

view() -> None

Opens the validation set details page in the browser.

Raises:

Type Description
Exception

If the order is not in processing state.

Source code in src/rapidata/rapidata_client/validation/rapidata_validation_set.py
def view(self) -> None:
    """
    Opens the validation set details page in the browser.

    Raises:
        Exception: If the order is not in processing state.
    """
    logger.info("Opening validation set details page in browser...")
    could_open_browser = webbrowser.open(self.validation_set_details_page)
    if not could_open_browser:
        encoded_url = urllib.parse.quote(
            self.validation_set_details_page, safe="%/:=&?~#+!$,;'@()*[]"
        )
        managed_print(
            Fore.RED
            + f"Please open this URL in your browser: '{encoded_url}'"
            + Fore.RESET
        )

delete #

delete() -> None

Deletes the validation set

Source code in src/rapidata/rapidata_client/validation/rapidata_validation_set.py
def delete(self) -> None:
    """Deletes the validation set"""
    with tracer.start_as_current_span("RapidataValidationSet.delete"):
        logger.info("Deleting ValidationSet '%s'", self)
        self.__openapi_service.validation_api.validation_set_validation_set_id_delete(
            self.id
        )
        logger.debug("ValidationSet '%s' has been deleted.", self)
        managed_print(f"ValidationSet '{self}' has been deleted.")