Skip to content

Update docstrings #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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. */
Expand Down Expand Up @@ -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.
*
Expand All @@ -1361,7 +1370,7 @@ declare namespace admin.machineLearning {
createModel(model: ModelOptions): Promise<Model>;

/**
* 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.
Expand All @@ -1371,7 +1380,9 @@ declare namespace admin.machineLearning {
updateModel(modelId: string, model: ModelOptions): Promise<Model>;

/**
* 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.
*
Expand All @@ -1380,7 +1391,7 @@ declare namespace admin.machineLearning {
publishModel(modelId: string): Promise<Model>;

/**
* Unpublishes a model in Firebase ML.
* Unpublishes a Firebase ML model.
*
* @param {string} modelId The ID of the model to unpublish.
*
Expand All @@ -1389,7 +1400,7 @@ declare namespace admin.machineLearning {
unpublishModel(modelId: string): Promise<Model>;

/**
* Gets a model from Firebase ML.
* Gets the model specified by the given ID.
*
* @param {string} modelId The ID of the model to get.
*
Expand All @@ -1398,7 +1409,7 @@ declare namespace admin.machineLearning {
getModel(modelId: string): Promise<Model>;

/**
* Lists models from Firebase ML.
* Lists the current project's models.
*
* @param {ListModelsOptions} options The listing options.
*
Expand All @@ -1410,7 +1421,7 @@ declare namespace admin.machineLearning {
listModels(options?: ListModelsOptions): Promise<ListModelsResult>;

/**
* Deletes a model from Firebase ML.
* Deletes a model from the current project.
*
* @param {string} modelId The ID of the model to delete.
*/
Expand Down
42 changes: 13 additions & 29 deletions src/machine-learning/machine-learning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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<Model>} A Promise fulfilled with the updated model.
Expand All @@ -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<Model>} A Promise fulfilled with the published model.
*/
Expand All @@ -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<Model>} A Promise fulfilled with the unpublished model.
*/
Expand All @@ -137,19 +135,19 @@ 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<Model>} A Promise fulfilled with the model.
* @return {Promise<Model>} A Promise fulfilled with the unpublished model.
*/
public getModel(modelId: string): Promise<Model> {
return this.client.getModel(modelId)
.then((modelResponse) => new Model(modelResponse, this.client));
}

/**
* Lists the current project's models.
* Lists models from Firebase ML.
*
* @param {ListModelsOptions} options The listing options.
*
Expand Down Expand Up @@ -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<void> {
return this.client.deleteModel(modelId);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down