hydra.validation module
Framework types for configurable validation: profiles classify checks as errors or warnings, and results accumulate findings up to caller-specified bounds.
- class hydra.validation.ValidationProfile(error_rules: Annotated[Set[Name], "The set of fully qualified rule names whose findings are treated as errors. Each name has the form 'hydra.error.<package>.<UnionType>.<variant>', e.g. 'hydra.error.core.InvalidTermError.duplicateBinding'."], warning_rules: Annotated[Set[Name], 'The set of fully qualified rule names whose findings are treated as warnings. Same name format as errorRules.'], max_errors: Annotated[int, "Hard upper bound on collected errors. Validation terminates as soon as the errors list reaches this length. A value of 1 reproduces the legacy 'first error wins' behaviour."], max_warnings: Annotated[int, 'Soft upper bound on collected warnings. Once the warnings list reaches this length, further warning matches are silently dropped, but validation does not terminate; it continues until maxErrors is reached or the traversal completes.'])
Bases:
objectConfiguration for a validation pass: which check rules are active, how each is classified, and the upper bounds on collected findings. A check whose rule name appears in neither set is never evaluated. Errors hard-stop the traversal once maxErrors is reached; warnings only stop being collected once maxWarnings is reached, never causing termination.
- class Builder(_error_rules: 'Set[hydra.core.Name]' = None, _warning_rules: 'Set[hydra.core.Name]' = None, _max_errors: 'int' = None, _max_warnings: 'int' = None)
Bases:
object- build()
- error_rules(error_rules)
- max_errors(max_errors)
- max_warnings(max_warnings)
- warning_rules(warning_rules)
- ERROR_RULES = Name(value='errorRules')
- MAX_ERRORS = Name(value='maxErrors')
- MAX_WARNINGS = Name(value='maxWarnings')
- TYPE_ = Name(value='hydra.validation.ValidationProfile')
- WARNING_RULES = Name(value='warningRules')
- static builder()
- error_rules: Annotated[Set[Name], "The set of fully qualified rule names whose findings are treated as errors. Each name has the form 'hydra.error.<package>.<UnionType>.<variant>', e.g. 'hydra.error.core.InvalidTermError.duplicateBinding'."]
- max_errors: Annotated[int, "Hard upper bound on collected errors. Validation terminates as soon as the errors list reaches this length. A value of 1 reproduces the legacy 'first error wins' behaviour."]
- max_warnings: Annotated[int, 'Soft upper bound on collected warnings. Once the warnings list reaches this length, further warning matches are silently dropped, but validation does not terminate; it continues until maxErrors is reached or the traversal completes.']
- warning_rules: Annotated[Set[Name], 'The set of fully qualified rule names whose findings are treated as warnings. Same name format as errorRules.']
- with_error_rules(error_rules)
- with_max_errors(max_errors)
- with_max_warnings(max_warnings)
- with_warning_rules(warning_rules)
- class hydra.validation.ValidationResult(errors: Annotated[Sequence[E], "Findings classified as errors, in traversal order, bounded by the profile's maxErrors."], warnings: Annotated[Sequence[E], "Findings classified as warnings, in traversal order, bounded by the profile's maxWarnings."])
Bases:
Generic[E]The outcome of a validation pass: an ordered list of error findings and an ordered list of warning findings, each parameterized by the finding payload type. The pass is considered successful when ‘errors’ is empty; warnings are informational and do not affect that judgement.
- class Builder(_errors: 'Sequence[E]' = None, _warnings: 'Sequence[E]' = None)
Bases:
Generic[E]- build()
- errors(errors)
- warnings(warnings)
- ERRORS = Name(value='errors')
- TYPE_ = Name(value='hydra.validation.ValidationResult')
- WARNINGS = Name(value='warnings')
- static builder()
- errors: Annotated[Sequence[E], "Findings classified as errors, in traversal order, bounded by the profile's maxErrors."]
- warnings: Annotated[Sequence[E], "Findings classified as warnings, in traversal order, bounded by the profile's maxWarnings."]
- with_errors(errors)
- with_warnings(warnings)