17
17
18
18
import path = require( 'path' ) ;
19
19
import * as chai from 'chai' ;
20
- import { projectId } from './setup' ;
21
20
import { Bucket } from '@google-cloud/storage' ;
22
21
import { getStorage } from '../../lib/storage/index' ;
23
22
import {
24
- AutoMLTfliteModelOptions , GcsTfliteModelOptions , Model , ModelOptions , getMachineLearning ,
23
+ GcsTfliteModelOptions , Model , ModelOptions , getMachineLearning ,
25
24
} from '../../lib/machine-learning/index' ;
26
25
27
26
const expect = chai . expect ;
@@ -104,31 +103,6 @@ describe('admin.machineLearning', () => {
104
103
} ) ;
105
104
} ) ;
106
105
107
- it ( 'creates a new Model with valid AutoML TFLite ModelFormat' , function ( ) {
108
- // AutoML models require verification. This takes between 20 and 60 seconds
109
- this . timeout ( 60000 ) ; // Allow up to 60 seconds for this test.
110
- return getAutoMLModelReference ( )
111
- . then ( ( automlRef : string ) => {
112
- if ( ! automlRef ) {
113
- this . skip ( ) ;
114
- return ;
115
- }
116
- const modelOptions : ModelOptions = {
117
- displayName : 'node-integ-test-create-automl' ,
118
- tags : [ 'tagAutoml' ] ,
119
- tfliteModel : { automlModel : automlRef }
120
- } ;
121
- return getMachineLearning ( ) . createModel ( modelOptions )
122
- . then ( ( model ) => {
123
- return model . waitForUnlocked ( 55000 )
124
- . then ( ( ) => {
125
- scheduleForDelete ( model ) ;
126
- verifyModel ( model , modelOptions ) ;
127
- } ) ;
128
- } ) ;
129
- } ) ;
130
- } ) ;
131
-
132
106
it ( 'creates a new Model with invalid ModelFormat' , ( ) => {
133
107
// Upload a file to default gcs bucket
134
108
const modelOptions : ModelOptions = {
@@ -233,33 +207,6 @@ describe('admin.machineLearning', () => {
233
207
} ) ;
234
208
} ) ;
235
209
236
- it ( 'updates the automl model' , function ( ) {
237
- // AutoML models require verification. This takes between 20 and 60 seconds
238
- this . timeout ( 60000 ) ; // Allow up to 60 seconds for this test.
239
- return createTemporaryModel ( {
240
- displayName : 'node-integ-test-update-automl'
241
- } ) . then ( ( model ) => {
242
-
243
- return getAutoMLModelReference ( )
244
- . then ( ( automlRef : string ) => {
245
- if ( ! automlRef ) {
246
- this . skip ( ) ;
247
- return ;
248
- }
249
- const modelOptions : ModelOptions = {
250
- tfliteModel : { automlModel : automlRef } ,
251
- } ;
252
- return getMachineLearning ( ) . updateModel ( model . modelId , modelOptions )
253
- . then ( ( updatedModel ) => {
254
- return updatedModel . waitForUnlocked ( 55000 )
255
- . then ( ( ) => {
256
- verifyModel ( updatedModel , modelOptions ) ;
257
- } ) ;
258
- } ) ;
259
- } ) ;
260
- } ) ;
261
- } ) ;
262
-
263
210
it ( 'can update more than 1 field' , ( ) => {
264
211
const DISPLAY_NAME = 'node-integ-test-update-3b' ;
265
212
const TAGS = [ 'node-integ-tag-1' , 'node-integ-tag-2' ] ;
@@ -540,8 +487,6 @@ function verifyModel(model: Model, expectedOptions: ModelOptions): void {
540
487
}
541
488
if ( ( expectedOptions as GcsTfliteModelOptions ) . tfliteModel ?. gcsTfliteUri !== undefined ) {
542
489
verifyGcsTfliteModel ( model , ( expectedOptions as GcsTfliteModelOptions ) ) ;
543
- } else if ( ( expectedOptions as AutoMLTfliteModelOptions ) . tfliteModel ?. automlModel !== undefined ) {
544
- verifyAutomlTfliteModel ( model , ( expectedOptions as AutoMLTfliteModelOptions ) ) ;
545
490
} else {
546
491
expect ( model . validationError ) . to . equal ( 'No model file has been uploaded.' ) ;
547
492
}
@@ -558,35 +503,3 @@ function verifyGcsTfliteModel(model: Model, expectedOptions: GcsTfliteModelOptio
558
503
expect ( model . validationError ) . to . be . undefined ;
559
504
}
560
505
}
561
-
562
- function verifyAutomlTfliteModel ( model : Model , expectedOptions : AutoMLTfliteModelOptions ) : void {
563
- const expectedAutomlReference = expectedOptions . tfliteModel . automlModel ;
564
- expect ( model . tfliteModel ! . automlModel ) . to . equal ( expectedAutomlReference ) ;
565
- expect ( model . validationError ) . to . be . undefined ;
566
- expect ( model . tfliteModel ! . sizeBytes ) . to . not . be . undefined ;
567
- expect ( model . modelHash ) . to . not . be . undefined ;
568
- }
569
-
570
- function getAutoMLModelReference ( ) : Promise < string > {
571
- let automl ;
572
- try {
573
- const { AutoMlClient } = require ( '@google-cloud/automl' ) . v1 ;
574
- automl = new AutoMlClient ( ) ;
575
- }
576
- catch ( error ) {
577
- // Returning an empty string will result in skipping the test.
578
- return Promise . resolve ( '' ) ;
579
- }
580
-
581
- const parent = automl . locationPath ( projectId , 'us-central1' ) ;
582
- return automl . listModels ( { parent, filter :'displayName=admin_sdk_integ_test1' } )
583
- . then ( ( [ models ] : [ any ] ) => {
584
- let modelRef = '' ;
585
- for ( const model of models ) {
586
- modelRef = model . name ;
587
- }
588
- return modelRef ;
589
- } )
590
- // Skip the test if anything goes wrong with listing the models.
591
- . catch ( ( ) => '' ) ;
592
- }
0 commit comments