Skip to content

GCP.ML reference

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.

const getModel = yield* GCP.ML.GetModel(model);
const live = yield* getModel();

Source: src/GCP/ML/GetModelHttp.ts Kind: Layer · Provides: GCP.ML.GetModel

HTTP implementation of GetModel.

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.

const getVersion = yield* GCP.ML.GetVersion(version);
const live = yield* getVersion();

Source: src/GCP/ML/GetVersionHttp.ts Kind: 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.

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,
});
const model = yield* GCP.ML.Model("Classifier", {
description: "image classifier v2",
});

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.

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 },
});
const version = yield* GCP.ML.ModelsVersion("V1", {
model: model.name,
autoScaling: { minNodes: 1 },
});

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.

const predict = yield* GCP.ML.Predict(model);
const result = yield* predict({
body: {
httpBody: {
contentType: "application/json",
data: btoa(JSON.stringify({ instances: [{ f1: 1 }] })),
},
},
});

Source: src/GCP/ML/PredictHttp.ts Kind: Layer · Provides: GCP.ML.Predict

HTTP implementation of Predict.