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:20.771566> Region set to 'us-central1'
gcva_project_set(projectId)
## 2024-07-08 12:35:20.77209> ProjectId set to 'gc-vertex-ai-r'

First, let’s set a unique dataset name with a timestamp to avoid confusion:

timestamp <- strftime(Sys.time(), "%Y%m%d%H%M%S")
timestamp
## [1] "20240708123520"
datasetDisplayName <- sprintf("california-housing-%s", timestamp)
datasetDisplayName
## [1] "california-housing-20240708123520"

List datasets

##                         displayName
## 1 california-housing-20230603152752
## 2 california-housing-20230602151732
## 3 california-housing-20230602151425
## 4 california-housing-20230205131419
## 5 california-housing-20230120172747
## 6 california-housing-20221113133926
## 7 california-housing-20221113163728
##                                                                       name
## 1 projects/442003009360/locations/us-central1/datasets/2201923767226073088
## 2 projects/442003009360/locations/us-central1/datasets/4486093203233046528
## 3 projects/442003009360/locations/us-central1/datasets/6945340074754048000
## 4 projects/442003009360/locations/us-central1/datasets/1778563412020690944
## 5 projects/442003009360/locations/us-central1/datasets/1237603691154898944
## 6 projects/442003009360/locations/us-central1/datasets/3229769227103633408
## 7 projects/442003009360/locations/us-central1/datasets/7808241198279163904
##                                                         metadataSchemaUri
## 1 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 2 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 3 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 4 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 5 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 6 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 7 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
##            createTime                  updateTime
## 1 2023-06-03 19:27:55 2023-06-03T19:27:56.201458Z
## 2 2023-06-02 19:17:34 2023-06-02T19:17:35.155780Z
## 3 2023-06-02 19:14:28 2023-06-02T19:14:28.637754Z
## 4 2023-02-05 18:14:20 2023-02-05T18:14:21.078906Z
## 5 2023-01-20 22:27:56 2023-01-20T22:40:21.187713Z
## 6 2022-11-13 18:39:31 2022-11-20T18:46:10.716692Z
## 7 2022-11-13 21:37:42 2022-11-20T18:45:24.758277Z
##                                                                   etag
## 1 AMEw9yPoU7Tocv_3ZRvyw90oy6mkwX7xuJ0QZ-w170gZS19zobTKTttYOlvrH_3xago=
## 2 AMEw9yOjeAdozZcv-5CBv2lCgXpyW9ou9HxEce_-NCmGa7q7gNmcZQs1IfrDijQh1g4=
## 3 AMEw9yNfWYJ3zH1gNXXWL6iMA1jRVgD5nGTn5m3_iG9lts7HGqypw0GLqex7sngu2X9Y
## 4 AMEw9yPwx31a7U23s4f2a_REl6wMlw3gTvID-8LdPPfwnZzZUOYdJsP8pObgURNAHDU=
## 5 AMEw9yM5Ix4maAzNixBKcWyCm6y93bQSzqkY-CTzdGVkRxjBMOQVcBiccRSWatdeR5E=
## 6 AMEw9yP74JcwKFZEti7PZzpAa5xxWy5ZfzucBo-4cq1jmVaCmzVVKENznXGPfXBjGpx-
## 7 AMEw9yMV1zaaZgGxtT9Jxb6hMwpxfef68Vl1GhxaeexfwM6WXFfLDHU4abwQkxz6lKhs
##                                                                                                      uri
## 1 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 2 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 3 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 4 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 5 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 6 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 7 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
##                                                                                                    metadataArtifact
## 1 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/b6061e06-1f17-44d5-a8c3-9de7ee8ea62e
## 2 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/31195bd3-ce31-4503-8e42-f884d8c529a7
## 3 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/90e1be4d-35a5-41d4-a9da-f275afc90fb2
## 4 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/4a956544-5cab-4aa4-864b-10ddcb64e830
## 5 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/7d665140-5b45-453f-8f64-55f9f4bca1c7
## 6 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/29b8e567-4c54-4397-8e63-9db7e0bdbad4
## 7 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/de5b32f8-d0fc-4ac2-a67b-23c576fd1c6a

Create a dataset

dataset <- gcva_create_tabluar_dataset(
  displayName = datasetDisplayName,
  gcsSource = "gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv")
## 2024-07-08 12:35:23.745031> Waiting 2 seconds...
dataset
## ==Google Cloud Vertex AI Dataset==
## name:                 projects/442003009360/locations/us-central1/datasets/5972519674288537600 
## displayName:          california-housing-20240708123520 
## createTime:           2024-07-08 16:35:21 
## gcsSource:            gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv

List datasets (again)

datasets_list <- gcva_list_datasets()
datasets_list
##                         displayName
## 1 california-housing-20240708123520
## 2 california-housing-20230603152752
## 3 california-housing-20230602151732
## 4 california-housing-20230602151425
## 5 california-housing-20230205131419
## 6 california-housing-20230120172747
## 7 california-housing-20221113133926
## 8 california-housing-20221113163728
##                                                                       name
## 1 projects/442003009360/locations/us-central1/datasets/5972519674288537600
## 2 projects/442003009360/locations/us-central1/datasets/2201923767226073088
## 3 projects/442003009360/locations/us-central1/datasets/4486093203233046528
## 4 projects/442003009360/locations/us-central1/datasets/6945340074754048000
## 5 projects/442003009360/locations/us-central1/datasets/1778563412020690944
## 6 projects/442003009360/locations/us-central1/datasets/1237603691154898944
## 7 projects/442003009360/locations/us-central1/datasets/3229769227103633408
## 8 projects/442003009360/locations/us-central1/datasets/7808241198279163904
##                                                         metadataSchemaUri
## 1 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 2 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 3 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 4 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 5 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 6 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 7 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 8 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
##            createTime                  updateTime
## 1 2024-07-08 16:35:21 2024-07-08T16:35:22.874195Z
## 2 2023-06-03 19:27:55 2023-06-03T19:27:56.201458Z
## 3 2023-06-02 19:17:34 2023-06-02T19:17:35.155780Z
## 4 2023-06-02 19:14:28 2023-06-02T19:14:28.637754Z
## 5 2023-02-05 18:14:20 2023-02-05T18:14:21.078906Z
## 6 2023-01-20 22:27:56 2023-01-20T22:40:21.187713Z
## 7 2022-11-13 18:39:31 2022-11-20T18:46:10.716692Z
## 8 2022-11-13 21:37:42 2022-11-20T18:45:24.758277Z
##                                                                   etag
## 1 AMEw9yMmHoc74kswx972T1KSx5j2x19-6V8uOpFomWwMn3uu4gVWAbc1sGz-ZYfjeguT
## 2 AMEw9yPjAwKH1QSvShTNcbm69QSXo7BkD4sis1UFu1KlE5S8_OxSBYhJom4vWzOyNHc=
## 3 AMEw9yMtqjZn1s8iBc-j7bfryvlLvhLDffeH8-yb2JDIgjgiCnUUTY1ztPqKLYTOYG4=
## 4 AMEw9yMkLA4hWwmyVWdu0KLy6-9xMzn1LdivesnAYB6bUCqYLkvOtkoGA2iA6oAbmCcv
## 5 AMEw9yMJSMrdEAT5ehPUgWolwl7BQzGobaTNS6LgJLTnVgak6wH5PyhbEXJIFWxQNnE=
## 6 AMEw9yPKvmta36Ne82z39V2OsK8a119IzZ_uNZroNrFsH_UPTQKogCYS5lKZWgs8JTY=
## 7 AMEw9yMwHzIHpAxFA1H2XNcCAP50y_j06-yf5eWaMSPGM5NShILDQII9yu5lUONzv5hK
## 8 AMEw9yNvP7PhScQipr6vsSgjkmiysdNY29j8drOzfLfuSeoyj8jyvfRoYLXWniq2IvrD
##                                                                                                      uri
## 1 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 2 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 3 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 4 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 5 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 6 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 7 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 8 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
##                                                                                                    metadataArtifact
## 1 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/d4033141-358f-4ee7-99a7-a4c3c0442c12
## 2 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/b6061e06-1f17-44d5-a8c3-9de7ee8ea62e
## 3 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/31195bd3-ce31-4503-8e42-f884d8c529a7
## 4 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/90e1be4d-35a5-41d4-a9da-f275afc90fb2
## 5 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/4a956544-5cab-4aa4-864b-10ddcb64e830
## 6 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/7d665140-5b45-453f-8f64-55f9f4bca1c7
## 7 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/29b8e567-4c54-4397-8e63-9db7e0bdbad4
## 8 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/de5b32f8-d0fc-4ac2-a67b-23c576fd1c6a

Get a dataset

gcva_dataset(datasetName = datasets_list[1,2])
## ==Google Cloud Vertex AI Dataset==
## name:                 projects/442003009360/locations/us-central1/datasets/5972519674288537600 
## displayName:          california-housing-20240708123520 
## createTime:           2024-07-08 16:35:21 
## gcsSource:            gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv

Delete dataset

gcva_delete_dataset(dataset = dataset)
## 2024-07-08 12:35:24.709219> Dataset successfully deleted.

List datasets

##                         displayName
## 1 california-housing-20230603152752
## 2 california-housing-20230602151732
## 3 california-housing-20230602151425
## 4 california-housing-20230205131419
## 5 california-housing-20230120172747
## 6 california-housing-20221113133926
## 7 california-housing-20221113163728
##                                                                       name
## 1 projects/442003009360/locations/us-central1/datasets/2201923767226073088
## 2 projects/442003009360/locations/us-central1/datasets/4486093203233046528
## 3 projects/442003009360/locations/us-central1/datasets/6945340074754048000
## 4 projects/442003009360/locations/us-central1/datasets/1778563412020690944
## 5 projects/442003009360/locations/us-central1/datasets/1237603691154898944
## 6 projects/442003009360/locations/us-central1/datasets/3229769227103633408
## 7 projects/442003009360/locations/us-central1/datasets/7808241198279163904
##                                                         metadataSchemaUri
## 1 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 2 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 3 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 4 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 5 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 6 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
## 7 gs://google-cloud-aiplatform/schema/dataset/metadata/tabular_1.0.0.yaml
##            createTime                  updateTime
## 1 2023-06-03 19:27:55 2023-06-03T19:27:56.201458Z
## 2 2023-06-02 19:17:34 2023-06-02T19:17:35.155780Z
## 3 2023-06-02 19:14:28 2023-06-02T19:14:28.637754Z
## 4 2023-02-05 18:14:20 2023-02-05T18:14:21.078906Z
## 5 2023-01-20 22:27:56 2023-01-20T22:40:21.187713Z
## 6 2022-11-13 18:39:31 2022-11-20T18:46:10.716692Z
## 7 2022-11-13 21:37:42 2022-11-20T18:45:24.758277Z
##                                                                   etag
## 1 AMEw9yOlb3nUJ4SRORDEmENEiWLvK1rY6wrA01RkOGBG8e2ntvuudMS_hhXqXeuiC-4=
## 2 AMEw9yMwPfC8ht2qZUAMaKSeCDgifLfdcahha2yZkvhLEhGFcrYPD4swp7YQsRHDjwA=
## 3 AMEw9yPyt56MYegH9Azt_TMfUOti091aPrWpXbZXF6rsv6Y16RfFs-Zi6hCDhiWbblZ_
## 4 AMEw9yNrRx-7TujNHt_wRjS5u-mzqc7Y-uclXBuDQDmzwDw57GqvmeMpAFyUMAQRZBI=
## 5 AMEw9yNo6tWezlRBOzCX0wch4OQndKx9xgLi5eeV03aOSWQ2U4ZBEL6lKnNnoqIqChQ=
## 6 AMEw9yMFhzFaujNrEY9RqpLipnIOHRKIWopPbTzm-685cVtrzfi3jj-CURgXgCzTVRuV
## 7 AMEw9yOpS6OcLlDtCWKOczsGrikOHyA99CkWtrJqS9GrWj_kRue2UKBk4oe-95v1odum
##                                                                                                      uri
## 1 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 2 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 3 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 4 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 5 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 6 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
## 7 gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv
##                                                                                                    metadataArtifact
## 1 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/b6061e06-1f17-44d5-a8c3-9de7ee8ea62e
## 2 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/31195bd3-ce31-4503-8e42-f884d8c529a7
## 3 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/90e1be4d-35a5-41d4-a9da-f275afc90fb2
## 4 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/4a956544-5cab-4aa4-864b-10ddcb64e830
## 5 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/7d665140-5b45-453f-8f64-55f9f4bca1c7
## 6 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/29b8e567-4c54-4397-8e63-9db7e0bdbad4
## 7 projects/442003009360/locations/us-central1/metadataStores/default/artifacts/de5b32f8-d0fc-4ac2-a67b-23c576fd1c6a