sanity
Checker
Base class for sanity checkers.
Source code in t4_devkit/sanity/checker.py
can_skip(_)
check(context)
abstractmethod
Return a list of reasons if the checker fails, or None if it passes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
SanityContext
|
The sanity context. |
required |
Returns:
| Type | Description |
|---|---|
list[Reason] | None
|
A list of reasons if the checker fails, or None if it passes. |
Source code in t4_devkit/sanity/checker.py
CheckerRegistry
Source code in t4_devkit/sanity/registry.py
build(excludes=None)
Build a list of checkers from the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
excludes
|
Sequence[str] | None
|
A list of rule IDs or rule groups to exclude. |
None
|
Returns:
| Type | Description |
|---|---|
list[Checker]
|
A list of checkers. |
Source code in t4_devkit/sanity/registry.py
register()
Register a checker class.
Returns:
| Type | Description |
|---|---|
Callable
|
A decorator function that registers the checker class. |
Source code in t4_devkit/sanity/registry.py
Report
A report for a rule.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
RuleID
|
The ID of the rule. |
name |
RuleName
|
The name of the rule. |
severity |
Severity
|
The severity of the rule. |
description |
str
|
The description of the rule. |
status |
Status
|
The status of the report. |
reasons |
list[Reason] | None
|
The list of reasons for the report if the report is a failure or skipped. |
Source code in t4_devkit/sanity/result.py
is_failed(*, strict=False)
Check if the status is failed.
is_passed(*, strict=False)
is_skipped()
to_str(*, strict=False)
Return a string representation of the report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strict
|
bool
|
Whether to consider warnings as failures. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A string representation of the report. |
Source code in t4_devkit/sanity/result.py
RuleGroup
Source code in t4_devkit/sanity/registry.py
to_group(id)
classmethod
Convert a rule ID to a rule group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
RuleID
|
The ID of the rule. |
required |
Returns:
| Type | Description |
|---|---|
RuleGroup | None
|
The rule group if the rule ID belongs to any rule group, otherwise None. |
Source code in t4_devkit/sanity/registry.py
SanityResult
The result of a Sanity check.
Attributes:
| Name | Type | Description |
|---|---|---|
dataset_id |
str
|
The ID of the dataset. |
version |
str | None
|
The version of the dataset. |
reports |
list[Report]
|
The list of reports. |
Source code in t4_devkit/sanity/result.py
from_context(context, reports)
classmethod
Create a SanityResult from a SanityContext and a list of reports.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
SanityContext
|
The SanityContext to use. |
required |
reports
|
list[Report]
|
The list of reports to include in the result. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
The created SanityResult. |
Source code in t4_devkit/sanity/result.py
is_passed(*, strict=False)
Return True if all reports are passed, False otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strict
|
bool
|
Whether to consider warnings as failures. |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if all reports are passed, False otherwise. |
Source code in t4_devkit/sanity/result.py
to_str(*, strict=False)
Return a string representation of the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strict
|
bool
|
Whether to consider warnings as failures. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
A string representation of the result. |
Source code in t4_devkit/sanity/result.py
Status
print_sanity_result(result, *, strict=False)
Print detailed and summary results of a sanity check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
SanityResult
|
The result of a sanity check. |
required |
Source code in t4_devkit/sanity/result.py
sanity_check(data_root, revision=None, *, excludes=None)
Run sanity checks on the given data root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_root
|
str
|
The root directory of the data. |
required |
revision
|
str | None
|
The revision to check. If None, the latest revision is used. |
None
|
excludes
|
Sequence[str] | None
|
A list of rule names or groups to exclude. |
None
|
Returns:
| Type | Description |
|---|---|
SanityResult
|
A SanityResult object. |