hyped.core.features.engine module¶
DType Handling and Validation Module.
This module provides utilities for type validation, type variable registration, and type checking within a data flow graph system. It allows dynamic handling of type annotations, argument validation, and captures type variables during function calls. It integrates with Pydantic to handle model validation.
- class hyped.core.features.engine.FeatureEngine(name: str, config: BaseConfig, signature: Signature)[source]¶
Bases:
objectFeature Engine.
The
FeatureEngineensures that the input features conform to the expected types defined in the function’s signature and uses the type annotations to construct output features dynamically.- build_feature_with_context(annotation: Any, inputs: None | dict[str, Feature]) Feature[source]¶
Create a feature based on type annotation and inputs in a specific context.
- build_return_feature(inputs: dict[str, Feature]) Feature[source]¶
Build the return feature based on the function’s return type annotation.
- get_features_and_objects(*args: Feature | Any, **kwargs: Feature | Any) tuple[dict[str, Feature], dict[str, Any], dict[str, DType]][source]¶
Separate input feature references and constants from the arguments.
- validate_arguments(*args: Any, **kwargs: Any) None[source]¶
Validate the arguments passed to the function based on its signature.
- Parameters:
*args (Any) – Positional arguments.
**kwargs (Any) – Keyword arguments.
- Raises:
TypeError – If the arguments provided are invalid or do not match the expected types.
- class hyped.core.features.engine.TypeVarRegister[source]¶
Bases:
objectA registry for managing and capturing TypeVars used in type validation.
- create_trackable_typevar(*args: Any, **kwargs: Any) TypeVar[source]¶
Create and register a TypeVar with a custom validator.
- Parameters:
*args (Any) – Positional arguments passed to the
TypeVarconstructor.**kwargs (Any) – Keyword arguments passed to the
TypeVarconstructor. Specialboundkeyword is used to define the type bound for the TypeVar.
- Returns:
The newly created and registered
TypeVarwith the custom validator.- Return type:
TypeVar
- create_validator()[source]¶
Create a Pydantic validator to validate and capture TypeVars.
- Returns:
A Pydantic validator function with an associated UUID.
- Return type:
Callable
- register(t: TypeVar, validator: AfterValidator) None[source]¶
Register a TypeVar with a Pydantic validator.
- Parameters:
t (TypeVar) – The TypeVar to register.
validator (pydantic.AfterValidator) – The validator associated with the TypeVar.