REST Resource: projects.locations.models

Resource: Model

A trained machine learning Model.

JSON representation
{
  "name": string,
  "displayName": string,
  "description": string,
  "predictSchemata": {
    object (PredictSchemata)
  },
  "metadataSchemaUri": string,
  "metadata": value,
  "supportedExportFormats": [
    {
      object (ExportFormat)
    }
  ],
  "trainingPipeline": string,
  "containerSpec": {
    object (ModelContainerSpec)
  },
  "artifactUri": string,
  "supportedDeploymentResourcesTypes": [
    enum (DeploymentResourcesType)
  ],
  "supportedInputStorageFormats": [
    string
  ],
  "supportedOutputStorageFormats": [
    string
  ],
  "createTime": string,
  "updateTime": string,
  "deployedModels": [
    {
      object (DeployedModelRef)
    }
  ],
  "explanationSpec": {
    object (ExplanationSpec)
  },
  "etag": string,
  "labels": {
    string: string,
    ...
  }
}
Fields
name

string

The resource name of the Model.

displayName

string

Required. The display name of the Model. The name can be up to 128 characters long and can be consist of any UTF-8 characters.

description

string

The description of the Model.

predictSchemata

object (PredictSchemata)

The schemata that describe formats of the Model's predictions and explanations as given and returned via PredictionService.Predict and PredictionService.Explain.

metadataSchemaUri

string

Immutable. Points to a YAML file stored on Google Cloud Storage describing additional information about the Model, that is specific to it. Unset if the Model does not have any additional information. The schema is defined as an OpenAPI 3.0.2 Schema Object. AutoML Models always have this field populated by AI Platform, if no additional metadata is needed this field is set to an empty string. Note: The URI given on output will be immutable and probably different, including the URI scheme, than the one given on input. The output URI will point to a location where the user only has a read access.

metadata

value (Value format)

Immutable. An additional information about the Model; the schema of the metadata can be found in metadata_schema. Unset if the Model does not have any additional information.

supportedExportFormats[]

object (ExportFormat)

Output only. The formats in which this Model may be exported. If empty, this Model is not available for export.

trainingPipeline

string

Output only. The resource name of the TrainingPipeline that uploaded this Model, if any.

containerSpec

object (ModelContainerSpec)

Input only. The specification of the container that is to be used when deploying this Model. The specification is ingested upon ModelService.UploadModel, and all binaries it contains are copied and stored internally by AI Platform. Not present for AutoML Models.

artifactUri

string

Immutable. The path to the directory containing the Model artifact and any of its supporting files. Not present for AutoML Models.

supportedDeploymentResourcesTypes[]

enum (DeploymentResourcesType)

Output only. When this Model is deployed, its prediction resources are described by the prediction_resources field of the Endpoint.deployed_models object. Because not all Models support all resource configuration types, the configuration types this Model supports are listed here. If no configuration types are listed, the Model cannot be deployed to an Endpoint and does not support online predictions (PredictionService.Predict or PredictionService.Explain). Such a Model can serve predictions by using a BatchPredictionJob, if it has at least one entry each in supportedInputStorageFormats and supportedOutputStorageFormats.

supportedInputStorageFormats[]

string

Output only. The formats this Model supports in BatchPredictionJob.input_config. If PredictSchemata.instance_schema_uri exists, the instances should be given as per that schema.

The possible formats are:

  • jsonl The JSON Lines format, where each instance is a single line. Uses GcsSource.

  • csv The CSV format, where each instance is a single comma-separated line. The first line in the file is the header, containing comma-separated field names. Uses GcsSource.

  • tf-record The TFRecord format, where each instance is a single record in tfrecord syntax. Uses GcsSource.

  • tf-record-gzip Similar to tf-record, but the file is gzipped. Uses GcsSource.

  • bigquery Each instance is a single row in BigQuery. Uses BigQuerySource.

  • file-list Each line of the file is the location of an instance to process, uses gcsSource field of the InputConfig object.

If this Model doesn't support any of these formats it means it cannot be used with a BatchPredictionJob. However, if it has supportedDeploymentResourcesTypes, it could serve online predictions by using PredictionService.Predict or PredictionService.Explain.

supportedOutputStorageFormats[]

string

Output only. The formats this Model supports in BatchPredictionJob.output_config. If both PredictSchemata.instance_schema_uri and PredictSchemata.prediction_schema_uri exist, the predictions are returned together with their instances. In other words, the prediction has the original instance data first, followed by the actual prediction content (as per the schema).

The possible formats are:

  • jsonl The JSON Lines format, where each prediction is a single line. Uses GcsDestination.

  • csv The CSV format, where each prediction is a single comma-separated line. The first line in the file is the header, containing comma-separated field names. Uses GcsDestination.

  • bigquery Each prediction is a single row in a BigQuery table, uses BigQueryDestination .

If this Model doesn't support any of these formats it means it cannot be used with a BatchPredictionJob. However, if it has supportedDeploymentResourcesTypes, it could serve online predictions by using PredictionService.Predict or PredictionService.Explain.

createTime

string (Timestamp format)

Output only. Timestamp when this Model was uploaded into AI Platform.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

updateTime

string (Timestamp format)

Output only. Timestamp when this Model was most recently updated.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

deployedModels[]

object (DeployedModelRef)

Output only. The pointers to DeployedModels created from this Model. Note that Model could have been deployed to Endpoints in different Locations.

explanationSpec

object (ExplanationSpec)

The default explanation specification for this Model.

The Model can be used for [requesting explanation][PredictionService.Explain] after being deployed iff it is populated. The Model can be used for [batch explanation][BatchPredictionJob.generate_explanation] iff it is populated.

All fields of the explanationSpec can be overridden by explanationSpec of DeployModelRequest.deployed_model, or explanationSpec of BatchPredictionJob.

etag

string

Used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens.

labels

map (key: string, value: string)

The labels with user-defined metadata to organize your Models.

Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed.

See https://goo.gl/xmQnxf for more information and examples of labels.

PredictSchemata

Contains the schemata used in Model's predictions and explanations via PredictionService.Predict, PredictionService.Explain and BatchPredictionJob.

JSON representation
{
  "instanceSchemaUri": string,
  "parametersSchemaUri": string,
  "predictionSchemaUri": string
}
Fields
instanceSchemaUri

string

Immutable. Points to a YAML file stored on Google Cloud Storage describing the format of a single instance, which are used in PredictRequest.instances, ExplainRequest.instances and BatchPredictionJob.input_config. The schema is defined as an OpenAPI 3.0.2 Schema Object. AutoML Models always have this field populated by AI Platform. Note: The URI given on output will be immutable and probably different, including the URI scheme, than the one given on input. The output URI will point to a location where the user only has a read access.

parametersSchemaUri

string

Immutable. Points to a YAML file stored on Google Cloud Storage describing the parameters of prediction and explanation via PredictRequest.parameters, ExplainRequest.parameters and BatchPredictionJob.model_parameters. The schema is defined as an OpenAPI 3.0.2 Schema Object. AutoML Models always have this field populated by AI Platform, if no parameters are supported it is set to an empty string. Note: The URI given on output will be immutable and probably different, including the URI scheme, than the one given on input. The output URI will point to a location where the user only has a read access.

predictionSchemaUri

string

Immutable. Points to a YAML file stored on Google Cloud Storage describing the format of a single prediction produced by this Model, which are returned via PredictResponse.predictions, ExplainResponse.explanations, and BatchPredictionJob.output_config. The schema is defined as an OpenAPI 3.0.2 Schema Object. AutoML Models always have this field populated by AI Platform. Note: The URI given on output will be immutable and probably different, including the URI scheme, than the one given on input. The output URI will point to a location where the user only has a read access.

ExportFormat

Represents a supported by the Model export format. All formats export to Google Cloud Storage.

JSON representation
{
  "id": string,
  "exportableContents": [
    enum (ExportableContent)
  ]
}
Fields
id

string

Output only. The ID of the export format. The possible format IDs are:

  • tflite Used for Android mobile devices.

  • edgetpu-tflite Used for Edge TPU devices.

  • tf-saved-model A tensorflow model in SavedModel format.

  • tf-js A TensorFlow.js model that can be used in the browser and in Node.js using JavaScript.

  • core-ml Used for iOS mobile devices.

  • custom-trained A Model that was uploaded or trained by custom code.

exportableContents[]

enum (ExportableContent)

Output only. The content of this Model that may be exported.

ExportableContent

The Model content that can be exported.

Enums
EXPORTABLE_CONTENT_UNSPECIFIED Should not be used.
ARTIFACT Model artifact and any of its supported files. Will be exported to the location specified by the artifactDestination field of the ExportModelRequest.output_config object.
IMAGE The container image that is to be used when deploying this Model. Will be exported to the location specified by the imageDestination field of the ExportModelRequest.output_config object.

ModelContainerSpec

Specification of a container for serving predictions. This message is a subset of the Kubernetes Container v1 core specification.

JSON representation
{
  "imageUri": string,
  "command": [
    string
  ],
  "args": [
    string
  ],
  "env": [
    {
      object (EnvVar)
    }
  ],
  "ports": [
    {
      object (Port)
    }
  ],
  "predictRoute": string,
  "healthRoute": string
}
Fields
imageUri

string

Required. Immutable. URI of the Docker image to be used as the custom container for serving predictions. This URI must identify an image in Artifact Registry or Container Registry. Learn more about the container publishing requirements, including permissions requirements for the AI Platform Service Agent, here.

The container image is ingested upon ModelService.UploadModel, stored internally, and this original path is afterwards not used.

To learn about the requirements for the Docker image itself, see Custom container requirements.

You can use the URI to one of AI Platform's pre-built container images for prediction in this field.

command[]

string

Immutable. Specifies the command that runs when the container starts. This overrides the container's ENTRYPOINT. Specify this field as an array of executable and arguments, similar to a Docker ENTRYPOINT's "exec" form, not its "shell" form.

If you do not specify this field, then the container's ENTRYPOINT runs, in conjunction with the args field or the container's CMD, if either exists. If this field is not specified and the container does not have an ENTRYPOINT, then refer to the Docker documentation about how CMD and ENTRYPOINT interact.

If you specify this field, then you can also specify the args field to provide additional arguments for this command. However, if you specify this field, then the container's CMD is ignored. See the Kubernetes documentation about how the command and args fields interact with a container's ENTRYPOINT and CMD.

In this field, you can reference environment variables set by AI Platform and environment variables set in the env field. You cannot reference environment variables set in the Docker image. In order for environment variables to be expanded, reference them by using the following syntax:

$(VARIABLE_NAME)

Note that this differs from Bash variable expansion, which does not use parentheses. If a variable cannot be resolved, the reference in the input string is used unchanged. To avoid variable expansion, you can escape this syntax with $$; for example:

$$(VARIABLE_NAME)

This field corresponds to the command field of the Kubernetes Containers v1 core API.

args[]

string

Immutable. Specifies arguments for the command that runs when the container starts. This overrides the container's CMD. Specify this field as an array of executable and arguments, similar to a Docker CMD's "default parameters" form.

If you don't specify this field but do specify the command field, then the command from the command field runs without any additional arguments. See the Kubernetes documentation about how the command and args fields interact with a container's ENTRYPOINT and CMD.

If you don't specify this field and don't specify the command field, then the container's ENTRYPOINT and CMD determine what runs based on their default behavior. See the Docker documentation about how CMD and ENTRYPOINT interact.

In this field, you can reference environment variables set by AI Platform and environment variables set in the env field. You cannot reference environment variables set in the Docker image. In order for environment variables to be expanded, reference them by using the following syntax:

$(VARIABLE_NAME)

Note that this differs from Bash variable expansion, which does not use parentheses. If a variable cannot be resolved, the reference in the input string is used unchanged. To avoid variable expansion, you can escape this syntax with $$; for example:

$$(VARIABLE_NAME)

This field corresponds to the args field of the Kubernetes Containers v1 core API.

env[]

object (EnvVar)

Immutable. List of environment variables to set in the container. After the container starts running, code running in the container can read these environment variables.

Additionally, the command and args fields can reference these variables. Later entries in this list can also reference earlier entries. For example, the following example sets the variable VAR_2 to have the value foo bar:

[
  {
    "name": "VAR_1",
    "value": "foo"
  },
  {
    "name": "VAR_2",
    "value": "$(VAR_1) bar"
  }
]

If you switch the order of the variables in the example, then the expansion does not occur.

This field corresponds to the env field of the Kubernetes Containers v1 core API.

ports[]

object (Port)

Immutable. List of ports to expose from the container. AI Platform sends any prediction requests that it receives to the first port on this list. AI Platform also sends liveness and health checks to this port.

If you do not specify this field, it defaults to following value:

[
  {
    "containerPort": 8080
  }
]

AI Platform does not use ports other than the first one listed. This field corresponds to the ports field of the Kubernetes Containers v1 core API.

predictRoute

string

Immutable. HTTP path on the container to send prediction requests to. AI Platform forwards requests sent using projects.locations.endpoints.predict to this path on the container's IP address and port. AI Platform then returns the container's response in the API response.

For example, if you set this field to /foo, then when AI Platform receives a prediction request, it forwards the request body in a POST request to the /foo path on the port of your container specified by the first value of this ModelContainerSpec's ports field.

If you don't specify this field, it defaults to the following value when you deploy this Model to an Endpoint:

/v1/endpoints/ENDPOINT/deployedModels/DEPLOYED_MODEL:predict

The placeholders in this value are replaced as follows:

  • ENDPOINT: The last segment (following endpoints/)of the Endpoint.name][] field of the Endpoint where this Model has been deployed. (AI Platform makes this value available to your container code as the AIP_ENDPOINT_ID environment variable.)

  • DEPLOYED_MODEL: DeployedModel.id of the DeployedModel. (AI Platform makes this value available to your container code as the AIP_DEPLOYED_MODEL_ID environment variable.)

healthRoute

string

Immutable. HTTP path on the container to send health checkss to. AI Platform intermittently sends GET requests to this path on the container's IP address and port to check that the container is healthy. Read more about health checks.

For example, if you set this field to /bar, then AI Platform intermittently sends a GET request to the /bar path on the port of your container specified by the first value of this ModelContainerSpec's ports field.

If you don't specify this field, it defaults to the following value when you deploy this Model to an Endpoint:

/v1/endpoints/ENDPOINT/deployedModels/DEPLOYED_MODEL:predict

The placeholders in this value are replaced as follows:

  • ENDPOINT: The last segment (following endpoints/)of the Endpoint.name][] field of the Endpoint where this Model has been deployed. (AI Platform makes this value available to your container code as the AIP_ENDPOINT_ID environment variable.)

  • DEPLOYED_MODEL: DeployedModel.id of the DeployedModel. (AI Platform makes this value available to your container code as the AIP_DEPLOYED_MODEL_ID environment variable.)

EnvVar

Represents an environment variable present in a Container or Python Module.

JSON representation
{
  "name": string,
  "value": string
}
Fields
name

string

Required. Name of the environment variable. Must be a valid C identifier.

value

string

Required. Variables that reference a $(VAR_NAME) are expanded using the previous defined environment variables in the container and any service environment variables. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not.

Port

Represents a network port in a container.

JSON representation
{
  "containerPort": integer
}
Fields
containerPort

integer

The number of the port to expose on the pod's IP address. Must be a valid port number, between 1 and 65535 inclusive.

DeploymentResourcesType

Identifies a type of Model's prediction resources.

Enums
DEPLOYMENT_RESOURCES_TYPE_UNSPECIFIED Should not be used.
DEDICATED_RESOURCES Resources that are dedicated to the DeployedModel, and that need a higher degree of manual configuration.
AUTOMATIC_RESOURCES Resources that to large degree are decided by AI Platform, and require only a modest additional configuration.

DeployedModelRef

Points to a DeployedModel.

JSON representation
{
  "endpoint": string,
  "deployedModelId": string
}
Fields
endpoint

string

Immutable. A resource name of an Endpoint.

deployedModelId

string

Immutable. An ID of a DeployedModel in the above Endpoint.

Methods

delete

Deletes a Model.

export

Exports a trained, exportable, Model to a location specified by the user.

get

Gets a Model.

list

Lists Models in a Location.

patch

Updates a Model.

upload

Uploads a Model artifact into AI Platform.