@@ -17,18 +17,22 @@ describe('pickAndModifyParams', () => {
1717 mockedQuickPickManyValues . mockResolvedValueOnce ( undefined )
1818
1919 const paramsToQueue = await pickAndModifyParams ( [
20- { path : 'params.yaml:learning_rate' , value : 2e-12 }
20+ { isString : false , path : 'params.yaml:learning_rate' , value : 2e-12 }
2121 ] )
2222
2323 expect ( paramsToQueue ) . toBeUndefined ( )
2424 expect ( mockedGetInput ) . not . toHaveBeenCalled ( )
2525 } )
2626
2727 it ( 'should return early if the user exits from the input box' , async ( ) => {
28- const unchanged = { path : 'params.yaml:learning_rate' , value : 2e-12 }
28+ const unchanged = {
29+ isString : false ,
30+ path : 'params.yaml:learning_rate' ,
31+ value : 2e-12
32+ }
2933 const initialUserResponse = [
30- { path : 'params.yaml:dropout' , value : 0.15 } ,
31- { path : 'params.yaml:process.threshold' , value : 0.86 }
34+ { isString : false , path : 'params.yaml:dropout' , value : 0.15 } ,
35+ { isString : false , path : 'params.yaml:process.threshold' , value : 0.86 }
3236 ]
3337 mockedQuickPickManyValues . mockResolvedValueOnce ( initialUserResponse )
3438 const firstInput = '0.16'
@@ -45,31 +49,58 @@ describe('pickAndModifyParams', () => {
4549 } )
4650
4751 it ( 'should convert any selected params into the required format' , async ( ) => {
48- const unchanged = { path : 'params.yaml:learning_rate' , value : 2e-12 }
52+ const unchanged = {
53+ isString : false ,
54+ path : 'params.yaml:learning_rate' ,
55+ value : 2e-12
56+ }
57+
4958 const initialUserResponse = [
50- { path : 'params.yaml:dropout' , value : 0.15 } ,
51- { path : 'params.yaml:process.threshold' , value : 0.86 } ,
52- { path : 'params.yaml:code_names' , value : [ 0 , 1 , 2 ] }
59+ { isString : false , path : 'params.yaml:dropout' , value : 0.15 } ,
60+ { isString : false , path : 'params.yaml:process.threshold' , value : 0.86 } ,
61+ { isString : false , path : 'params.yaml:code_names' , value : [ 0 , 1 , 2 ] } ,
62+ {
63+ isString : true ,
64+ path : 'params.yaml:transforms' ,
65+ value : '[Pipeline: PILBase.create, Pipeline: partial -> PILBase.create]'
66+ }
5367 ]
5468 mockedQuickPickManyValues . mockResolvedValueOnce ( initialUserResponse )
5569 const firstInput = '0.16'
5670 const secondInput = '0.87'
5771 const thirdInput = '[0,1,3]'
72+ const fourthInput = '[Pipeline: PILBase.create]'
5873 mockedGetInput . mockResolvedValueOnce ( firstInput )
5974 mockedGetInput . mockResolvedValueOnce ( secondInput )
6075 mockedGetInput . mockResolvedValueOnce ( thirdInput )
76+ mockedGetInput . mockResolvedValueOnce ( fourthInput )
6177
6278 const paramsToQueue = await pickAndModifyParams ( [
6379 unchanged ,
6480 ...initialUserResponse
6581 ] )
6682
67- expect ( mockedGetInput ) . toHaveBeenCalledTimes ( 3 )
83+ expect ( mockedGetInput ) . toHaveBeenCalledTimes ( 4 )
84+ expect ( mockedGetInput ) . toHaveBeenCalledWith (
85+ 'Enter a Value for params.yaml:dropout' ,
86+ '0.15'
87+ )
88+
89+ expect ( mockedGetInput ) . toHaveBeenCalledWith (
90+ 'Enter a Value for params.yaml:process.threshold' ,
91+ '0.86'
92+ )
93+
6894 expect ( mockedGetInput ) . toHaveBeenCalledWith (
6995 'Enter a Value for params.yaml:code_names' ,
7096 '[0,1,2]'
7197 )
7298
99+ expect ( mockedGetInput ) . toHaveBeenCalledWith (
100+ 'Enter a Value for params.yaml:transforms' ,
101+ '[Pipeline: PILBase.create, Pipeline: partial -> PILBase.create]'
102+ )
103+
73104 expect ( paramsToQueue ) . toStrictEqual ( [
74105 '-S' ,
75106 `params.yaml:dropout=${ firstInput } ` ,
@@ -78,8 +109,57 @@ describe('pickAndModifyParams', () => {
78109 '-S' ,
79110 `params.yaml:code_names=${ thirdInput } ` ,
80111 '-S' ,
112+ `params.yaml:transforms='${ fourthInput } '` ,
113+ '-S' ,
81114 [ unchanged . path , unchanged . value ] . join ( '=' )
82115 ] )
83- expect ( mockedGetInput ) . toHaveBeenCalledTimes ( 3 )
116+ } )
117+
118+ it ( 'should convert any unselected params into the required format' , async ( ) => {
119+ const numericValue = {
120+ isString : false ,
121+ path : 'params.yaml:learning_rate' ,
122+ value : 2e-12
123+ }
124+ const stringArrayValue = {
125+ isString : true ,
126+ path : 'params.yaml:transforms' ,
127+ value : '[Pipeline: PILBase.create, Pipeline: partial -> PILBase.create]'
128+ }
129+
130+ const actualArrayValue = {
131+ isString : false ,
132+ path : 'params.yaml:code_names' ,
133+ value : [ 0 , 1 , 2 ]
134+ }
135+
136+ const unchanged = [ numericValue , stringArrayValue , actualArrayValue ]
137+ const initialUserResponse = {
138+ isString : false ,
139+ path : 'params.yaml:dropout' ,
140+ value : 0.15
141+ }
142+
143+ mockedQuickPickManyValues . mockResolvedValueOnce ( [ initialUserResponse ] )
144+ const firstInput = '0.16'
145+ mockedGetInput . mockResolvedValueOnce ( firstInput )
146+
147+ const paramsToQueue = await pickAndModifyParams ( [
148+ ...unchanged ,
149+ initialUserResponse
150+ ] )
151+
152+ expect ( mockedGetInput ) . toHaveBeenCalledTimes ( 1 )
153+
154+ expect ( paramsToQueue ) . toStrictEqual ( [
155+ '-S' ,
156+ `params.yaml:dropout=${ firstInput } ` ,
157+ '-S' ,
158+ [ numericValue . path , numericValue . value ] . join ( '=' ) ,
159+ '-S' ,
160+ [ stringArrayValue . path , `'${ stringArrayValue . value } '` ] . join ( '=' ) ,
161+ '-S' ,
162+ [ actualArrayValue . path , JSON . stringify ( actualArrayValue . value ) ] . join ( '=' )
163+ ] )
84164 } )
85165} )
0 commit comments