Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions docs/tutorials/cli/t4sanity.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $ t4sanity -h
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version -v Show the application version and exit. │
│ --output -o TEXT Path to output JSON file. [default: None] │
│ --revision -rv TEXT Specify if you want to load the specific version. [default: None] │
│ --include-warning -iw Indicates whether to report any warnings. │
│ --install-completion Install completion for the current shell. │
Expand Down Expand Up @@ -62,7 +63,7 @@ $ t4sanity <DATA_ROOT>
>>>Sanity checking...: 2it [00:00, 18.69it/s]
⚠️ Encountered some exceptions!!
+-----------+---------+--------+------------------------------------------------------------------------------------------------+
| DatasetID | Version | status | Message |
| DatasetID | Version | Status | Message |
+-----------+---------+--------+------------------------------------------------------------------------------------------------+
| dataset1 | 2 | ERROR | bbox must be (xmin, ymin, xmax, ymax) and xmin <= xmax && ymin <= ymax: (1532, 198, 1440, 265) |
| dataset2 | 1 | OK | |
Expand All @@ -79,9 +80,39 @@ $ t4sanity <DATA_ROOT> -iw
>>>Sanity checking...: 2it [00:00, 21.54it/s]
⚠️ Encountered some exceptions!!
+-----------+---------+---------+------------------------------------------------------------------------------------------------+
| DatasetID | Version | status | Message |
| DatasetID | Version | Status | Message |
+-----------+---------+---------+------------------------------------------------------------------------------------------------+
| dataset1 | 2 | ERROR | bbox must be (xmin, ymin, xmax, ymax) and xmin <= xmax && ymin <= ymax: (1532, 198, 1440, 265) |
| dataset2 | 1 | WARNING | Category token is empty for surface ann: 0c15d9c143fb2723c16ac7e0c735b0a8 |
+-----------+---------+---------+------------------------------------------------------------------------------------------------+
```

### Dump Results as JSON

To dump results into JSON, use the `-o; --output` option:

```shell
$ t4sanity <DATA_ROOT> -o results.json

>>>Sanity checking...: 2it [00:00, 21.54it/s]
...
```

Then a JSON file named `results.json` will be generated:

```json
[
{
"dataset_id": "dataset1",
"version": 2,
"status": "ERROR",
"message": "bbox must be (xmin, ymin, xmax, ymax) and xmin <= xmax && ymin <= ymax: (1532, 198, 1440, 265)"
},
{
"dataset_id": "dataset2",
"version": 1,
"status": "WARNING",
"message": "Category token is empty for surface ann: 0c15d9c143fb2723c16ac7e0c735b0a8"
}
]
```
9 changes: 8 additions & 1 deletion t4_devkit/cli/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from tabulate import tabulate
from tqdm import tqdm

from t4_devkit.common.io import save_json
from t4_devkit.common.sanity import DBException, sanity_check
from t4_devkit.common.serialize import serialize_dataclasses

from .version import version_callback

Expand Down Expand Up @@ -41,6 +43,7 @@ def main(
is_eager=True,
),
db_parent: str = typer.Argument(..., help="Path to parent directory of the databases."),
output: str | None = typer.Option(None, "-o", "--output", help="Path to output JSON file."),
revision: str | None = typer.Option(
None, "-rv", "--revision", help="Specify if you want to check the specific version."
),
Expand All @@ -54,6 +57,10 @@ def main(
print("✅ No exceptions occurred!!")
else:
print("⚠️ Encountered some exceptions!!")
headers = ["DatasetID", "Version", "status", "Message"]
headers = ["DatasetID", "Version", "Status", "Message"]
table = [[e.dataset_id, e.version, e.status, e.message] for e in exceptions]
print(tabulate(table, headers=headers, tablefmt="pretty"))

if output:
serialized = serialize_dataclasses(exceptions)
save_json(serialized, output)
Loading