@@ -11,6 +11,12 @@ import { MatButtonModule } from '@angular/material/button';
11
11
import { TrialsTableComponent } from './trials-table.component' ;
12
12
import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ;
13
13
14
+ import { SimpleChange } from '@angular/core' ;
15
+ import { PropertyValue , StatusValue , ComponentValue } from 'kubeflow' ;
16
+ import { parseStatus } from '../../experiments/utils' ;
17
+ import lowerCase from 'lodash-es/lowerCase' ;
18
+ import { KfpRunComponent } from './kfp-run/kfp-run.component' ;
19
+
14
20
describe ( 'TrialsTableComponent' , ( ) => {
15
21
let component : TrialsTableComponent ;
16
22
let fixture : ComponentFixture < TrialsTableComponent > ;
@@ -38,10 +44,157 @@ describe('TrialsTableComponent', () => {
38
44
beforeEach ( ( ) => {
39
45
fixture = TestBed . createComponent ( TrialsTableComponent ) ;
40
46
component = fixture . componentInstance ;
47
+ component . displayedColumns = [
48
+ 'Status' ,
49
+ 'Trial name' ,
50
+ 'Validation loss' ,
51
+ 'Lr' ,
52
+ 'Batch size' ,
53
+ 'Embed dim' ,
54
+ 'Dropout' ,
55
+ 'Sp dropout' ,
56
+ 'Kfp run' ,
57
+ ] ;
58
+ component . data = [
59
+ [
60
+ 'Succeeded' ,
61
+ 'open-vaccine-0f37u-6cd03cbf' ,
62
+ '0.70573' ,
63
+ '0.0001' ,
64
+ '32' ,
65
+ '20' ,
66
+ '0.2' ,
67
+ '0.2' ,
68
+ '9af7c534-689a-48aa-996b-537d13989729' ,
69
+ '0' ,
70
+ ] ,
71
+ [
72
+ 'Succeeded' ,
73
+ 'open-vaccine-0f37u-8ec17b8f' ,
74
+ '0.76401' ,
75
+ '0.0001' ,
76
+ '96' ,
77
+ '20' ,
78
+ '0.2' ,
79
+ '0.2' ,
80
+ '19aed8e0-143c-49d8-8bd3-7ebb464181d8' ,
81
+ '1' ,
82
+ ] ,
83
+ ] ;
84
+ component . ngOnChanges ( {
85
+ displayedColumns : new SimpleChange (
86
+ null ,
87
+ component . displayedColumns ,
88
+ false ,
89
+ ) ,
90
+ } ) ;
91
+
41
92
fixture . detectChanges ( ) ;
42
93
} ) ;
43
94
44
- it ( 'should create' , ( ) => {
45
- expect ( component ) . toBeTruthy ( ) ;
95
+ it ( 'should create processedData' , ( ) => {
96
+ expect ( component . processedData ) . toEqual ( [
97
+ {
98
+ 'trial name' : 'open-vaccine-0f37u-6cd03cbf' ,
99
+ status : 'Succeeded' ,
100
+ 'validation loss' : '0.70573' ,
101
+ lr : '0.0001' ,
102
+ 'batch size' : '32' ,
103
+ 'embed dim' : '20' ,
104
+ dropout : '0.2' ,
105
+ 'sp dropout' : '0.2' ,
106
+ 'kfp run' : '9af7c534-689a-48aa-996b-537d13989729' ,
107
+ } ,
108
+ {
109
+ 'trial name' : 'open-vaccine-0f37u-8ec17b8f' ,
110
+ status : 'Succeeded' ,
111
+ 'validation loss' : '0.76401' ,
112
+ lr : '0.0001' ,
113
+ 'batch size' : '96' ,
114
+ 'embed dim' : '20' ,
115
+ dropout : '0.2' ,
116
+ 'sp dropout' : '0.2' ,
117
+ 'kfp run' : '19aed8e0-143c-49d8-8bd3-7ebb464181d8' ,
118
+ } ,
119
+ ] ) ;
120
+ } ) ;
121
+
122
+ it ( 'should create config' , ( ) => {
123
+ expect ( component . config ) . toEqual ( {
124
+ columns : [
125
+ {
126
+ matColumnDef : 'Status' ,
127
+ matHeaderCellDef : 'Status' ,
128
+ value : new StatusValue ( {
129
+ valueFn : parseStatus ,
130
+ } ) ,
131
+ sort : true ,
132
+ } ,
133
+ {
134
+ matColumnDef : 'name' ,
135
+ matHeaderCellDef : 'Trial name' ,
136
+ value : new PropertyValue ( {
137
+ field : lowerCase ( component . displayedColumns [ 1 ] ) ,
138
+ isLink : true ,
139
+ } ) ,
140
+ sort : true ,
141
+ } ,
142
+ {
143
+ matColumnDef : 'Validation loss' ,
144
+ matHeaderCellDef : 'Validation loss' ,
145
+ value : new PropertyValue ( {
146
+ field : lowerCase ( component . displayedColumns [ 2 ] ) ,
147
+ } ) ,
148
+ sort : true ,
149
+ } ,
150
+ {
151
+ matColumnDef : 'Lr' ,
152
+ matHeaderCellDef : 'Lr' ,
153
+ value : new PropertyValue ( {
154
+ field : lowerCase ( component . displayedColumns [ 3 ] ) ,
155
+ } ) ,
156
+ sort : true ,
157
+ } ,
158
+ {
159
+ matColumnDef : 'Batch size' ,
160
+ matHeaderCellDef : 'Batch size' ,
161
+ value : new PropertyValue ( {
162
+ field : lowerCase ( component . displayedColumns [ 4 ] ) ,
163
+ } ) ,
164
+ sort : true ,
165
+ } ,
166
+ {
167
+ matColumnDef : 'Embed dim' ,
168
+ matHeaderCellDef : 'Embed dim' ,
169
+ value : new PropertyValue ( {
170
+ field : lowerCase ( component . displayedColumns [ 5 ] ) ,
171
+ } ) ,
172
+ sort : true ,
173
+ } ,
174
+ {
175
+ matColumnDef : 'Dropout' ,
176
+ matHeaderCellDef : 'Dropout' ,
177
+ value : new PropertyValue ( {
178
+ field : lowerCase ( component . displayedColumns [ 6 ] ) ,
179
+ } ) ,
180
+ sort : true ,
181
+ } ,
182
+ {
183
+ matColumnDef : 'Sp dropout' ,
184
+ matHeaderCellDef : 'Sp dropout' ,
185
+ value : new PropertyValue ( {
186
+ field : lowerCase ( component . displayedColumns [ 7 ] ) ,
187
+ } ) ,
188
+ sort : true ,
189
+ } ,
190
+ {
191
+ matHeaderCellDef : '' ,
192
+ matColumnDef : 'actions' ,
193
+ value : new ComponentValue ( {
194
+ component : KfpRunComponent ,
195
+ } ) ,
196
+ } ,
197
+ ] ,
198
+ } ) ;
46
199
} ) ;
47
200
} ) ;
0 commit comments