Skip to main content

versions

Creates, updates, deletes, gets or lists a versions resource.

Overview

Nameversions
TypeResource
Idgoogle.ml.versions

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringRequired. The name specified for the version when it was created. The version name must be unique within the model it is created in.
acceleratorConfigobjectOptional. Accelerator config for using GPUs for online prediction (beta). Only specify this field if you have specified a Compute Engine (N1) machine type in the machineType field. Learn more about using GPUs for online prediction. (id: GoogleCloudMlV1__AcceleratorConfig)
autoScalingobjectAutomatically scale the number of nodes used to serve the model in response to increases and decreases in traffic. Care should be taken to ramp up traffic according to the model's ability to scale or you will start seeing increases in latency and 429 response codes. (id: GoogleCloudMlV1__AutoScaling)
containerobjectOptional. Specifies a custom container to use for serving predictions. If you specify this field, then machineType is required. If you specify this field, then deploymentUri is optional. If you specify this field, then you must not specify runtimeVersion, packageUris, framework, pythonVersion, or predictionClass. (id: GoogleCloudMlV1__ContainerSpec)
createTimestring (google-datetime)Output only. The time the version was created.
deploymentUristringThe Cloud Storage URI of a directory containing trained model artifacts to be used to create the model version. See the guide to deploying models for more information. The total number of files under this directory must not exceed 1000. During projects.models.versions.create, AI Platform Prediction copies all files from the specified directory to a location managed by the service. From then on, AI Platform Prediction uses these copies of the model artifacts to serve predictions, not the original files in Cloud Storage, so this location is useful only as a historical record. If you specify container, then this field is optional. Otherwise, it is required. Learn how to use this field with a custom container.
descriptionstringOptional. The description specified for the version when it was created.
errorMessagestringOutput only. The details of a failure or a cancellation.
etagstring (byte)etag is used for optimistic concurrency control as a way to help prevent simultaneous updates of a model from overwriting each other. It is strongly suggested that systems make use of the etag in the read-modify-write cycle to perform model updates in order to avoid race conditions: An etag is returned in the response to GetVersion, and systems are expected to put that etag in the request to UpdateVersion to ensure that their change will be applied to the model as intended.
explanationConfigobjectOptional. Configures explainability features on the model's version. Some explanation features require additional metadata to be loaded as part of the model payload. (id: GoogleCloudMlV1__ExplanationConfig)
frameworkstringOptional. The machine learning framework AI Platform uses to train this version of the model. Valid values are TENSORFLOW, SCIKIT_LEARN, XGBOOST. If you do not specify a framework, AI Platform will analyze files in the deployment_uri to determine a framework. If you choose SCIKIT_LEARN or XGBOOST, you must also set the runtime version of the model to 1.4 or greater. Do not specify a framework if you're deploying a custom prediction routine or if you're using a custom container.
isDefaultbooleanOutput only. If true, this version will be used to handle prediction requests that do not specify a version. You can change the default version by calling projects.methods.versions.setDefault.
labelsobjectOptional. One or more labels that you can add, to organize your model versions. Each label is a key-value pair, where both the key and the value are arbitrary strings that you supply. For more information, see the documentation on using labels. Note that this field is not updatable for mls1* models.
lastMigrationModelIdstringOutput only. The AI Platform (Unified) Model ID for the last model migration.
lastMigrationTimestring (google-datetime)Output only. The last time this version was successfully migrated to AI Platform (Unified).
lastUseTimestring (google-datetime)Output only. The time the version was last used for prediction.
machineTypestringOptional. The type of machine on which to serve the model. Currently only applies to online prediction service. To learn about valid values for this field, read Choosing a machine type for online prediction. If this field is not specified and you are using a regional endpoint, then the machine type defaults to n1-standard-2. If this field is not specified and you are using the global endpoint (ml.googleapis.com), then the machine type defaults to mls1-c1-m2.
manualScalingobjectManually select the number of nodes to use for serving the model. You should generally use auto_scaling with an appropriate min_nodes instead, but this option is available if you want more predictable billing. Beware that latency and error rates will increase if the traffic exceeds that capability of the system to serve it based on the selected number of nodes. (id: GoogleCloudMlV1__ManualScaling)
packageUrisarrayOptional. Cloud Storage paths (gs://…) of packages for custom prediction routines or scikit-learn pipelines with custom code. For a custom prediction routine, one of these packages must contain your Predictor class (see predictionClass). Additionally, include any dependencies used by your Predictor or scikit-learn pipeline uses that are not already included in your selected runtime version. If you specify this field, you must also set runtimeVersion to 1.4 or greater.
predictionClassstringOptional. The fully qualified name (module_name.class_name) of a class that implements the Predictor interface described in this reference field. The module containing this class should be included in a package provided to the packageUris field. Specify this field if and only if you are deploying a custom prediction routine (beta). If you specify this field, you must set runtimeVersion to 1.4 or greater and you must set machineType to a legacy (MLS1) machine type. The following code sample provides the Predictor interface: class Predictor(object): """Interface for constructing custom predictors.""" def predict(self, instances, **kwargs): """Performs custom prediction. Instances are the decoded values from the request. They have already been deserialized from JSON. Args: instances: A list of prediction input instances. **kwargs: A dictionary of keyword args provided as additional fields on the predict request body. Returns: A list of outputs containing the prediction results. This list must be JSON serializable. """ raise NotImplementedError() @classmethod def from_path(cls, model_dir): """Creates an instance of Predictor using the given path. Loading of the predictor should be done in this method. Args: model_dir: The local directory that contains the exported model file along with any additional files uploaded when creating the version resource. Returns: An instance implementing this Predictor class. """ raise NotImplementedError() Learn more about the Predictor interface and custom prediction routines.
pythonVersionstringRequired. The version of Python used in prediction. The following Python versions are available: * Python '3.7' is available when runtime_version is set to '1.15' or later. * Python '3.5' is available when runtime_version is set to a version from '1.4' to '1.14'. * Python '2.7' is available when runtime_version is set to '1.15' or earlier. Read more about the Python versions available for each runtime version.
requestLoggingConfigobjectOptional. Only specify this field in a projects.models.versions.patch request. Specifying it in a projects.models.versions.create request has no effect. Configures the request-response pair logging on predictions from this Version. (id: GoogleCloudMlV1__RequestLoggingConfig)
routesobjectOptional. Specifies paths on a custom container's HTTP server where AI Platform Prediction sends certain requests. If you specify this field, then you must also specify the container field. If you specify the container field and do not specify this field, it defaults to the following: json { "predict": "/v1/models/MODEL/versions/VERSION:predict", "health": "/v1/models/MODEL/versions/VERSION" } See RouteMap for more details about these default values. (id: GoogleCloudMlV1__RouteMap)
runtimeVersionstringRequired. The AI Platform runtime version to use for this deployment. For more information, see the runtime version list and how to manage runtime versions.
serviceAccountstringOptional. Specifies the service account for resource access control. If you specify this field, then you must also specify either the containerSpec or the predictionClass field. Learn more about using a custom service account.
statestringOutput only. The state of a version.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
projects_models_versions_getselectprojectsId, modelsId, versionsIdGets information about a model version. Models can have multiple versions. You can call projects.models.versions.list to get the same information that this method returns for all of the versions of a model.
projects_models_versions_listselectprojectsId, modelsIdfilter, pageToken, pageSizeGets basic information about all the versions of a model. If you expect that a model has many versions, or if you need to handle only a limited number of results at a time, you can request that the list be retrieved in batches (called pages). If there are no versions that match the request parameters, the list request returns an empty response body: {}.
projects_models_versions_createinsertprojectsId, modelsIdCreates a new version of a model from a trained TensorFlow model. If the version created in the cloud by this call is the first deployed version of the specified model, it will be made the default version of the model. When you add a version to a model that already has one or more versions, the default version does not automatically change. If you want a new version to be the default, you must call projects.models.versions.setDefault.
projects_models_versions_patchupdateprojectsId, modelsId, versionsIdupdateMaskUpdates the specified Version resource. Currently the only update-able fields are description, requestLoggingConfig, autoScaling.minNodes, and manualScaling.nodes.
projects_models_versions_deletedeleteprojectsId, modelsId, versionsIdDeletes a model version. Each model can have multiple versions deployed and in use at any given time. Use this method to remove a single version. Note: You cannot delete the version that is set as the default version of the model unless it is the only remaining version.
projects_models_versions_set_defaultexecprojectsId, modelsId, versionsIdDesignates a version to be the default for the model. The default version is used for prediction requests made against the model that don't specify a version. The first version to be created for a model is automatically set as the default. You must make any subsequent changes to the default version setting manually using this method.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
modelsIdstring
projectsIdstring
versionsIdstring
filterstring
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples

Gets information about a model version. Models can have multiple versions. You can call projects.models.versions.list to get the same information that this method returns for all of the versions of a model.

SELECT
name,
acceleratorConfig,
autoScaling,
container,
createTime,
deploymentUri,
description,
errorMessage,
etag,
explanationConfig,
framework,
isDefault,
labels,
lastMigrationModelId,
lastMigrationTime,
lastUseTime,
machineType,
manualScaling,
packageUris,
predictionClass,
pythonVersion,
requestLoggingConfig,
routes,
runtimeVersion,
serviceAccount,
state
FROM google.ml.versions
WHERE projectsId = '{{ projectsId }}' -- required
AND modelsId = '{{ modelsId }}' -- required
AND versionsId = '{{ versionsId }}' -- required;

INSERT examples

Creates a new version of a model from a trained TensorFlow model. If the version created in the cloud by this call is the first deployed version of the specified model, it will be made the default version of the model. When you add a version to a model that already has one or more versions, the default version does not automatically change. If you want a new version to be the default, you must call projects.models.versions.setDefault.

INSERT INTO google.ml.versions (
data__name,
data__description,
data__isDefault,
data__deploymentUri,
data__createTime,
data__lastUseTime,
data__runtimeVersion,
data__machineType,
data__autoScaling,
data__manualScaling,
data__state,
data__errorMessage,
data__predictionClass,
data__packageUris,
data__labels,
data__etag,
data__framework,
data__pythonVersion,
data__acceleratorConfig,
data__serviceAccount,
data__requestLoggingConfig,
data__explanationConfig,
data__container,
data__routes,
projectsId,
modelsId
)
SELECT
'{{ name }}',
'{{ description }}',
{{ isDefault }},
'{{ deploymentUri }}',
'{{ createTime }}',
'{{ lastUseTime }}',
'{{ runtimeVersion }}',
'{{ machineType }}',
'{{ autoScaling }}',
'{{ manualScaling }}',
'{{ state }}',
'{{ errorMessage }}',
'{{ predictionClass }}',
'{{ packageUris }}',
'{{ labels }}',
'{{ etag }}',
'{{ framework }}',
'{{ pythonVersion }}',
'{{ acceleratorConfig }}',
'{{ serviceAccount }}',
'{{ requestLoggingConfig }}',
'{{ explanationConfig }}',
'{{ container }}',
'{{ routes }}',
'{{ projectsId }}',
'{{ modelsId }}'
RETURNING
name,
done,
error,
metadata,
response
;

UPDATE examples

Updates the specified Version resource. Currently the only update-able fields are description, requestLoggingConfig, autoScaling.minNodes, and manualScaling.nodes.

UPDATE google.ml.versions
SET
data__name = '{{ name }}',
data__description = '{{ description }}',
data__isDefault = {{ isDefault }},
data__deploymentUri = '{{ deploymentUri }}',
data__createTime = '{{ createTime }}',
data__lastUseTime = '{{ lastUseTime }}',
data__runtimeVersion = '{{ runtimeVersion }}',
data__machineType = '{{ machineType }}',
data__autoScaling = '{{ autoScaling }}',
data__manualScaling = '{{ manualScaling }}',
data__state = '{{ state }}',
data__errorMessage = '{{ errorMessage }}',
data__predictionClass = '{{ predictionClass }}',
data__packageUris = '{{ packageUris }}',
data__labels = '{{ labels }}',
data__etag = '{{ etag }}',
data__framework = '{{ framework }}',
data__pythonVersion = '{{ pythonVersion }}',
data__acceleratorConfig = '{{ acceleratorConfig }}',
data__serviceAccount = '{{ serviceAccount }}',
data__requestLoggingConfig = '{{ requestLoggingConfig }}',
data__explanationConfig = '{{ explanationConfig }}',
data__container = '{{ container }}',
data__routes = '{{ routes }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND modelsId = '{{ modelsId }}' --required
AND versionsId = '{{ versionsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
done,
error,
metadata,
response;

DELETE examples

Deletes a model version. Each model can have multiple versions deployed and in use at any given time. Use this method to remove a single version. Note: You cannot delete the version that is set as the default version of the model unless it is the only remaining version.

DELETE FROM google.ml.versions
WHERE projectsId = '{{ projectsId }}' --required
AND modelsId = '{{ modelsId }}' --required
AND versionsId = '{{ versionsId }}' --required;

Lifecycle Methods

Designates a version to be the default for the model. The default version is used for prediction requests made against the model that don't specify a version. The first version to be created for a model is automatically set as the default. You must make any subsequent changes to the default version setting manually using this method.

EXEC google.ml.versions.projects_models_versions_set_default 
@projectsId='{{ projectsId }}' --required,
@modelsId='{{ modelsId }}' --required,
@versionsId='{{ versionsId }}' --required;