Setup

library(googleAuthR)
library(googleCloudVertexAIR)

options(googleAuthR.scopes.selected = "https://www.googleapis.com/auth/cloud-platform")

gar_auth_service(json_file = Sys.getenv("GAR_SERVICE_JSON"))

Set global arguements

projectId <- Sys.getenv("GCVA_DEFAULT_PROJECT_ID")
gcva_region_set("us-central1")
## 2024-07-08 12:35:43.310669> Region set to 'us-central1'
gcva_project_set(projectId)
## 2024-07-08 12:35:43.311209> ProjectId set to 'gc-vertex-ai-r'

List Models

models <- gcva_list_models()
models
##                                                                     name
## 1 projects/442003009360/locations/us-central1/models/6818469627048230912
## 2 projects/442003009360/locations/us-central1/models/8383417721001345024
## 3 projects/442003009360/locations/us-central1/models/2734102788232445952
## 4 projects/442003009360/locations/us-central1/models/2964912269135183872
##                               displayName
## 1                          vertex-r-model
## 2                          vertex-r-model
## 3 model-california-housing-20221113163728
## 4 model-california-housing-20221113133926
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          predictSchemata.instanceSchemaUri
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     <NA>
## 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     <NA>
## 3 https://storage.googleapis.com/caip-tenant-83d09d28-0ad0-483a-86c1-98696b7a84ed/schema/predict/instance.yaml?GoogleAccessId=service-442003009360@gcp-sa-aiplatform.iam.gserviceaccount.com&Expires=1720460143&Signature=xuPhSbRU6OmuoEv1GwMkgN0zQu0zuRaVP9OEWPtOsmx2GoRuY1HNIMK%252BsYlsT32BiNH7UkYwJVahkNSifF05HpK2b9uo9EQk3dc%252FN3oHqzOgpMH1ZzFBMie80%252BNX6bvInOQaMu4p9ugWfEOFllK%252Fu8SlslLXcBrdpj6l%252FjtKlFGA4IABX8oTOVFJwnxZ4FMVivwiiiEEwNiLkFW4Ad%252FtJysyIta6DZxIau948ldMG3SoVGWVjsl1E0RAPAiCzspoZC4hGZWaWUHV6E52OL%252Bz42GTReXN6WI2fEy7yMJT7wKYZlGXWBKdEBZ%252B7n0Ib4yOjNlI7s6poErwHF9pUwIIHQ%253D%253D
## 4         https://storage.googleapis.com/caip-tenant-ae36e64e-83e5-4731-aae8-26eeaf01c180/schema/predict/instance.yaml?GoogleAccessId=service-442003009360@gcp-sa-aiplatform.iam.gserviceaccount.com&Expires=1720460143&Signature=f0kVPQhYEvoWrfh6ifCnoMqqKwZqZnK3HaMbtYoLfMqajdCSuvrWt1Xw32Xc6859vBuVtTa0Fc03OBQPdk0XlfNzKpKshGW%252BL7YyWVPOaI1bSH7v6Vtm99CFiztRQWO%252FISiTh5v0FkB7iR79irA5LBASOF9Tz03LCOdNDwLDa7pqXMK43oiZc0h%252BnytEnxpCP2YwvhxnRWahUDhXGMuBLeHPDtlt8MZQm5s8dnkUpV0m0iVr5e5Ex272X%252BaqTIeEC6rV844vgyf1dinXvTv8WmjfOlIAnfTUF3V16M7RrZJ1U1CbXjXaVRXqh65HimYPbO8pj%252Boo4GsJo8%252Fzn7vu3A%253D%253D
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          predictSchemata.predictionSchemaUri
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       <NA>
## 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       <NA>
## 3 https://storage.googleapis.com/caip-tenant-83d09d28-0ad0-483a-86c1-98696b7a84ed/schema/predict/prediction.yaml?GoogleAccessId=service-442003009360@gcp-sa-aiplatform.iam.gserviceaccount.com&Expires=1720460143&Signature=e%252BFrnTs0lMopro8uMOSHs4IQS13c0kbYb2S%252FFGA285WZr3FhweoB%252FfrV8L3m%252Bltw2zYhhmR1BwkVmqJMtaTm8P%252B7lxdh7lhADlPvIBSvTwuBfeanJM41qkurDmvkulqH8cAHVIortoU%252FRVHn1bT5tezQKcLqZ3LCkbJ8p78h1Ic3jhb3MjyMxwe2T4quPevprZ%252BupzIN5pH0m%252BuYce4%252FBj6V2NK%252BezV4QwRtljEdaiX4xUyuoB%252F6faWzAGf14v4UVFDcNcQc%252BpNOAwwV9PXZfTE6XG%252FKvh3CVIEOaAlXJotumIjJNX8TRCcy%252FAnAl5md%252FskmMdoXXPH1I%252BfHioGhUQ%253D%253D
## 4         https://storage.googleapis.com/caip-tenant-ae36e64e-83e5-4731-aae8-26eeaf01c180/schema/predict/prediction.yaml?GoogleAccessId=service-442003009360@gcp-sa-aiplatform.iam.gserviceaccount.com&Expires=1720460143&Signature=aDmaHZEdunOE9wUAeEwp%252FGfE1gb6I%252FNVyjRsEMV7EMLSd8CR4OAQwQh5yeDrE5YNqrynWQQvkbanqKvUICsR%252FmRLG9eq23uG4RlRT8q%252Bn6167WIoSa4Ku12NsTfVMHYuw2r66AJFecocCSHDv7Y6MICRsy5Ml6PIhvCv5U9uCG0QkXjHfwXEkuirES4kbvi2MuUVHe19tmuqVTAgWDsPGyvrN%252B4hqxBFZ%252BQLmYaN4oOcghC3cCnamyO8WuHC3vhTct45%252FplsvNxhNTvH%252BWI1%252FZv5iP0G5y%252FPktwWHYDON005FsfT%252BAueBbovzD7%252FI%252FmuBQiaclfqYNqwNT%252BlAXqYNg%253D%253D
##                                                                    trainingPipeline
## 1  projects/442003009360/locations/us-central1/trainingPipelines/947230504279605248
## 2 projects/442003009360/locations/us-central1/trainingPipelines/4909272276458799104
## 3 projects/442003009360/locations/us-central1/trainingPipelines/2601571779788931072
## 4  projects/442003009360/locations/us-central1/trainingPipelines/422955460048453632
##                                                     containerSpec.imageUri
## 1 us-central1-docker.pkg.dev/gc-vertex-ai-r/my-docker-repo/vertex-r:latest
## 2 us-central1-docker.pkg.dev/gc-vertex-ai-r/my-docker-repo/vertex-r:latest
## 3                                                                     <NA>
## 4                                                                     <NA>
##   containerSpec.command supportedDeploymentResourcesTypes
## 1      Rscript, serve.R               DEDICATED_RESOURCES
## 2      Rscript, serve.R               DEDICATED_RESOURCES
## 3                  NULL               DEDICATED_RESOURCES
## 4                  NULL               DEDICATED_RESOURCES
##                                 supportedInputStorageFormats
## 1 jsonl, bigquery, csv, tf-record, tf-record-gzip, file-list
## 2 jsonl, bigquery, csv, tf-record, tf-record-gzip, file-list
## 3                            bigquery, csv, jsonl, tf-record
## 4                            bigquery, csv, jsonl, tf-record
##     supportedOutputStorageFormats          createTime
## 1                 jsonl, bigquery 2023-01-20 22:38:00
## 2                 jsonl, bigquery 2023-01-20 22:28:06
## 3 bigquery, csv, tf-record, jsonl 2022-11-13 21:38:14
## 4 bigquery, csv, tf-record, jsonl 2022-11-13 18:43:54
##                    updateTime
## 1 2023-01-20T22:44:49.072684Z
## 2 2023-01-20T22:35:36.741432Z
## 3 2022-11-13T23:33:13.942890Z
## 4 2022-11-13T20:54:04.169546Z
##                                                                   etag
## 1 AMEw9yMKoP3sFaYhf-OnWM-kfaNkN0PE3FUZ9vdfN8aavyhG4bGL8ELfG7pW1-UKhq4=
## 2 AMEw9yOV62WX0OHh-bzJIbMOhKxmdUn0n5YwDe9kCnpZtXcy6s-1JAyxVOdS-ITrCDpz
## 3 AMEw9yNpECdl7GaOc5gRx0J2a4xDyTToM82tjBSaBATwhJIur_cbE8sgH_cg-dNxDOBI
## 4 AMEw9yO2wwYGWZ7Bu0ndvdmbi6e26WIHpezuYcj5vtPj2hd30wHIagNO65ISn2nrBh4=
##            supportedExportFormats
## 1 custom-trained, ARTIFACT, IMAGE
## 2 custom-trained, ARTIFACT, IMAGE
## 3        tf-saved-model, ARTIFACT
## 4        tf-saved-model, ARTIFACT
##                                                   artifactUri versionId
## 1 gs://gc-vertex-ai-r-aip-20230120172747/20230120173759/model         1
## 2 gs://gc-vertex-ai-r-aip-20230120172747/20230120172806/model         1
## 3                                                        <NA>         1
## 4                                                        <NA>         1
##   versionAliases           versionCreateTime           versionUpdateTime
## 1        default 2023-01-20T22:38:00.055628Z 2023-01-20T22:44:49.072684Z
## 2        default 2023-01-20T22:28:06.707955Z 2023-01-20T22:35:36.741432Z
## 3        default 2022-11-13T21:38:14.348002Z 2022-11-13T23:33:13.942890Z
## 4        default 2022-11-13T18:43:54.580925Z 2022-11-13T20:54:04.169546Z
##   sourceType
## 1     CUSTOM
## 2     CUSTOM
## 3     AUTOML
## 4     AUTOML
##                                                                                        metadataSchemaUri
## 1                                                                                                   <NA>
## 2                                                                                                   <NA>
## 3 https://storage.googleapis.com/google-cloud-aiplatform/schema/model/metadata/automl_tabular_1.0.0.yaml
## 4 https://storage.googleapis.com/google-cloud-aiplatform/schema/model/metadata/automl_tabular_1.0.0.yaml
##   explanationSpec.pathCount explanationSpec.metadata.inputs.inputBaselines
## 1                        NA                                           NULL
## 2                        NA                                           NULL
## 3                        16                                        -118.49
## 4                        16                                        -118.31
##   explanationSpec.metadata.inputs.inputBaselines
## 1                                           NULL
## 2                                           NULL
## 3                                          34.26
## 4                                          34.06
##   explanationSpec.metadata.inputs.inputBaselines
## 1                                           NULL
## 2                                           NULL
## 3                                           29.0
## 4                                           29.0
##   explanationSpec.metadata.inputs.inputBaselines
## 1                                           NULL
## 2                                           NULL
## 3                                         2127.0
## 4                                         2127.0
##   explanationSpec.metadata.inputs.inputBaselines
## 1                                           NULL
## 2                                           NULL
## 3                                          435.0
## 4                                          435.0
##   explanationSpec.metadata.inputs.inputBaselines
## 1                                           NULL
## 2                                           NULL
## 3                                         1167.0
## 4                                         1167.0
##   explanationSpec.metadata.inputs.inputBaselines
## 1                                           NULL
## 2                                           NULL
## 3                                          410.0
## 4                                          410.0
##   explanationSpec.metadata.inputs.inputBaselines
## 1                                           NULL
## 2                                           NULL
## 3                                         3.5388
## 4                                         3.5388
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  explanationSpec.metadata.featureAttributionsSchemaUri
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 <NA>
## 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 <NA>
## 3     https://storage.googleapis.com/caip-tenant-83d09d28-0ad0-483a-86c1-98696b7a84ed/schema/explain/feature_attributions.yaml?GoogleAccessId=service-442003009360@gcp-sa-aiplatform.iam.gserviceaccount.com&Expires=1720460143&Signature=q5WzKKIh9GzpsXD6zF9CrH3T83pSSd8O1CXPrDTsviy031erLVNboU5GczjIFgvgV8Fxk1XUrXLjwOQUP1N09HxCADXQx5b65tNzvQ3UAlKOxLxhf9Oftyx%252BgnSiW%252FU0dz5fqRRlYKLX6usS%252FfW54Ak9JeqKTLii6tlhvu5fJDKf0xC7%252BdFOKD9Ks2U64Qz54%252F6ntaGpzvBOicmaX9Ue%252Bkc0E%252Fy4juzFaPFYwSb%252FJj7HvGhRJ3hozAXVSA6yN%252FRtLB3sG%252BcCBdTsnG1MwG75YmpMWJH2W1sdnS9UxTNJp9a%252FX5KJHQQutilW4xVCRqab1AAwub1Qq4vNZCYsISRcWA%253D%253D
## 4 https://storage.googleapis.com/caip-tenant-ae36e64e-83e5-4731-aae8-26eeaf01c180/schema/explain/feature_attributions.yaml?GoogleAccessId=service-442003009360@gcp-sa-aiplatform.iam.gserviceaccount.com&Expires=1720460143&Signature=D5G9NkkWki7a0dy3Tj5dCExK6rVmn9HrJQfw0fLJzaFll8lFpKHNjyQPe7IpBbcUU6S3tvNA32RLY4Pj8PWdOTuYbt%252Bo%252Bf%252BA6Ker6ty9I8jyCeJOKOWUAIfcKwDr%252FEHkYiRl%252B63Xkm432SQ91w6QQlaqcgAjHFHowNUQ61k8K6RjV0iARRtYNnZln8JUS6cdxe%252BkYb23daTeVU14EBTMhaSNj2Lqa9cJ2pEZD%252B%252BmTFjmsmA9xvjsyhbxlf50reWjr%252BhxUBPkUZ%252BfxP3pmgiEwAgnH1f3jMY7CQUKAL68vS6pSfVuZqhCkD%252FxEjHPDKTDP0NSsyZP89uf95ie%252FNOe1g%253D%253D

Get model

model <- gcva_model(model = models[1,1])
model
## ==Google Cloud Vertex AI Model==
## name:                 projects/442003009360/locations/us-central1/models/6818469627048230912 
## displayName:          vertex-r-model 
## createTime:           2023-01-20 22:38:00 
## versionId:            1 
## versionAlias:         default