From 4654a484857b9d76827bdbd0125d92d6ee0ad80b Mon Sep 17 00:00:00 2001 From: Kevin Cheung Date: Thu, 20 Aug 2020 13:41:54 -0700 Subject: [PATCH 1/4] Update docstrings --- src/machine-learning/machine-learning.ts | 42 ++++++++++++++++-------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/machine-learning/machine-learning.ts b/src/machine-learning/machine-learning.ts index 7b7678e4d5..67f3d8fab3 100644 --- a/src/machine-learning/machine-learning.ts +++ b/src/machine-learning/machine-learning.ts @@ -83,7 +83,7 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Creates a model in Firebase ML. + * Creates a model in the current Firebase project. * * @param {ModelOptions} model The model to create. * @@ -97,9 +97,9 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Updates a model in Firebase ML. + * Updates a model's metadata or model file. * - * @param {string} modelId The id of the model to update. + * @param {string} modelId The ID of the model to update. * @param {ModelOptions} model The model fields to update. * * @return {Promise} A Promise fulfilled with the updated model. @@ -113,9 +113,11 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Publishes a model in Firebase ML. + * Publishes a Firebase ML model. * - * @param {string} modelId The id of the model to publish. + * A published model can be downloaded to client apps. + * + * @param {string} modelId The ID of the model to publish. * * @return {Promise} A Promise fulfilled with the published model. */ @@ -124,9 +126,9 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Unpublishes a model in Firebase ML. + * Unpublishes a Firebase ML model. * - * @param {string} modelId The id of the model to unpublish. + * @param {string} modelId The ID of the model to unpublish. * * @return {Promise} A Promise fulfilled with the unpublished model. */ @@ -135,11 +137,11 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Gets a model from Firebase ML. + * Gets the model specified by the given ID. * - * @param {string} modelId The id of the model to get. + * @param {string} modelId The ID of the model to get. * - * @return {Promise} A Promise fulfilled with the unpublished model. + * @return {Promise} A Promise fulfilled with the model. */ public getModel(modelId: string): Promise { return this.client.getModel(modelId) @@ -147,7 +149,7 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Lists models from Firebase ML. + * Lists the current project's models. * * @param {ListModelsOptions} options The listing options. * @@ -177,9 +179,9 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Deletes a model from Firebase ML. + * Deletes a model from the current project. * - * @param {string} modelId The id of the model to delete. + * @param {string} modelId The ID of the model to delete. */ public deleteModel(modelId: string): Promise { return this.client.deleteModel(modelId); @@ -244,42 +246,53 @@ export class Model { this.client = client; } + /** The ID of the model. */ get modelId(): string { return extractModelId(this.model.name); } + /** The model's display name. This is the value you use to refer + to the model in the iOS and Android libraries. */ get displayName(): string { return this.model.displayName!; } + /** The model's tags. */ get tags(): string[] { return this.model.tags || []; } + /** The date and time the model was created (added to the project). */ get createTime(): string { return new Date(this.model.createTime).toUTCString(); } + /** The date and time the model was last updated. */ get updateTime(): string { return new Date(this.model.updateTime).toUTCString(); } + /** The validation error message, if the model isn't valid. */ get validationError(): string | undefined { return this.model.state?.validationError?.message; } + /** True if the model is published and available to download. */ get published(): boolean { return this.model.state?.published || false; } + /** The model's ETag. */ get etag(): string { return this.model.etag; } + /** The SHA256 hash of the model file. */ get modelHash(): string | undefined { return this.model.modelHash; } + /** The model's tflite file. */ get tfliteModel(): TFLiteModel | undefined { // Make a copy so people can't directly modify the private this.model object. return deepCopy(this.model.tfliteModel); @@ -376,6 +389,9 @@ export class Model { /** * A TFLite Model output object + * + * One of either the `gcsTfliteUri` or `automlModel` properties will be defined + * and non-empty. */ export interface TFLiteModel { readonly sizeBytes: number; From eb3b7a0fa7c07b99b1fff260a9278352a78f7eee Mon Sep 17 00:00:00 2001 From: Kevin Cheung Date: Thu, 20 Aug 2020 15:18:15 -0700 Subject: [PATCH 2/4] Update docstrings in d.ts --- src/index.d.ts | 31 +++++++++++------ src/machine-learning/machine-learning.ts | 44 ++++++++---------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index 5dc573c050..83e8149df1 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1231,7 +1231,10 @@ declare namespace admin.machineLearning { /** The URI from which the model was originally provided to Firebase. */ readonly gcsTfliteUri?: string; - /** The AutoML URI from which the model was originally provided to Firebase. */ + /** + * The AutoML model reference from which the model was originally provided + * to Firebase. + */ readonly automlModel?: string; } @@ -1242,10 +1245,16 @@ declare namespace admin.machineLearning { /** The ID of the model. */ readonly modelId: string; - /** The model's name. This is the name you use from your app to load the model. */ + /** + * The model's name. This is the name you use from your app to load the + * model. + */ readonly displayName: string; - /** The model's tags. */ + /** + * The model's tags, which can be used to group or filter models in list + * operations. + */ readonly tags?: string[]; /** The timestamp of the model's creation. */ @@ -1352,7 +1361,7 @@ declare namespace admin.machineLearning { app: admin.app.App; /** - * Creates a model in Firebase ML. + * Creates a model in the current Firebase project. * * @param {ModelOptions} model The model to create. * @@ -1361,7 +1370,7 @@ declare namespace admin.machineLearning { createModel(model: ModelOptions): Promise; /** - * Updates a model in Firebase ML. + * Updates a model's metadata or model file. * * @param {string} modelId The ID of the model to update. * @param {ModelOptions} model The model fields to update. @@ -1371,7 +1380,9 @@ declare namespace admin.machineLearning { updateModel(modelId: string, model: ModelOptions): Promise; /** - * Publishes a model in Firebase ML. + * Publishes a Firebase ML model. + * + * A published model can be downloaded to client apps. * * @param {string} modelId The ID of the model to publish. * @@ -1380,7 +1391,7 @@ declare namespace admin.machineLearning { publishModel(modelId: string): Promise; /** - * Unpublishes a model in Firebase ML. + * Unpublishes a Firebase ML model. * * @param {string} modelId The ID of the model to unpublish. * @@ -1389,7 +1400,7 @@ declare namespace admin.machineLearning { unpublishModel(modelId: string): Promise; /** - * Gets a model from Firebase ML. + * Gets the model specified by the given ID. * * @param {string} modelId The ID of the model to get. * @@ -1398,7 +1409,7 @@ declare namespace admin.machineLearning { getModel(modelId: string): Promise; /** - * Lists models from Firebase ML. + * Lists the current project's models. * * @param {ListModelsOptions} options The listing options. * @@ -1410,7 +1421,7 @@ declare namespace admin.machineLearning { listModels(options?: ListModelsOptions): Promise; /** - * Deletes a model from Firebase ML. + * Deletes a model from the current project. * * @param {string} modelId The ID of the model to delete. */ diff --git a/src/machine-learning/machine-learning.ts b/src/machine-learning/machine-learning.ts index 67f3d8fab3..4917773201 100644 --- a/src/machine-learning/machine-learning.ts +++ b/src/machine-learning/machine-learning.ts @@ -83,7 +83,7 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Creates a model in the current Firebase project. + * Creates a model in Firebase ML. * * @param {ModelOptions} model The model to create. * @@ -97,9 +97,9 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Updates a model's metadata or model file. + * Updates a model in Firebase ML. * - * @param {string} modelId The ID of the model to update. + * @param {string} modelId The id of the model to update. * @param {ModelOptions} model The model fields to update. * * @return {Promise} A Promise fulfilled with the updated model. @@ -113,11 +113,9 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Publishes a Firebase ML model. + * Publishes a model in Firebase ML. * - * A published model can be downloaded to client apps. - * - * @param {string} modelId The ID of the model to publish. + * @param {string} modelId The id of the model to publish. * * @return {Promise} A Promise fulfilled with the published model. */ @@ -126,9 +124,9 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Unpublishes a Firebase ML model. + * Unpublishes a model in Firebase ML. * - * @param {string} modelId The ID of the model to unpublish. + * @param {string} modelId The id of the model to unpublish. * * @return {Promise} A Promise fulfilled with the unpublished model. */ @@ -137,11 +135,11 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Gets the model specified by the given ID. + * Gets a model from Firebase ML. * - * @param {string} modelId The ID of the model to get. + * @param {string} modelId The id of the model to get. * - * @return {Promise} A Promise fulfilled with the model. + * @return {Promise} A Promise fulfilled with the unpublished model. */ public getModel(modelId: string): Promise { return this.client.getModel(modelId) @@ -149,7 +147,7 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Lists the current project's models. + * Lists models from Firebase ML. * * @param {ListModelsOptions} options The listing options. * @@ -179,9 +177,9 @@ export class MachineLearning implements FirebaseServiceInterface { } /** - * Deletes a model from the current project. + * Deletes a model from Firebase ML. * - * @param {string} modelId The ID of the model to delete. + * @param {string} modelId The id of the model to delete. */ public deleteModel(modelId: string): Promise { return this.client.deleteModel(modelId); @@ -246,53 +244,42 @@ export class Model { this.client = client; } - /** The ID of the model. */ get modelId(): string { return extractModelId(this.model.name); } - /** The model's display name. This is the value you use to refer - to the model in the iOS and Android libraries. */ get displayName(): string { return this.model.displayName!; } - /** The model's tags. */ get tags(): string[] { return this.model.tags || []; } - /** The date and time the model was created (added to the project). */ get createTime(): string { return new Date(this.model.createTime).toUTCString(); } - /** The date and time the model was last updated. */ get updateTime(): string { return new Date(this.model.updateTime).toUTCString(); } - /** The validation error message, if the model isn't valid. */ get validationError(): string | undefined { return this.model.state?.validationError?.message; } - /** True if the model is published and available to download. */ get published(): boolean { return this.model.state?.published || false; } - /** The model's ETag. */ get etag(): string { return this.model.etag; } - /** The SHA256 hash of the model file. */ get modelHash(): string | undefined { return this.model.modelHash; } - /** The model's tflite file. */ get tfliteModel(): TFLiteModel | undefined { // Make a copy so people can't directly modify the private this.model object. return deepCopy(this.model.tfliteModel); @@ -389,9 +376,6 @@ export class Model { /** * A TFLite Model output object - * - * One of either the `gcsTfliteUri` or `automlModel` properties will be defined - * and non-empty. */ export interface TFLiteModel { readonly sizeBytes: number; @@ -403,4 +387,4 @@ export interface TFLiteModel { function extractModelId(resourceName: string): string { return resourceName.split('/').pop()!; -} +} \ No newline at end of file From 8d257541f7813199143038f502a16db09532ce00 Mon Sep 17 00:00:00 2001 From: Kevin Cheung Date: Thu, 20 Aug 2020 15:19:42 -0700 Subject: [PATCH 3/4] newline --- src/machine-learning/machine-learning.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine-learning/machine-learning.ts b/src/machine-learning/machine-learning.ts index 4917773201..7b7678e4d5 100644 --- a/src/machine-learning/machine-learning.ts +++ b/src/machine-learning/machine-learning.ts @@ -387,4 +387,4 @@ export interface TFLiteModel { function extractModelId(resourceName: string): string { return resourceName.split('/').pop()!; -} \ No newline at end of file +} From fa5c0ce20f4a602602e3217a5b405d5cb4790f2d Mon Sep 17 00:00:00 2001 From: Kevin Cheung Date: Thu, 20 Aug 2020 17:03:18 -0700 Subject: [PATCH 4/4] update --- src/index.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 83e8149df1..1b9e65636b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1224,6 +1224,9 @@ declare namespace admin.machineLearning { /** * A TensorFlow Lite Model output object + * + * One of either the `gcsTfliteUri` or `automlModel` properties will be + * defined. */ interface TFLiteModel { /** The size of the model. */ @@ -1323,7 +1326,7 @@ declare namespace admin.machineLearning { * state.published = true * ``` * - * See https://firebase.google.com/docs/ml-kit/manage-hosted-models#list_your_projects_models + * See https://firebase.google.com/docs/ml/manage-hosted-models#list_your_projects_models */ filter?: string;