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#
Common validators for pipeline stages. |
|
Details about a specific validation failure. |
|
Wrapper class for stage verification results. |
Data#
API#
- class fastvideo.v1.pipelines.stages.validators.StageValidators[source]#
Common validators for pipeline stages.
- 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_tensor(value: Any) bool [source]#
Check if value is a torch tensor and doesn’t contain NaN values.
- static list_min_length(value: Any, min_length: int) bool [source]#
Check if list has at least min_length items.
- 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 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 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_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.
- 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)])