8
8
from cli .helpers .nucleus_url import nucleus_url
9
9
from cli .helpers .web_helper import launch_web_or_invoke
10
10
from nucleus import NucleusAPIError
11
- from nucleus .modelci import (
11
+ from nucleus .validate import (
12
12
AvailableEvalFunctions ,
13
+ ScenarioTestMetric ,
13
14
ThresholdComparison ,
14
- UnitTestMetric ,
15
15
)
16
16
17
17
21
21
def tests (ctx , web ):
22
22
"""Scenario Tests allow you to test your Models
23
23
24
- https://dashboard.scale.com/nucleus/unit -tests
24
+ https://dashboard.scale.com/nucleus/scenario -tests
25
25
"""
26
- launch_web_or_invoke ("unit -tests" , ctx , web , list_tests )
26
+ launch_web_or_invoke ("scenario -tests" , ctx , web , list_tests )
27
27
28
28
29
29
@tests .command ("list" )
@@ -32,7 +32,7 @@ def list_tests():
32
32
console = Console ()
33
33
with console .status ("Finding your Scenario Tests" , spinner = "dots4" ):
34
34
client = init_client ()
35
- unit_tests = client .modelci . list_unit_tests ()
35
+ scenario_tests = client .validate . list_scenario_tests ()
36
36
table = Table (
37
37
Column ("id" , overflow = "fold" , min_width = 24 ),
38
38
"Name" ,
@@ -41,13 +41,13 @@ def list_tests():
41
41
title = ":chart_with_upwards_trend: Scenario Tests" ,
42
42
title_justify = "left" ,
43
43
)
44
- for ut in unit_tests :
44
+ for ut in scenario_tests :
45
45
table .add_row (ut .id , ut .name , ut .slice_id , nucleus_url (ut .id ))
46
46
console .print (table )
47
47
48
48
49
49
def format_criterion (
50
- criterion : UnitTestMetric , eval_functions : AvailableEvalFunctions
50
+ criterion : ScenarioTestMetric , eval_functions : AvailableEvalFunctions
51
51
):
52
52
op_map = {
53
53
ThresholdComparison .GREATER_THAN : ">" ,
@@ -63,55 +63,57 @@ def format_criterion(
63
63
64
64
65
65
@tests .command ("describe" )
66
- @click .argument ("unit -test-id" , default = None , required = False )
66
+ @click .argument ("scenario -test-id" , default = None , required = False )
67
67
@click .option (
68
68
"--all" , "-a" , is_flag = True , help = "View details about all Scenario Tests"
69
69
)
70
- def describe_test (unit_test_id , all ):
70
+ def describe_test (scenario_test_id , all ):
71
71
"""View detailed information about a test or all tests"""
72
72
console = Console ()
73
- # unit_test = client.modelci.get_unit_test(unit_test_id )
74
- assert unit_test_id or all , "Must pass a unit_test_id or --all"
73
+ # scenario_test = client.validate.get_scenario_test(scenario_test_id )
74
+ assert scenario_test_id or all , "Must pass a scenario_test_id or --all"
75
75
client = init_client ()
76
- unit_tests = client .modelci . list_unit_tests ()
76
+ scenario_tests = client .validate . list_scenario_tests ()
77
77
if all :
78
78
tree = Tree (":chart_with_upwards_trend: All Scenario Tests" )
79
79
with Live (
80
80
"Fetching description of all Scenario Tests" ,
81
81
vertical_overflow = "visible" ,
82
82
) as live :
83
- for idx , ut in enumerate (unit_tests ):
84
- test_branch = tree .add (f"{ idx } : Unit Test" )
85
- build_unit_test_info_tree (client , ut , test_branch )
83
+ for idx , ut in enumerate (scenario_tests ):
84
+ test_branch = tree .add (f"{ idx } : Scenario Test" )
85
+ build_scenario_test_info_tree (client , ut , test_branch )
86
86
live .update (tree )
87
87
else :
88
88
with console .status ("Fetching Scenario Test information" ):
89
- unit_test = [ut for ut in unit_tests if ut .id == unit_test_id ][0 ]
90
- tree = Tree (":chart_with_upwards_trend: Unit Test" )
91
- build_unit_test_info_tree (client , unit_test , tree )
89
+ scenario_test = [
90
+ ut for ut in scenario_tests if ut .id == scenario_test_id
91
+ ][0 ]
92
+ tree = Tree (":chart_with_upwards_trend: Scenario Test" )
93
+ build_scenario_test_info_tree (client , scenario_test , tree )
92
94
console .print (tree )
93
95
94
96
95
- def build_unit_test_info_tree (client , unit_test , tree ):
97
+ def build_scenario_test_info_tree (client , scenario_test , tree ):
96
98
try :
97
- slc = client .get_slice (unit_test .slice_id )
99
+ slc = client .get_slice (scenario_test .slice_id )
98
100
info_branch = tree .add (":mag: Details" )
99
- info_branch .add (f"id: '{ unit_test .id } '" )
100
- info_branch .add (f"name: '{ unit_test .name } '" )
101
- unit_test_url = nucleus_url (unit_test .id )
102
- info_branch .add (f"url: { unit_test_url } " )
101
+ info_branch .add (f"id: '{ scenario_test .id } '" )
102
+ info_branch .add (f"name: '{ scenario_test .name } '" )
103
+ scenario_test_url = nucleus_url (scenario_test .id )
104
+ info_branch .add (f"url: { scenario_test_url } " )
103
105
slice_url = nucleus_url (f"{ slc .dataset_id } /{ slc .slice_id } " )
104
106
slice_branch = tree .add (":cake: Slice" )
105
107
slice_branch .add (f"id: '{ slc .id } '" )
106
108
slice_info = slc .info ()
107
109
slice_branch .add (f"name: '{ slice_info ['name' ]} '" )
108
110
slice_branch .add (f"len: { len (slc .items )} " )
109
111
slice_branch .add (f"url: { slice_url } " )
110
- criteria = unit_test .get_criteria ()
112
+ criteria = scenario_test .get_criteria ()
111
113
criteria_branch = tree .add (":crossed_flags: Criteria" )
112
114
for criterion in criteria :
113
115
pretty_criterion = format_criterion (
114
- criterion , client .modelci .eval_functions
116
+ criterion , client .validate .eval_functions
115
117
)
116
118
criteria_branch .add (pretty_criterion )
117
119
except NucleusAPIError as e :
0 commit comments