Validator (autotransform.validator.base)

The base class and associated classes for Validator components.

exception autotransform.validator.base.ValidationError(*, issue: ValidationResult, message: Optional[str])

Bases: Exception

An error raised by validation failing on a run.

issue

The validation result that triggered the error.

Type:

ValidationResult

message

A message representing why the validation failed.

Type:

str

issue: ValidationResult
message: Optional[str]
class autotransform.validator.base.ValidationResult(*, level: ValidationResultLevel, validator: Validator, message: Optional[str] = None)

Bases: object

Represents the result of an attempt at validation.

level

The level of the validation issue raised.

Type:

ValidationResultLevel

validator

The Validator that returned this result.

Type:

Validator

message

The message associated with the validation result. Defaults to None.

Type:

Optional[str], optional

level: ValidationResultLevel
message: Optional[str] = None
validator: Validator
class autotransform.validator.base.ValidationResultLevel(value)

Bases: str, Enum

The result level of a validation indicating how bad a validation failure is.

ERROR = 'error'
NONE = 'none'
WARNING = 'warning'
compare(other: str) int

Compares two result levels and returns an integer indicating the comparison.

Parameters:

other (str) – The value to compare against.

Returns:

A negative number if lt, 0 if equal, and a positive number if gt.

Return type:

int

class autotransform.validator.base.Validator

Bases: NamedComponent

The base for Validator components. Validators test that the codebase is still healthy after a transformation.

name

The name of the component.

Type:

ClassVar[ValidatorName]

abstract check(batch: Batch, transform_data: Optional[Mapping[str, Any]]) ValidationResult

Validate that a Batch that has undergone transformation does not produce any issues such as test failures or type errors.

Parameters:
  • batch (Batch) – The transformed Batch to validate.

  • transform_data (Optional[Mapping[str, Any]]) – Data from the transformation.

Returns:

The result of the validation check indicating the severity of any

validation failures as well as an associated message.

Return type:

ValidationResult

name: ClassVar[ValidatorName]
class autotransform.validator.base.ValidatorName(value)

Bases: str, Enum

A simple enum for mapping.

SCRIPT = 'script'