Skip to content

Commit 3f28a79

Browse files
committed
docs: update document
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
1 parent 51fe994 commit 3f28a79

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

docs/cli/t4sanity.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,24 @@ With `-f; --fix` option enables to fix issues automatically:
9393
```shell
9494
# Fix issues automatically
9595
t4sanity <DATA_ROOT> --fix
96+
97+
>>>Sanity checking...: 1it [00:00, 9.70it/s]
98+
99+
=== DatasetID: dataset1 ===
100+
...
101+
REC007: --> FIXED🎉
102+
- All categories either must have an 'index' set or all have a 'null' index.
103+
...
104+
105+
+-----------+---------+--------+--------+---------+----------+-------+
106+
| DatasetID | Version | Passed | Failed | Skipped | Warnings | Fixed |
107+
+-----------+---------+--------+--------+---------+----------+-------+
108+
| dataset1 | 0 | 49 | 0 | 2 | 3 | 1 |
109+
+-----------+---------+--------+--------+---------+----------+-------+
96110
```
97111
112+
The generated report contains failure or warning reasons, but it's considered as passed if the fix was successful.
113+
98114
### Exit Status Logic
99115
100116
`t4sanity` CLI returns the exit code based on the following conditions:
@@ -129,7 +145,7 @@ Then a JSON file named `result.json` will be generated as follows:
129145
"severity": "<WARNING/ERROR: str>",
130146
"description": "<Description: str>",
131147
"status": "<PASSED/FAILED/SKIPPED: str>",
132-
"reasons": "<[<Reason1>, <Reason2>, ...]: [str; N] | null>", // Failed or skipped reasons, null if passed
148+
"reasons": "<[<Reason1>, <Reason2>, ...]: [str; N] | null>",
133149
"fixed": "<Fixed: bool>"
134150
},
135151
]

docs/tutorials/sanity.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,28 @@ save_json(serialize_dataclass(result), "result.json")
2222

2323
### How to Add New Checkers
2424

25+
The following diagram shows the logic of the checkers:
26+
27+
```mermaid
28+
flowchart LR
29+
Start --> A{Can skip?}
30+
A --> |Yes| B[Skip check and <br/>returns skipped report]
31+
A --> |No| C[Perform check]
32+
C --> D{Failed and --fix=True?}
33+
D --> |Yes| E[Fix issues]
34+
E --> F[Return report]
35+
D --> |No| F
36+
```
37+
2538
All checkers must follow:
2639

2740
- Implement a class that inherits from `Checker` class.
2841
- Its ID must be unique and belong to one of `RuleGroup` enum.
29-
- Override the `check() -> list[Reason] | None` method to perform the specific check.
3042
- Register the checker using `CHECKERS.register()` decorator.
43+
- Override the `check(...) -> list[Reason] | None` method to perform the specific check.
44+
- [OPTIONAL] The following methods can be overridden if needed:
45+
- Override `can_skip(...) -> Maybe[Reason]` method to determine whether the checker can be skipped.
46+
- Override `fix(...) -> bool` method to fix the issue if possible.
3147

3248
```python title="str000.py"
3349
from __future__ import annotations

0 commit comments

Comments
 (0)