Skip to content

Commit ffae70c

Browse files
change(ml): Drop the feature to publish from an AutoML Model (#1974)
* Deprecating the feature to publish from an AutoML Model * Empty-Commit to trigger CI --------- Co-authored-by: Lahiru Maramba <[email protected]>
1 parent e7c4258 commit ffae70c

8 files changed

+5
-201
lines changed

etc/firebase-admin.api.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@ export function machineLearning(app?: App): machineLearning.MachineLearning;
320320

321321
// @public (undocumented)
322322
export namespace machineLearning {
323-
// Warning: (ae-forgotten-export) The symbol "AutoMLTfliteModelOptions" needs to be exported by the entry point default-namespace.d.ts
324-
//
325-
// @deprecated
326-
export type AutoMLTfliteModelOptions = AutoMLTfliteModelOptions;
327323
// Warning: (ae-forgotten-export) The symbol "GcsTfliteModelOptions" needs to be exported by the entry point default-namespace.d.ts
328324
export type GcsTfliteModelOptions = GcsTfliteModelOptions;
329325
// Warning: (ae-forgotten-export) The symbol "ListModelsOptions" needs to be exported by the entry point default-namespace.d.ts

etc/firebase-admin.machine-learning.api.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88

99
import { Agent } from 'http';
1010

11-
// @public @deprecated (undocumented)
12-
export interface AutoMLTfliteModelOptions extends ModelOptionsBase {
13-
// (undocumented)
14-
tfliteModel: {
15-
automlModel: string;
16-
};
17-
}
18-
1911
// @public (undocumented)
2012
export interface GcsTfliteModelOptions extends ModelOptionsBase {
2113
// (undocumented)
@@ -74,7 +66,7 @@ export class Model {
7466
}
7567

7668
// @public (undocumented)
77-
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions | AutoMLTfliteModelOptions;
69+
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions;
7870

7971
// @public
8072
export interface ModelOptionsBase {
@@ -86,8 +78,6 @@ export interface ModelOptionsBase {
8678

8779
// @public
8880
export interface TFLiteModel {
89-
// @deprecated
90-
readonly automlModel?: string;
9181
readonly gcsTfliteUri?: string;
9282
readonly sizeBytes: number;
9383
}

src/machine-learning/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export {
3131
TFLiteModel,
3232
} from './machine-learning';
3333
export {
34-
AutoMLTfliteModelOptions,
3534
GcsTfliteModelOptions,
3635
ListModelsOptions,
3736
ModelOptions,

src/machine-learning/machine-learning-api-client.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,7 @@ export interface GcsTfliteModelOptions extends ModelOptionsBase {
3838
};
3939
}
4040

41-
/**
42-
* @deprecated AutoMLTfliteModelOptions will be removed in the next major version.
43-
*/
44-
export interface AutoMLTfliteModelOptions extends ModelOptionsBase {
45-
tfliteModel: {
46-
automlModel: string;
47-
};
48-
}
49-
50-
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions | AutoMLTfliteModelOptions;
41+
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions;
5142

5243
/**
5344
* Interface representing options for listing Models.
@@ -108,7 +99,6 @@ export interface ModelContent {
10899
};
109100
readonly tfliteModel?: {
110101
readonly gcsTfliteUri?: string;
111-
readonly automlModel?: string;
112102

113103
readonly sizeBytes: number;
114104
};

src/machine-learning/machine-learning-namespace.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
TFLiteModel as TTFLiteModel,
2323
} from './machine-learning';
2424
import {
25-
AutoMLTfliteModelOptions as TAutoMLTfliteModelOptions,
2625
GcsTfliteModelOptions as TGcsTfliteModelOptions,
2726
ListModelsOptions as TListModelsOptions,
2827
ModelOptions as TModelOptions,
@@ -80,13 +79,6 @@ export namespace machineLearning {
8079
*/
8180
export type TFLiteModel = TTFLiteModel;
8281

83-
/**
84-
* Type alias to {@link firebase-admin.machine-learning#AutoMLTfliteModelOptions}.
85-
*
86-
* @deprecated AutoMLTfliteModelOptions will be removed in the next major version.
87-
*/
88-
export type AutoMLTfliteModelOptions = TAutoMLTfliteModelOptions;
89-
9082
/**
9183
* Type alias to {@link firebase-admin.machine-learning#GcsTfliteModelOptions}.
9284
*/

src/machine-learning/machine-learning.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,13 @@ export interface ListModelsResult {
4040

4141
/**
4242
* A TensorFlow Lite Model output object
43-
*
44-
* One of either the `gcsTfliteUri` or `automlModel` properties will be
45-
* defined.
4643
*/
4744
export interface TFLiteModel {
4845
/** The size of the model. */
4946
readonly sizeBytes: number;
5047

5148
/** The URI from which the model was originally provided to Firebase. */
5249
readonly gcsTfliteUri?: string;
53-
/**
54-
* The AutoML model reference from which the model was originally provided
55-
* to Firebase.
56-
*
57-
* @deprecated AutoML model support will be removed in the next major version.
58-
*/
59-
readonly automlModel?: string;
6050
}
6151

6252
/**
@@ -400,11 +390,9 @@ export class Model {
400390
}
401391
const tmpModel = deepCopy(model);
402392

403-
// If tflite Model is specified, it must have a source consisting of
404-
// oneof {gcsTfliteUri, automlModel}
393+
// If tflite Model is specified, it must have a source of {gcsTfliteUri}
405394
if (model.tfliteModel &&
406-
!validator.isNonEmptyString(model.tfliteModel.gcsTfliteUri) &&
407-
!validator.isNonEmptyString(model.tfliteModel.automlModel)) {
395+
!validator.isNonEmptyString(model.tfliteModel.gcsTfliteUri)) {
408396
// If we have some other source, ignore the whole tfliteModel.
409397
delete (tmpModel as any).tfliteModel;
410398
}

test/integration/machine-learning.spec.ts

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
import path = require('path');
1919
import * as chai from 'chai';
20-
import { projectId } from './setup';
2120
import { Bucket } from '@google-cloud/storage';
2221
import { getStorage } from '../../lib/storage/index';
2322
import {
24-
AutoMLTfliteModelOptions, GcsTfliteModelOptions, Model, ModelOptions, getMachineLearning,
23+
GcsTfliteModelOptions, Model, ModelOptions, getMachineLearning,
2524
} from '../../lib/machine-learning/index';
2625

2726
const expect = chai.expect;
@@ -104,31 +103,6 @@ describe('admin.machineLearning', () => {
104103
});
105104
});
106105

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-
132106
it('creates a new Model with invalid ModelFormat', () => {
133107
// Upload a file to default gcs bucket
134108
const modelOptions: ModelOptions = {
@@ -233,33 +207,6 @@ describe('admin.machineLearning', () => {
233207
});
234208
});
235209

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-
263210
it('can update more than 1 field', () => {
264211
const DISPLAY_NAME = 'node-integ-test-update-3b';
265212
const TAGS = ['node-integ-tag-1', 'node-integ-tag-2'];
@@ -540,8 +487,6 @@ function verifyModel(model: Model, expectedOptions: ModelOptions): void {
540487
}
541488
if ((expectedOptions as GcsTfliteModelOptions).tfliteModel?.gcsTfliteUri !== undefined) {
542489
verifyGcsTfliteModel(model, (expectedOptions as GcsTfliteModelOptions));
543-
} else if ((expectedOptions as AutoMLTfliteModelOptions).tfliteModel?.automlModel !== undefined) {
544-
verifyAutomlTfliteModel(model, (expectedOptions as AutoMLTfliteModelOptions));
545490
} else {
546491
expect(model.validationError).to.equal('No model file has been uploaded.');
547492
}
@@ -558,35 +503,3 @@ function verifyGcsTfliteModel(model: Model, expectedOptions: GcsTfliteModelOptio
558503
expect(model.validationError).to.be.undefined;
559504
}
560505
}
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-
}

test/unit/machine-learning/machine-learning-api-client.spec.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,6 @@ describe('MachineLearningApiClient', () => {
6464
sizeBytes: 2220022,
6565
},
6666
};
67-
const MODEL_RESPONSE_AUTOML = {
68-
name: 'projects/test-project/models/3456789',
69-
createTime: '2020-07-15T18:12:25.123987Z',
70-
updateTime: '2020-07-15T19:15:32.965435Z',
71-
etag: 'etag345',
72-
modelHash: 'modelHash345',
73-
displayName: 'model_automl',
74-
tags: ['tag_automl'],
75-
state: { published: true },
76-
tfliteModel: {
77-
automlModel: 'projects/65432/models/ICN123',
78-
sizeBytes: 3330033,
79-
},
80-
};
8167

8268
const PROJECT_ID = 'test-project';
8369
const PROJECT_NUMBER = '1234567';
@@ -105,10 +91,6 @@ describe('MachineLearningApiClient', () => {
10591
},
10692
done: false,
10793
};
108-
const OPERATION_AUTOML_RESPONSE = {
109-
done: true,
110-
response: MODEL_RESPONSE_AUTOML,
111-
};
11294
const LOCKED_MODEL_RESPONSE = {
11395
name: 'projects/test-project/models/1234567',
11496
createTime: '2020-02-07T23:45:23.288047Z',
@@ -179,12 +161,6 @@ describe('MachineLearningApiClient', () => {
179161
gcsTfliteUri: 'gcsUri1',
180162
},
181163
};
182-
const AUTOML_OPTIONS: ModelOptions = {
183-
displayName: 'name3',
184-
tfliteModel: {
185-
automlModel: 'automlModel',
186-
},
187-
};
188164

189165
const invalidContent: any[] = [null, undefined, {}, { tags: [] }];
190166
invalidContent.forEach((content) => {
@@ -236,19 +212,6 @@ describe('MachineLearningApiClient', () => {
236212
});
237213
});
238214

239-
it('should accept AutoML options', () => {
240-
const stub = sinon
241-
.stub(HttpClient.prototype, 'send')
242-
.resolves(utils.responseFrom(OPERATION_AUTOML_RESPONSE));
243-
stubs.push(stub);
244-
return apiClient.createModel(AUTOML_OPTIONS)
245-
.then((resp) => {
246-
expect(resp.done).to.be.true;
247-
expect(resp.name).to.be.undefined;
248-
expect(resp.response).to.deep.equal(MODEL_RESPONSE_AUTOML);
249-
});
250-
});
251-
252215
it('should resolve with error when the operation fails', () => {
253216
const stub = sinon
254217
.stub(HttpClient.prototype, 'send')
@@ -302,20 +265,12 @@ describe('MachineLearningApiClient', () => {
302265
gcsTfliteUri: 'gcsUri1',
303266
},
304267
};
305-
const AUTOML_OPTIONS: ModelOptions = {
306-
displayName: 'name3',
307-
tfliteModel: {
308-
automlModel: 'automlModel',
309-
},
310-
};
311268

312269
const NAME_ONLY_MASK_LIST = ['displayName'];
313270
const GCS_MASK_LIST = ['displayName', 'tfliteModel.gcsTfliteUri'];
314-
const AUTOML_MASK_LIST = ['displayName', 'tfliteModel.automlModel'];
315271

316272
const NAME_ONLY_UPDATE_MASK_STRING = 'updateMask=displayName';
317273
const GCS_UPDATE_MASK_STRING = 'updateMask=displayName,tfliteModel.gcsTfliteUri';
318-
const AUTOML_UPDATE_MASK_STRING = 'updateMask=displayName,tfliteModel.automlModel';
319274

320275
const invalidOptions: any[] = [null, undefined];
321276
invalidOptions.forEach((option) => {
@@ -385,25 +340,6 @@ describe('MachineLearningApiClient', () => {
385340
});
386341
});
387342

388-
it('should resolve with the updated AutoML resource on success', () => {
389-
const stub = sinon
390-
.stub(HttpClient.prototype, 'send')
391-
.resolves(utils.responseFrom(OPERATION_SUCCESS_RESPONSE));
392-
stubs.push(stub);
393-
return apiClient.updateModel(MODEL_ID, AUTOML_OPTIONS, AUTOML_MASK_LIST)
394-
.then((resp) => {
395-
expect(resp.done).to.be.true;
396-
expect(resp.name).to.be.undefined;
397-
expect(resp.response).to.deep.equal(MODEL_RESPONSE);
398-
expect(stub).to.have.been.calledOnce.and.calledWith({
399-
method: 'PATCH',
400-
headers: EXPECTED_HEADERS,
401-
url: `${BASE_URL}/projects/test-project/models/${MODEL_ID}?${AUTOML_UPDATE_MASK_STRING}`,
402-
data: AUTOML_OPTIONS,
403-
});
404-
});
405-
});
406-
407343
it('should resolve with error when the operation fails', () => {
408344
const stub = sinon
409345
.stub(HttpClient.prototype, 'send')

0 commit comments

Comments
 (0)