GCP.ML reference
GetModel
Section titled “GetModel”Source:
src/GCP/ML/GetModel.ts
Runtime binding for AI Platform (legacy ML Engine) models.get.
Bind this operation to a Model in a Function/Action init
phase. Provide GetModelHttp.
GetModel: Reading a Model
Section titled “GetModel: Reading a Model”const getModel = yield* GCP.ML.GetModel(model);const live = yield* getModel();GetModelHttp
Section titled “GetModelHttp”Source:
src/GCP/ML/GetModelHttp.tsKind: Layer · Provides:GCP.ML.GetModel
HTTP implementation of GetModel.
GetVersion
Section titled “GetVersion”Source:
src/GCP/ML/GetVersion.ts
Runtime binding for AI Platform (legacy ML Engine) versions.get.
Bind this operation to a ModelsVersion in a Function/Action
init phase. Provide GetVersionHttp.
GetVersion: Reading a Version
Section titled “GetVersion: Reading a Version”const getVersion = yield* GCP.ML.GetVersion(version);const live = yield* getVersion();GetVersionHttp
Section titled “GetVersionHttp”Source:
src/GCP/ML/GetVersionHttp.tsKind: Layer · Provides:GCP.ML.GetVersion
HTTP implementation of GetVersion.
Source:
src/GCP/ML/Model.ts
An AI Platform (legacy ML Engine) model — a named container for
deployed ModelsVersions.
Labels are set at create time but are not patchable, so Alchemy also
stamps ownership into description for list / nuke. Model id,
regions, and logging flags are identity. Description and the default
version update in place.
The AI Platform Training and Prediction API (ml.googleapis.com)
must be enabled. Create of a model is metadata-only; serving traffic
requires at least one version.
Model: Creating a Model
Section titled “Model: Creating a Model”Generated name
const model = yield* GCP.ML.Model("Classifier", { description: "image classifier",});Explicit id, region, and labels
const model = yield* GCP.ML.Model("Classifier", { modelId: "image-classifier", regions: ["us-central1"], labels: { env: "prod" }, onlinePredictionLogging: true,});Model: Updating a Model
Section titled “Model: Updating a Model”const model = yield* GCP.ML.Model("Classifier", { description: "image classifier v2",});ModelsVersion
Section titled “ModelsVersion”Source:
src/GCP/ML/ModelsVersion.ts
A deployed version of an AI Platform (legacy ML Engine)
Model. Each version serves online and batch predictions from
a Cloud Storage SavedModel (or a custom container).
Version id, parent model, deploymentUri, runtime, framework, and
machine type are identity. Description, autoScaling.minNodes,
manualScaling.nodes, and requestLoggingConfig update in place.
Create and delete are long-running operations.
ModelsVersion: Creating a ModelsVersion
Section titled “ModelsVersion: Creating a ModelsVersion”TensorFlow SavedModel
const model = yield* GCP.ML.Model("Classifier", {});const version = yield* GCP.ML.ModelsVersion("V1", { model: model.name, deploymentUri: "gs://my-bucket/saved-model", runtimeVersion: "2.11", pythonVersion: "3.7", framework: "TENSORFLOW",});Explicit version id and labels
const version = yield* GCP.ML.ModelsVersion("V1", { model: model.name, versionId: "v1", deploymentUri: "gs://my-bucket/saved-model", labels: { env: "prod" }, autoScaling: { minNodes: 0 },});ModelsVersion: Updating a ModelsVersion
Section titled “ModelsVersion: Updating a ModelsVersion”const version = yield* GCP.ML.ModelsVersion("V1", { model: model.name, autoScaling: { minNodes: 1 },});Predict
Section titled “Predict”Source:
src/GCP/ML/Predict.ts
Runtime binding for AI Platform (legacy ML Engine) projects.predict.
Bind this operation to a Model in a Function/Action init
phase. Requests that omit a version use the model’s default version.
Provide PredictHttp.
Predict: Predicting
Section titled “Predict: Predicting”const predict = yield* GCP.ML.Predict(model);const result = yield* predict({ body: { httpBody: { contentType: "application/json", data: btoa(JSON.stringify({ instances: [{ f1: 1 }] })), }, },});PredictHttp
Section titled “PredictHttp”Source:
src/GCP/ML/PredictHttp.tsKind: Layer · Provides:GCP.ML.Predict
HTTP implementation of Predict.