fastvideo.v1.pipelines.stages.validators#

Common validators for pipeline stage verification.

This module provides reusable validation functions that can be used across all pipeline stages for input/output verification.

Module Contents#

Classes#

StageValidators

Common validators for pipeline stages.

ValidationFailure

Details about a specific validation failure.

VerificationResult

Wrapper class for stage verification results.

Data#

V

API#

class fastvideo.v1.pipelines.stages.validators.StageValidators[source]#

Common validators for pipeline stages.

static bool_value(value: Any) bool[source]#

Check if value is a boolean.

static divisible(divisor: int) collections.abc.Callable[[Any], bool][source]#

Return a validator that checks if value is divisible by divisor.

static divisible_by(value: Any, divisor: int) bool[source]#

Check if value is divisible by divisor.

static generator_or_list_generators(value: Any) bool[source]#

Check if value is a Generator or list of Generators.

static is_list(value: Any) bool[source]#

Check if value is a list (can be empty).

static is_tensor(value: Any) bool[source]#

Check if value is a torch tensor and doesn’t contain NaN values.

static is_tuple(value: Any) bool[source]#

Check if value is a tuple.

static list_length(value: Any, length: int) bool[source]#

Check if list has specific length.

static list_min_length(value: Any, min_length: int) bool[source]#

Check if list has at least min_length items.

static list_not_empty(value: Any) bool[source]#

Check if value is a non-empty list.

static list_of_tensors(value: Any) bool[source]#

Check if value is a non-empty list where all items are tensors without NaN values.

static list_of_tensors_dims(dims: int) collections.abc.Callable[[Any], bool][source]#

Return a validator that checks if value is a list of tensors with specific dimensions and no NaN values.

static list_of_tensors_min_dims(min_dims: int) collections.abc.Callable[[Any], bool][source]#

Return a validator that checks if value is a list of tensors with at least min_dims dimensions and no NaN values.

static list_of_tensors_with_dims(value: Any, dims: int) bool[source]#

Check if value is a non-empty list where all items are tensors with specific dimensions and no NaN values.

static list_of_tensors_with_min_dims(value: Any, min_dims: int) bool[source]#

Check if value is a non-empty list where all items are tensors with at least min_dims dimensions and no NaN values.

static min_dims(min_dims: int) collections.abc.Callable[[Any], bool][source]#

Return a validator that checks if tensor has at least min_dims dimensions and no NaN values.

static non_negative_float(value: Any) bool[source]#

Check if value is a non-negative float.

static none_or_list(value: Any) bool[source]#

Check if value is None or a list.

static none_or_positive_int(value: Any) bool[source]#

Check if value is None or a positive integer.

static none_or_tensor(value: Any) bool[source]#

Check if value is None or a tensor without NaN values.

static none_or_tensor_with_dims(dims: int) collections.abc.Callable[[Any], bool][source]#

Return a validator that checks if value is None or a tensor with specific dimensions and no NaN values.

static not_none(value: Any) bool[source]#

Check if value is not None.

static positive_float(value: Any) bool[source]#

Check if value is a positive float.

static positive_int(value: Any) bool[source]#

Check if value is a positive integer.

static positive_int_divisible(divisor: int) collections.abc.Callable[[Any], bool][source]#

Return a validator that checks if value is a positive integer divisible by divisor.

static string_not_empty(value: Any) bool[source]#

Check if value is a non-empty string.

static string_or_list_strings(value: Any) bool[source]#

Check if value is a string or list of strings.

static tensor_min_dims(value: Any, min_dims: int) bool[source]#

Check if value is a tensor with at least min_dims dimensions and no NaN values.

static tensor_shape_matches(value: Any, expected_shape: tuple) bool[source]#

Check if tensor shape matches expected shape (None for any size) and no NaN values.

static tensor_with_dims(value: Any, dims: int) bool[source]#

Check if value is a tensor with specific dimensions and no NaN values.

static with_dims(dims: int) collections.abc.Callable[[Any], bool][source]#

Return a validator that checks if tensor has specific dimensions and no NaN values.

fastvideo.v1.pipelines.stages.validators.V#

None

class fastvideo.v1.pipelines.stages.validators.ValidationFailure(validator_name: str, actual_value: Any, expected: str | None = None, error_msg: str | None = None)[source]#

Details about a specific validation failure.

Initialization

class fastvideo.v1.pipelines.stages.validators.VerificationResult[source]#

Wrapper class for stage verification results.

Initialization

add_check(field_name: str, value: Any, validators: collections.abc.Callable[[Any], bool] | list[collections.abc.Callable[[Any], bool]]) fastvideo.v1.pipelines.stages.validators.VerificationResult[source]#

Add a validation check for a field.

Parameters:
  • field_name – Name of the field being checked

  • value – The actual value to validate

  • validators – Single validation function or list of validation functions. Each function will be called with the value as its first argument.

Returns:

Self for method chaining

.. rubric:: Examples

Single validator#

result.add_check(“tensor”, my_tensor, V.is_tensor)

Multiple validators (all must pass)#

result.add_check(“latents”, batch.latents, [V.is_tensor, V.with_dims(5)])

Using partial functions for parameters#

result.add_check(“height”, batch.height, [V.not_none, V.divisible(8)])

get_detailed_failures() dict[str, list[fastvideo.v1.pipelines.stages.validators.ValidationFailure]][source]#

Get detailed failure information for each failed field.

get_failed_fields() list[str][source]#

Get list of fields that failed validation.

get_failure_summary() str[source]#

Get a comprehensive summary of all validation failures.

is_valid() bool[source]#

Check if all validations passed.

to_dict() dict[source]#

Convert to dictionary for backward compatibility.