File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6666
6767## Tier4 Instance (` TIV ` )
6868
69- | ID | Name | Severity | Description |
70- | -------- | ------------ | -------- | --------------------------------------- |
71- | ` TIV001 ` | ` load-tier4 ` | ` Error ` | Success to initialize ` Tier4 ` instance. |
69+ | ID | Name | Severity | Description |
70+ | -------- | ------------ | -------- | ----------------------------------------------- |
71+ | ` TIV001 ` | ` load-tier4 ` | ` Error ` | Ensure ` Tier4 ` instance is loaded successfully . |
Original file line number Diff line number Diff line change 77from .result import * # noqa
88from .run import * # noqa
99from .structure import * # noqa
10+ from .tier4 import * # noqa
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class RuleGroup(Enum):
1313 RECORD = "REC"
1414 REFERENCE = "REF"
1515 FORMAT = "FMT"
16+ TIER4 = "TIV"
1617
1718 @classmethod
1819 def values (cls ) -> list [str ]:
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ from .tiv001 import * # noqa
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING
4+
5+ from returns .pipeline import is_successful
6+ from returns .result import Result , safe
7+
8+ from ..checker import Checker , RuleID , RuleName
9+ from ..result import Reason
10+ from ..registry import CHECKERS
11+ from t4_devkit import Tier4
12+
13+ if TYPE_CHECKING :
14+ from ..context import SanityContext
15+
16+ __all__ = ["TIV001" ]
17+
18+
19+ @CHECKERS .register (RuleID ("TIV001" ))
20+ class TIV001 (Checker ):
21+ """A checker for TIV001."""
22+
23+ name = RuleName ("load-tier4" )
24+ description = "Ensure 'Tier4' instance is loaded successfully."
25+
26+ def check (self , context : SanityContext ) -> list [Reason ]:
27+ result = _load_tier4_safe (context )
28+ return (
29+ [] if is_successful (result ) else [Reason (f"Failed to load Tier4: { result .failure ()} " )]
30+ )
31+
32+
33+ @safe
34+ def _load_tier4_safe (context : SanityContext ) -> Result [Tier4 , Exception ]:
35+ data_root = context .data_root .unwrap ()
36+ revision = context .version .value_or (None )
37+ data_root = data_root .as_posix () if revision is None else data_root .parent .as_posix ()
38+ return Tier4 (data_root , revision = revision , verbose = False )
You can’t perform that action at this time.
0 commit comments