Validator (autotransform.validator.base)

The base class and associated classes for Validator components.

exception autotransform.validator.base.ValidationError(*, issue: ValidationResult, message: str | None)

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: str | None
class autotransform.validator.base.ValidationResult(*, level: ValidationResultLevel, validator: Validator, message: str | None = 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: str | None = 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: Mapping[str, Any] | None) 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

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

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

Bases: str, Enum

A simple enum for mapping.

SCRIPT = 'script'