We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data type mismatches between pipeline stages cause cryptic failures late in execution.
@validate_io
utils/validation.py
The text was updated successfully, but these errors were encountered:
example implementation for context :
from functools import wraps from typing import Type, Tuple, Optional from stimulus.exceptions import StimulusError def validate_input_types(*types: Type[object]): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): for i, (arg, expected_type) in enumerate(zip(args[1:], types)): # Skip self if not isinstance(arg, expected_type): raise StimulusError( f"Invalid type for argument {i} in {func.__name__}" ).add_context( expected_type=expected_type.__name__, actual_type=type(arg).__name__, argument_index=i ) return func(*args, **kwargs) return wrapper return decorator # Usage in encoder class TextEncoder: @validate_input_types(str) def encode(self, text: str) -> torch.Tensor: return self._encoding_logic(text)
Sorry, something went wrong.
No branches or pull requests
Is your change request related to a problem? Please describe.
Data type mismatches between pipeline stages cause cryptic failures late in execution.
Describe the solution you'd like
@validate_io
decorator inutils/validation.py
The text was updated successfully, but these errors were encountered: