@@ -25,59 +25,23 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2525
2626const BATCH_PREDICT_REGION_TAG = 'batch_predict' ;
2727const LOCATION = 'us-central1' ;
28- const MODEL_ID = 'TEN2238627664384491520 ' ;
28+ const MODEL_ID = 'TEN0000000000000000000 ' ;
2929const PREFIX = 'TEST_BATCH_PREDICT' ;
3030
3131describe ( 'Automl Batch Predict Test' , ( ) => {
3232 const client = new AutoMlClient ( ) ;
3333
34- before ( 'should verify the model is deployed' , async ( ) => {
35- const projectId = await client . getProjectId ( ) ;
36- const request = {
37- name : client . modelPath ( projectId , LOCATION , MODEL_ID ) ,
38- } ;
39-
40- const [ response ] = await client . getModel ( request ) ;
41- if ( response . deploymentState === 'UNDEPLOYED' ) {
42- const request = {
43- name : client . modelPath ( projectId , LOCATION , MODEL_ID ) ,
44- } ;
45-
46- const [ operation ] = await client . deployModel ( request ) ;
47-
48- // Wait for operation to complete.
49- await operation . promise ( ) ;
50- }
51- } ) ;
52-
5334 it ( 'should batch predict' , async ( ) => {
35+ // As batch prediction can take a long time, instead try to batch predict
36+ // on a nonexistent model and confirm that the model was not found, but
37+ // other elements of the request were valid.
5438 const projectId = await client . getProjectId ( ) ;
5539 const inputUri = `gs://${ projectId } -lcm/entity_extraction/input.jsonl` ;
56- const outputUri = `gs://${ projectId } -lcm/${ PREFIX } /` ;
40+ const outputUri = `gs://${ projectId } -lcm/TEST_BATCH_PREDICT /` ;
5741
58- const batchPredictOutput = execSync (
59- `node ${ BATCH_PREDICT_REGION_TAG } .js ${ projectId } ${ LOCATION } ${ MODEL_ID } ${ inputUri } ${ outputUri } `
60- ) ;
61- assert . match (
62- batchPredictOutput ,
63- / B a t c h P r e d i c t i o n r e s u l t s s a v e d t o C l o u d S t o r a g e b u c k e t /
64- ) ;
65- } ) ;
42+ const args = [ BATCH_PREDICT_REGION_TAG , projectId , LOCATION , MODEL_ID , inputUri , outputUri ] ;
43+ const output = cp . spawnSync ( 'node' , args , { encoding : 'utf8' } ) ;
6644
67- after ( 'delete created files' , async ( ) => {
68- const projectId = await client . getProjectId ( ) ;
69- const storageClient = new Storage ( ) ;
70- const options = {
71- prefix : PREFIX ,
72- } ;
73- const [ files ] = await storageClient
74- . bucket ( `gs://${ projectId } -lcm` )
75- . getFiles ( options ) ;
76- files . forEach ( file => {
77- storageClient
78- . bucket ( `gs://${ projectId } -lcm` )
79- . file ( file . name )
80- . delete ( ) ;
81- } ) ;
45+ assert . match ( output . stderr , / d o e s n o t e x i s t / ) ;
8246 } ) ;
8347} ) ;
0 commit comments