Compare commits

...
Author SHA1 Message Date
Andrew FerlitschandGitHub 44012a8516 Merge branch 'main' into model_monitoring_setup 2022-08-25 08:22:05 -07:00
Andrew Ferlitsch 479b375f4a fix: review comments 2022-08-25 15:21:03 +00:00
Andrew Ferlitsch 060ab84e33 fix: review comments 2022-08-25 15:18:55 +00:00
Andrew Ferlitsch 49798b1949 Merge branch 'model_monitoring_setup' of https://github.com/GoogleCloudPlatform/vertex-ai-samples into model_monitoring_setup 2022-08-25 15:08:56 +00:00
Andrew Ferlitsch 61786a4b89 fix: review comments 2022-08-25 15:08:07 +00:00
Andrew Ferlitsch 6190eee61b fix: review comments 2022-08-25 15:07:12 +00:00
7cad8680e1 Sdk automl tabular binary classification batch explain (#829)
* Changed prediction_output format from csv to jsonl to support generate_explanations

* ran linter test

* Made the changes as mentioned in the review

* Ran Linter Test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-25 08:05:21 -07:00
Andrew FerlitschandGitHub bdf1cf1a2e Merge branch 'main' into model_monitoring_setup 2022-08-24 21:56:02 -07:00
4f66324883 Google cloud pipeline components automl tabular (#843)
* Removed try except blocks from cleanup section

* Ran Linter test

* Made changes mentioned in review and removed globals

* Removed an unused variable

* Ran Linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-24 21:55:50 -07:00
Andrew FerlitschandGitHub 41f9548e46 Merge branch 'main' into model_monitoring_setup 2022-08-24 16:19:25 -07:00
Andrew Ferlitsch c7527fef2a Merge branch 'model_monitoring_setup' of https://github.com/GoogleCloudPlatform/vertex-ai-samples into model_monitoring_setup 2022-08-24 23:15:27 +00:00
Andrew Ferlitsch 3001067d1e fix: fine-tuning 2022-08-24 23:14:24 +00:00
Andrew Ferlitsch 79470f1747 fix: fine-tuning 2022-08-24 23:12:51 +00:00
468fd144d2 New auto ml tabular classification bean (#787)
* new notebook of classification beans

* new notebook of classification beans

* changes on andrew comments

* changes on andrew comments

* json file issues

* json file issue

* fixes issues from reviews: adds parameter descriptions, fixes clean up, textual updates and replaces gapic functionality

* ran linter test

* adds the missing machine-type parameter

* ran linter test

* retreives the metrics using dict method

* removes unused variables

* ran linter test

* replaces old code for resource-name with new one

* ran linter test

* updates fetching the resourceName from the training artifacts

* ran linter test

* adds wait method for endpoint deployment

* ran linter test

* removes the wait method

* ran linter test

* adds wait gcp resources component

* ran linter test

* updates colab link, removes wait component, sets force to true in delete endpoint step

* ran linter test

* adds endpoint.wait() method

* ran linter test

* moves model deletion down the endpoint deletion and removes endpoint.wait() method

* ran linter test

Co-authored-by: Krishna Chaitanya Movva <krishr2d2@gmail.com>
Co-authored-by: Krishna Chaitanya Movva <krishna.movva@springml.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-24 13:30:48 -07:00
Rosie ZouandGitHub 2503c3411c chore: fix typo in notebook (#900)
This fix was previously made by Yang Pan in https://github.com/googleapis/python-aiplatform/pull/1437 but closed due to the notebook being moved out of the main Vertex SDK repo.
2022-08-24 11:03:22 -07:00
Andrew FerlitschandGitHub 94b27550e8 feat: model monitor notebook (#899)
* feat: new mm notebook

* feat: new mm notebook
2022-08-24 08:56:18 -07:00
Andrew FerlitschandGitHub 7ad550d0c7 Merge branch 'main' into model_monitoring_setup 2022-08-24 08:54:16 -07:00
Soheila ZangenehandGitHub 3542e0b0a3 Add bqml vertexai model registry notebook (#842)
* Add bqml-vertexai-model-registry notebook

* Run linter

* Add notebook to CODEOWNERS file

* Update the links

* Ran linter again

* Rename bigquey-ml folder to model-registry

* Add bigquery-ml folder

* Moved the notebook

* Deleted folder

* Resolve comments

* Use UUID

* Remove using existing endpoint

* Remove try statement

* Get model sample based on model's name

* Use job.result to check query job status

* Run linter

* Fix dataset not found error by adding region in bq client creation

* Revert changes

* Fix bq bugs

* Run linter

* Resolve comments

* Display dataframe

* Updated the codeowner file
2022-08-24 10:58:46 -04:00
Andrew Ferlitsch ff1c7f013b feat: new mm notebook 2022-08-24 05:16:55 +00:00
Andrew Ferlitsch 10f1d368d2 feat: new mm notebook 2022-08-24 05:16:17 +00:00
Andrew FerlitschandGitHub 5cf3b64618 fix: add BQ batch format info (#895)
* fix: add more info on BQ batch format

* fix: add more info on BQ batch format
2022-08-23 09:56:04 -07:00
885bfd56e5 Vertex AI Pipelines - Dataproc Serverless components - Notebook review (#866)
* review dataproc serverless notebook

* linter passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-23 09:44:34 -07:00
3a5eec64af Vertex AI Experiments - Compare pipeline runs - Notebook review (#854)
* experiments cuj1 review

* linter test passed

* typo

* linter test passed

* add correct library. add IAM roles

* linter test passed

* minor fix

* linter test passed

* add api

* linter test passed

* remove library

* linter test passed

* fix

* linter passed

* check

* linter passed

* add text

* linter passed

* minor changes

* andy reviews

* linter passed

* fix link. fix warnings

* linter passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-23 07:57:41 -07:00
8cdc7f1f79 Modified notebook multi_node_ddp_gloo_vertex_training_with_custom_container.ipynb (#886)
* modified notebook according to template

* ran linter

Co-authored-by: gericdong <itseric@google.com>
2022-08-22 10:57:24 -04:00
Ivan CheungandGitHub 84fd10f408 fix: Fixed kernel spec by forcing it to use python3 (#889) 2022-08-19 18:43:07 -07:00
Andrew FerlitschandGitHub 7804c860c5 fix: replace tabs with spaces in JSON template (#888)
* fix: replace tabs with spaces in JSON template

* fix: replace tabs with spaces in JSON template
2022-08-19 11:11:08 -07:00
Andrew FerlitschandGitHub ed0c1c74a6 fix: typo in serving_container_uri parameter (#887) 2022-08-19 08:49:12 -07:00
Andrew FerlitschandGitHub 5127a59e92 Model monitoring (#883)
* fix: notebook template tuning

* fix: notebook template tuning

* fix: possible confusion on when to wait for the email notification

* fix: possible confusion on when to wait for the email notification
2022-08-19 08:38:29 -07:00
d8df732d6b Replace GAPIC with SDK - Model Monitoring Notebook (#879)
* Replace GAPIC with SDK

* Run linter

* Remove unused variables

* Run linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-18 11:41:11 -07:00
9c10899db8 AutoML Video Classificaton (#871)
* changes according to andrew review comments

* changes according to andrew review comments

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-18 07:25:14 -07:00
Ivan NardiniandGitHub 80770188ec Vertex AI Experiments - Model training - Notebook review (#853)
* experiments cuj1 review

* linter test passed

* add IAM role

* linter test passed

* add rm local dir

* linter test passed

* add api

* linter test passed

* remove libraries

* linter test passed

* solve build error

* fix issue

* clean

* linter passed

* fix dependency

* linter passed

* add dependency

* linter passed

* add dependency

* linter passed

* delete bucket flag fix

* linter passed
2022-08-17 10:43:34 -04:00
fa91e45018 Adds the updated managed_notebooks/predictive_maintenance notebook to the official folder (#521)
* adds the updated predictive-maintenance (managed)notebook from community to official folder

* ran linter test

* resubmitting during phase2

* ran linter test

* addresses the review comments: updates based on the new template, sets delete_bucket to False

* ran linter test

* replaces timestamp with uuid

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-16 09:39:07 -07:00
fa27309134 Fixes the issues from the regression tests (#822)
* fixes tensorflow version, replaces timestamp with uuid, adds service-account and minor textual changes

* removes second defnition of random library

* ran linter test

* uncomments the user flag and updates the installation command

* ran linter test

* removes the extra backslash

* ran linter test

* updates the installation step to fix long running compatibility checks

* ran linter test

* updates the METADATA path during installation steps

* ran linter test

* adds google-api-core version in the installation

* ran linter test

* removes METADATA step during installation

* ran linter test

* updates google api-core & auth versions

* ran linter test

* fixes tensorflow version, replaces timestamp with uuid, adds service-account and minor textual changes

* removes second defnition of random library

* ran linter test

* uncomments the user flag and updates the installation command

* ran linter test

* removes the extra backslash

* ran linter test

* updates the installation step to fix long running compatibility checks

* ran linter test

* updates the METADATA path during installation steps

* ran linter test

* adds google-api-core version in the installation

* ran linter test

* removes METADATA step during installation

* ran linter test

* updates google api-core & auth versions

* ran linter test

* fixes the issues from review: cell descriptions, parameter definitions, tense changes, 3rd person --> 2nd person, list model after pipeline run

* ran linter test

* removes the METADATA hack and updates the installations

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-16 09:11:30 -07:00
udaypunnaandGitHub 7b85f76384 custom_model_training_and_batch_prediction (#873)
* changed based on andrew review comments

* changed based on andrew review comments

* import library issues

* import library issues

* import issues

* import issues
2022-08-16 08:40:33 -07:00
40a0477b08 modified notebook automl-text-classification.ipynb (#757)
* modified notebook

* modified notebook

* added new notebook

* added new notebook

* new auto_ml_text_classifiation

* new auto_ml_text_classifiation

* new automl text classification

* linter test

* linter test

* changes on andrew comments

* changes on andrew comments

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-15 17:53:52 -07:00
839c7dddb8 Vertex AI Experiments - Compare Models - Notebook review (#852)
* experiments cuj1 review

* linter test passed

* typo

* linter test passed

* add andy reviews

* linter test passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-15 09:49:50 -07:00
Andrew FerlitschandGitHub 578cfb7da7 fi: Issue 850 (#863)
* fix: add missing end_run() for experiment

* fix: add missing end_run() for experiment
2022-08-15 08:57:07 -07:00
Ivan CheungandGitHub b129c0bf43 Update CODEOWNERS (#864)
Use proper Github username.
2022-08-12 17:21:39 -04:00
07b4c37135 Automl links fix (#742)
* fixing links to open notebook - main and images

* linter test changes

* fixes the papermill execution error(hard-coded bucket link was the cause)

* ran linter test

* adds minor textual changes

* ran linter test

* fixes issues from review: future tense, copyright year, section placement, latest sdk methods, new updates from the template

* ran linter test

Co-authored-by: Manuel Amunategui <manuel.amunategui@springml.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-12 12:34:53 -07:00
f48fb1c650 Modified file churn_prediction_for_game_developers (#809)
* made changes

* made changes

* ran linter test

* made changes

* ran linter

* made changes

* ran linter

* changes suggested by andrew done

* ran linter

* replaced timestamp with uuid

* ran linter

* changed bucket creation command according to template

* ran linter

* changed text in overview

* changed region cell from markdown to code

* made changes

* replaced dataset from constant to a variable

* replaced constant dataset_id with a variable

* ran linter

* changed suggested by andrew done

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-12 08:40:38 -07:00
3bbd59311c Made UUID Changes to SDK_BigQuery_Custom_Container_Training.ipynb (#849)
* MAde UUID changes

* Ran Linter test

* made some minor changes

* Ran Linter Test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-12 08:08:32 -07:00
Krishna Chaitanya MovvaandGitHub 15bb4cea73 Fixes the issues(missing variable) from regression tests, adds minor updates from the template. (#823)
* adds the missing delete_bucket variable, adds steps to configure SERVICE_ACCOUNT

* removes unnecessary random import

* ran linter test

* removes the src folder dependency to run on Colab, adds the pipeline.wait step, updates the cleanup steps

* ran linter test

* fixed issues from review: section posistions, tense changes, section descriptions, template updates

* ran linter test
2022-08-12 08:07:11 -07:00
Andrew FerlitschandGitHub 1511cc9fd1 fix: branding updates from autoreview (#862)
* autoreview: branding fixes

* fix: improve installation detection

* cleanup: rm tmp file

* fix: lint issues

* fix: 2nd try at lint fixes
2022-08-11 18:32:47 -07:00
2885a7a70f Migrated matching engine notebook to official and added VPC network support to CI (#836)
* Added matching engine notebook official

* Ran linter

* Added matching engine to .cloud-build/test_notebook_vm.txt

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 18:30:22 -07:00
ea36f5c43e Vertex SDK Custom Image Classification with pre-built training container (#833)
* new notebook of custom image classification

* new notebook of custome image classification

* andrew commented changes

* andrew commented changes

* andrew commented changes

* andrew commented changes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 14:58:49 -07:00
a905a6305f fixed cleanup cell, cosmetic and doc improvements, and removed load test (to avoid flakiness), (#859)
* fix cleanup cell and print out more info on xai prediction test

* lint fix

* remove load test

* lint fixes

* lint fix

* fix andrews comments

* lint fix

* missing newline

* lint fixes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 14:04:28 -07:00
Ivan CheungandGitHub aeaeddcc75 Update PULL_REQUEST_TEMPLATE.md (#860)
Updated PR template to emphasize need for a summary and checklist. Otherwise, people tend to skip this standard practice.
2022-08-11 16:18:54 -04:00
161965cfb0 Fixes the exception in batch-explain notebook in the official folder (#810)
* fixes exception(reg-test), replaces timestamp with uuid, minor changes

* ran linter test

* resolved review comments: license year, Vertex AI SDK, dataset after objective and future tense

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 10:25:51 -07:00
b9d4457474 Modified notebook forecasting-retail-demand (#827)
* deleted file in community and added file in official folder

* renamed file

* ran linter test

* renamed file

* ran linter

* made changes

* ran linter test

* made changes

* ran linter test

* made changes

* ran linter test

* made changes

* ran linter

* made change

* ran linter test

* changes suggested by andrew done

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 09:31:27 -07:00
a5b6bcfab1 those two files are moved to official folder.Deleting them in community content (#855)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 09:14:02 -07:00
5d55f5b0d2 Modified notebook pricing-optimization.ipynb (#834)
* modified notebook according to notebook_template.

* ran linter

* Added create dataset step

* ran linter

* replaced hardcoded dataset name with a variable

* ran linter

* changes suggested by nadrew done

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 09:00:13 -07:00
36ace6f4a6 deleted inventory_prediction_folder,folder moved to official (#856)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 08:24:39 -07:00
32d9b416c1 UUID changes done comparing_pipeline_runs.ipynb (#759)
* done UUID changes

* ran lintertest

* made changes in cleanup section

* ran lintertest

* done UUID changes

* ran lintertest

* made changes in cleanup section

* ran lintertest

* made changes in cleanup section

* Ran linter test

* made UUID changes

* RAN linter test

* Made Some minor Chanages notebook

* Ran Linter Test

* small changes made

* Ran Linter Test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-11 08:07:17 -07:00
1c6309f401 Modified notebook SDK_AutoML_Video_Classification.ipynb (#839)
* modified notebook according to template, tensorflow library is used only for file opening so instead of tf we used bucket.blob.download_as_string()

* ran linter

* all changes requested by andrew are done

* cleared all outputs

* making changes to run linter test

* making changes to run linter test

* ran linter

* removed region text in create bucket step

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-10 19:05:41 -07:00
728dec8526 Updates the custom-tabular-bq-managed-dataset notebook according to the new template (#780)
* updates the configuring steps, replaces timestamp with uuid, expands the imports

* ran linter test

* separates the vertex-ai and bigquery initialization steps

* adds comment to cell_24

* adds blank line to cell_24:7:1

* adds blank line to cell_24:7:1

* ran linter test

* fixes aiplatform+bigquery installation compatibility issue

* ran linter test

* fixes installation dependencies

* ran linter test

* fixes the issues from the review: future tense, section positions, updates from the latest template

* ran linter test

* fixes the issues from the review: Code formatting, delete redundant cells, resource name changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-10 08:41:50 -07:00
sudarshan-SpringMLandGitHub 7692f902dd Added minor changes to training-multi-class-classification-model-for-ads-targeting-usecase notebook (#735)
* added new file

* ran linter test

* made small changes

* ran linter

* added file

* ran linter

* changes requested by andrew done

* ran linter
2022-08-10 08:03:42 -07:00
9281403198 fix cleanup cell to undeploy models before deleting endpoint and remove BQ table and dataset (#846)
* fix artifact cleanup

* lint fixes

* remove extraneous echo

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-09 20:09:25 -07:00
2be602fbef Update comparing_local_trained_models.ipynb (#704)
Install from Pypi

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-09 15:39:54 -07:00
b140077eb1 Change REGION_NAME to REGION to match flag set earlier in notebook (#734)
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-09 14:54:22 -07:00
d3139f7df8 Added colab , installed some packages, added some code based on standard template and made changes in cleanup section for the file inventory_prediction.ipynb (#533)
* Added notebook

* Ran linter test

* added pyarrow to install

Co-authored-by: Andrew Ferlitsch <aferlitsch@gmail.com>
Co-authored-by: sudarshan-SpringML <82567512+sudarshan-SpringML@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-09 14:49:40 -07:00
72baced988 model monitoring notebook fixes (#841)
* fix model monitoring notebook

* lint fixes

* fixed Soheila's review comments

* fix Andrew's comments

* lint fixes

* clean up install packages per review request

* lint fixes

* fix more comments from Andrew

* lint fixes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-09 14:16:54 -07:00
Soheila ZangenehandGitHub 5232654705 Update folder name to training (#845) 2022-08-09 12:29:34 -07:00
Andrew FerlitschandGitHub 125fe32eb2 feat: notebook for DASK training (#837)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review script

* tune: project ID and Region

* tune: project ID and Region

* fix: set MODEL_DIR for HPT

* fix: set MODEL_DIR for HPT

* feat: add batch example

* feat: add batch example

* feat: add batch example

* feat: add batch example

* feat: add notebook for DASK training

* feat: add notebook for DASK training
2022-08-08 16:17:28 -07:00
Andrew FerlitschandGitHub 614f4154dc fix: owner names 2022-08-08 15:50:33 -07:00
Andrew FerlitschandGitHub 970415398b fix: owner username 2022-08-08 15:46:57 -07:00
Hyunuk LimandGitHub a052a3d361 A new notebook for Spark Sample (#720)
* Created spark notebook with test code

* Implemented experimental code for poly_view

* implemented the table

* WIP-notebook

* moved experimental to tutorial

* delete experimental code and rename the notebook

* clear all outputs

* fix: delete outputs again

* fix: changed template to the newer one

* fix: modify link on workbench

* add creating a cluster

* Completed Before you begin part

* Change execution sequence

* completed write back process

* change order that switching kernel goes top

* modify pie chart to bar chart

* Completed write up part

* WIP: adding description and comments.

* WIP: delete outputs

* fix: nbqa done

* Completed the first draft

* Delete %%time from cells

* Apply changes as per the code review from Brad except SparkSql

* delete outputs

* Change SparkSQL to Spark API

* change label to xlabel

* fix: description in Dataset

* fix: change BUCKET_NAME to DATASET_NAME, link for the region, and add descriptions and examples for frequency table

* fix: move normalize_name to top of the cell

* fix: refactor udf functions and descriptions

* fix: add link for udf

* fix: description in Dataset

* fix: grammer

* fix: add declared in the sentence

* fix: small changes on grammar

* fix: delete string

* fix: change UserDefinedFunction to udf

* fix: as per TW's code review

* fix: reorder REGION and TIMESTAMP under Creating a GCS bucket

* fix: lint

* chore: add bmiro@ as a codeowner of this doc

* fix: change the variable to fix a bug

* fix: as per TW's second review

* fix: add installation part to pass the ci test

* fix: url for links to main

* fix: delete disabling API since it doesn't affect to the pricing

* fix: add conditions for CI test

* fix: changed jar for testing

* fix: add gcs connector

* fix: change writing method to direct

* fix: delete gcs connector

* fix: specify java folder

* fix: change java_home location

* fix: change unzip instruction

* fix: delete mono_ranking_avg_bytes from testing env

* fix: delete frequency_table from testing env

* fix: delete GCS bucket part

* fix: as per Brad's review

* fix: lint

* fix: add version

* fix: change comment

* fix: add package due to switching the kernel

* fix: delete dataproc cluster command

* fix: change link

* fix: change link

* fix: revert cluster deletion command

* fix: change parenthesis to encoded character

* fix: change the name of the notebook

* fix: change timestamp to UUID

* fix: change the link and add description

* fix: change metadata
2022-08-08 16:23:16 -04:00
Krishna Chaitanya MovvaandGitHub f8203b9f46 UUID replaces Timestamp in the notebook template (#745)
* replaces timestamp with uuid #create *task #tag1 replace the TIMESTAMP with uuid in other official notebooks

* ran linter test

* updates the uuid code

* fixes the comment style highlighted through linter-test

* ran linter test

* adds length argument to uuid function defaulted to 8

* ran linter test
2022-08-08 11:20:33 -04:00
Andrew FerlitschandGitHub fac8c4c9b1 fix: improve batch description (#830)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review script

* tune: project ID and Region

* tune: project ID and Region

* fix: set MODEL_DIR for HPT

* fix: set MODEL_DIR for HPT

* feat: add batch example

* feat: add batch example

* feat: add batch example

* feat: add batch example
2022-08-05 13:50:14 -07:00
Andrew FerlitschandGitHub d6c13c201e Ml ops v9v4 (#817)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review script

* tune: project ID and Region

* tune: project ID and Region

* fix: set MODEL_DIR for HPT

* fix: set MODEL_DIR for HPT

* feat: add batch example

* feat: add batch example
2022-08-05 09:40:11 -07:00
Soheila ZangenehandGitHub 8db9ce0415 Move download link up (#813) 2022-08-04 15:05:18 -04:00
Ivan CheungandGitHub 8c7fb38136 Added missing dependency (#814) 2022-08-04 14:53:17 -04:00
Andrew FerlitschandGitHub acec861ad5 tune: notebook template (#812)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review script

* tune: project ID and Region

* tune: project ID and Region
2022-08-04 10:51:08 -07:00
Andrew FerlitschandGitHub b5cc2b425e feat: auto review script tuning (#811)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review script
2022-08-04 09:30:13 -07:00
Soheila ZangenehandGitHub 710e6ea0d8 Run commands in quiet mode (#789)
* Run commands in quiet mode in both yaml files
* Test CI against single and multiple notebooks
2022-08-04 11:00:49 -04:00
4dce246b57 Add single notebook test file and remove broken notebook from the list (#801)
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-08-04 10:39:09 -04:00
Andrew FerlitschandGitHub 696efb00ee fix: auto review (#807)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review
2022-08-03 21:19:10 -07:00
Andrew FerlitschandGitHub fea73bb9c0 obsolete 2022-08-03 20:28:16 -07:00
Andrew FerlitschandGitHub f50ea24dd1 fix: auto review (#806)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review
2022-08-03 20:27:45 -07:00
Andrew FerlitschandGitHub 473e673d0a fix: auto review (#805)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review
2022-08-03 17:22:25 -07:00
Andrew FerlitschandGitHub 127297ee4e tune: grammar 2022-08-03 15:38:44 -07:00
Chun-Hsiang WangandGitHub fb528b60c6 samples: Minor fix for CPR existing image use cases. (#778) 2022-08-03 15:23:35 -07:00
Andrew FerlitschandGitHub 1c1a2b2097 fix: auto review (#804)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review

* feat: auto review

* fix: auto review
2022-08-03 14:56:26 -07:00
Andrew FerlitschandGitHub 8cb2a26817 fix: auto review (#803)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* feat: auto review

* feat: auto review
2022-08-03 14:38:14 -07:00
Andrew FerlitschandGitHub 3bf098b361 feat: auto review (#802)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review
2022-08-03 14:19:49 -07:00
433cffbf76 Tabnet (#732)
* Start a new branch for TabNet tutorial.

* format lint

* Clean version Created using Colaboratory

* Remove unused import

* Remove unused import

* Created using Colaboratory

* add import

* Add visualization for TabNet

* add gcs

* run format

* reformat

* reformat

* Rmove the - file

* run linter

* run linter

* Update the objective and data section

* Update the link.

* Update data description.

* Update data description.

Co-authored-by: Long Le <longtle@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 13:42:06 -07:00
0ec2f4fbe8 bugfix: pass Dataflow related parameters correct for AutoML Tabular pipeline notebook (#725)
Also corrected the required Roles for the service account.

Co-authored-by: Helin Wang <helin@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 13:39:32 -07:00
a9af97f1b9 Added notebook demonstrating Tensorboard Custom Training with custom container. (#611)
* Added notebook demonstrating Tensorboard Custom Training with custom container.

* Added notebook demonstrating Tensorboard Custom Training with custom container.

* update codeowners file

* call Vertex API instead of gapic API

* resolve comments for custom container

* resolve comments and format

* resolve comments

* using --quiet for delete doctor repository

* address more comments

Co-authored-by: gericdong <itseric@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 13:37:14 -07:00
d6431fab4c Added notebook demonstrating Tensorboard Custom Training with prebuilt container. (#603)
* Added notebook demonstrating Tensorboard Custom Training with prebuilt container

* Added notebook demonstrating Tensorboard Custom Training with prebuilt container

* small fix

* address comments

* format

* update project id to be [your-project-id], and populate tensorboard resource name automatically

* Added notebook demonstrating Tensorboard Custom Training with prebuilt container

* Added notebook demonstrating Tensorboard Custom Training with prebuilt container

* small fix

* address comments

* format

* fix typo for service account

* use vertex api instead of gapic api

* address comments

* minor fix

* minor fix for link

* minor fix

* resolve more comments

* a minor fix for comment

* format the notebook

* resolve comments

* address more comments

Co-authored-by: gericdong <itseric@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 13:35:41 -07:00
dcfde86928 Added colab , installation packages and few other changes to chicago_taxi_fare_prediction.ipynb file (#515)
* Added notebook

* Made changes in installing packages code cell

* Ran linter test

* fixes the installation issues and updates some textual content

* fixes the # formatting for comments

* ran linter test

* adds pyarrow to the packages

* ran linter test

* replaces timestamp with uuid

* ran linter test

* updates the uuid code

* fixes the comment style highlighted through linter-test

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: krishr2d2 <krishna.movva@springml.com>
2022-08-03 13:33:08 -07:00
5d747ffa0d Refresh of PyTorch Image Classification Multi-Node Distributed Data Parallel Training on GPU using Vertex Training with Custom Container (#509)
* notebook refresh from vertex ai sdk project

* linter test

* notebook refresh from vertex ai sdk project with trainer folder

* linter test

* add pyarrow

* modified notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@gmail.com>
Co-authored-by: sudarshan-SpringML <sudarshan.c@springml.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 13:32:44 -07:00
53f25201cc Made minor changes to SDK_Custom_Training_Python_Package_Managed_Text_Dataset_Tensorflow_Serving_Container notebook (#507)
* modified notebook

* small changes done

* modified notebook and moved notebook to official folder

* ran linter test

* resolved comments

* ran linter test

* sentence case heading added for some more text

* ran linter test

* made changes

* ran linter test

* made changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 13:32:01 -07:00
9b17db3025 Refresh of PyTorch Image Classification Multi-Node Distributed Data Parallel Training on CPU using Vertex Training with Custom Container Notebook (#489)
* multi_node_ddp_gloo_vertex_training_with_custom_container refresh and related trainer folder

* linter test

* various fixes and colab update

* linter test

* modified notebook

* modified notebook

* ran linter test

* Update multi_node_ddp_gloo_vertex_training_with_custom_container.ipynb

Co-authored-by: sudarshan-SpringML <sudarshan.c@springml.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 13:24:45 -07:00
423f7ac584 Adding PrivateEndpoint CUJ notebook to notebooks/community (#721)
* moving REGION up

* moving REGION up and csv file name

* fix: changed bucket URL to console

* removing TODOs from Tabnet notebook

* adding notebook and editing CODEOWNERS file

* fixing links

* adding to community because of test issue

* removing CODEOWNERS

* reverting CODEOWNERS

* linting?

* adding fixes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-08-03 12:54:46 -07:00
aec82c7e5b inardini -- bqml new operators release update to v1 (#717)
* update to v1

* linter test passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 12:51:46 -07:00
b227509fbb chore(deps): update dependency black to v22.6.0 (#696)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-03 12:43:54 -07:00
Andrew FerlitschandGitHub e715e68273 fix: auto review (#800)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review
2022-08-03 12:39:06 -07:00
406de6fe9a Adds the updated sdk-feature-store-pandas notebook to official from community folder (#488)
* adds the updated sdk-feature-store-pandas notebook to official and removes it from the community

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: nayaknishant <nishantnayak@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-08-03 12:30:10 -07:00
Andrew FerlitschandGitHub eacc49d911 fix: auto review (#798)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auto review

* fix: auto review
2022-08-03 12:26:12 -07:00
Andrew FerlitschandGitHub b95959e7a1 cleanup 2022-08-03 10:58:57 -07:00
Andrew FerlitschandGitHub cc2cf876de fix: auto review (#797)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review
2022-08-03 10:58:27 -07:00
Andrew FerlitschandGitHub 1047237335 Ml ops v9v4 (#796)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review
2022-08-03 10:11:23 -07:00
Andrew FerlitschandGitHub 791d589d41 Ml ops v9v4 (#795)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review
2022-08-03 09:53:21 -07:00
Andrew FerlitschandGitHub f7bdf75d90 fix: auto-review (#794)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review
2022-08-03 09:37:14 -07:00
Andrew FerlitschandGitHub 785ca9f864 fix: auto review (#793)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review

* fix: auti review

* fix: auti review
2022-08-03 09:22:59 -07:00
Andrew FerlitschandGitHub aaa7d5c259 fix: auto review (#792)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auti review

* fix: auti review
2022-08-03 09:01:37 -07:00
Andrew FerlitschandGitHub e21cb948d6 feat: auto review (#784)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review

* fix: auto review

* fix: auto review
2022-08-02 18:46:08 -07:00
Andrew FerlitschandGitHub 5551c5f895 fix: auto review (#783)
* feat: tune template

* feat: tune template

* fix: auto review

* fix: auto review
2022-08-02 18:29:21 -07:00
Andrew FerlitschandGitHub e8853475bc feat: tune template (#782)
* feat: tune template

* feat: tune template
2022-08-02 17:33:32 -07:00
Andrew FerlitschandGitHub 33cb8139da Update get_started_vertex_training_lightgbm.ipynb 2022-08-02 16:33:03 -07:00
Andrew FerlitschandGitHub 0288fa3703 fix: link 2022-08-02 16:32:25 -07:00
Andrew FerlitschandGitHub d48edc2cb4 fix: links 2022-08-02 16:27:45 -07:00
Andrew FerlitschandGitHub 7b26f01671 fix: link 2022-08-02 16:25:45 -07:00
Andrew FerlitschandGitHub 59cd2cda3c fix: link 2022-08-02 16:23:46 -07:00
Andrew FerlitschandGitHub 3ac469f57c fix: link 2022-08-02 16:12:59 -07:00
Andrew FerlitschandGitHub 008833422c fix: link 2022-08-02 14:47:08 -07:00
Andrew FerlitschandGitHub 59c85c3085 fix: link 2022-08-02 14:44:57 -07:00
Andrew FerlitschandGitHub f2b5d0924e fix: link title 2022-08-02 14:35:38 -07:00
Andrew FerlitschandGitHub 772cd44cef fix: link 2022-08-02 14:28:58 -07:00
Andrew FerlitschandGitHub 379a4c6a1c fix: link 2022-08-02 14:27:16 -07:00
Andrew FerlitschandGitHub 5cea72848e fix: link 2022-08-02 14:25:47 -07:00
Andrew FerlitschandGitHub 9c12dd811b fix: links 2022-08-02 14:22:38 -07:00
Andrew FerlitschandGitHub 844cf5b047 fix: links 2022-08-02 14:19:52 -07:00
Andrew FerlitschandGitHub 1492051560 fix: link 2022-08-02 14:06:43 -07:00
Andrew FerlitschandGitHub 40bdd5fce3 fix: link 2022-08-02 14:03:36 -07:00
Andrew FerlitschandGitHub d1cc60e8d7 fix: link 2022-08-02 13:50:36 -07:00
Andrew FerlitschandGitHub 7ca4cf9912 fix: links 2022-08-02 13:34:59 -07:00
Andrew FerlitschandGitHub 294e40cb61 fix: link 2022-08-02 13:27:09 -07:00
Andrew FerlitschandGitHub f69e43d3d6 fix: link 2022-08-02 13:24:41 -07:00
Andrew FerlitschandGitHub 582c479dbe fix: link 2022-08-02 13:23:07 -07:00
Andrew FerlitschandGitHub f83660cf62 fix: link 2022-08-02 13:15:55 -07:00
Andrew FerlitschandGitHub e948fae793 fix: link 2022-08-02 13:13:57 -07:00
Andrew FerlitschandGitHub cd51333ff1 fix: link 2022-08-02 13:13:00 -07:00
Andrew FerlitschandGitHub cf5d266bd7 fix: link 2022-08-02 13:09:57 -07:00
Andrew FerlitschandGitHub 8ef840affb fix: link 2022-08-02 12:59:31 -07:00
Andrew FerlitschandGitHub 4dcc3d0183 fix: link 2022-08-02 12:31:11 -07:00
Andrew FerlitschandGitHub 0bcb6a8d8e fix: title 2022-08-02 12:24:32 -07:00
Andrew FerlitschandGitHub d26b385ec7 fix: title 2022-08-02 12:23:44 -07:00
Andrew FerlitschandGitHub d5a2766aa4 Update get_started_with_matching_engine.ipynb 2022-08-02 12:22:14 -07:00
Andrew FerlitschandGitHub 7abfbb5473 fix: title 2022-08-02 12:21:41 -07:00
Andrew FerlitschandGitHub 096423da33 fix: notice 2022-08-02 12:11:17 -07:00
Andrew FerlitschandGitHub 89a133549c fix: pinning (#779)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* fix: pinning

* fix: pinning
2022-08-01 19:56:29 -07:00
648f1c34e0 Add notebook to show how to deploy BQML models for online prediction via Vertex AI Model Registry (#736)
* adding new notebook on BQML online pred via Model Registry

* minor changes

* fixes to linting

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-01 08:42:51 -07:00
Andrew FerlitschandGitHub 3f21907c31 feat: autodiscover (#775)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover
2022-07-29 22:23:59 -07:00
Andrew FerlitschandGitHub fce66b3e57 fix: title (#774)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* fix: title

* fix: title
2022-07-29 22:19:45 -07:00
Andrew FerlitschandGitHub 3b140f9caa fix: title (#773)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title
2022-07-29 21:57:11 -07:00
Andrew FerlitschandGitHub 89325d7e52 feat: autodiscover (#772)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover
2022-07-29 19:58:21 -07:00
Andrew FerlitschandGitHub e4d44f02d6 feat: autodiscover (#771)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title
2022-07-29 19:54:08 -07:00
Andrew FerlitschandGitHub 78993c4729 fix: title (#770)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover

* fix: title

* fix: title
2022-07-29 16:28:15 -07:00
Andrew FerlitschandGitHub c29e7d86bd feat: autodiscover (#769)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title

* feat: autodiscover
2022-07-29 16:18:24 -07:00
Andrew FerlitschandGitHub a8793fb00a fix: title (#768)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover

* fix: title

* fix: title
2022-07-29 16:08:49 -07:00
Andrew FerlitschandGitHub bb60a7d0db Ml ops v9v3 (#767)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* feat: autodiscover

* feat: autodiscover
2022-07-29 15:08:27 -07:00
Andrew FerlitschandGitHub eef758c719 feat: autodiscover index (#766)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title
2022-07-29 15:06:34 -07:00
Andrew FerlitschandGitHub 486ef17ab8 fix: title (#765)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title

* fix: title
2022-07-29 14:57:39 -07:00
Andrew FerlitschandGitHub 90dfef3db6 fix: title (#764)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title
2022-07-29 14:35:34 -07:00
Andrew FerlitschandGitHub d59c87b387 fix: title (#763)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover

* fix: title

* fix: title
2022-07-29 13:27:46 -07:00
Andrew FerlitschandGitHub 9d69b77ac6 feat: autodiscover index (#762)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title

* feat: auto-discover
2022-07-29 13:04:48 -07:00
Andrew FerlitschandGitHub b0da5d69f8 update: tune title (#761)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release

* update: tune title

* update: tune title
2022-07-29 12:44:46 -07:00
Andrew FerlitschandGitHub 830e10e583 upgrade: updates for new release (#760)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template

* upgrade: updates for new release

* upgrade: updates for new release
2022-07-29 12:17:43 -07:00
kthytangandGitHub db904b424e chore: Update CPR notebooks. (#756)
* chore: Update CPR notebooks to pip install latest released Vertex SDK pypi package.

* Update CPR notebooks wording for experimental -> preview.

* Update Objectives wording

* Update github links to main branch.

* Update Sklearn interface.

* Fix formatting and typos.

* Update Predictor interface
2022-07-28 17:13:50 -07:00
Andrew FerlitschandGitHub c371f05bfa fix: split guidelines from template (#754)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template

* fix: split guidelines from template

* fix: split guidelines from template
2022-07-28 08:13:04 -07:00
Andrew FerlitschandGitHub 5f7de16e2d fix: split off authoring guidelines (#753)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF

* fix: split guidelines from template
2022-07-28 08:08:55 -07:00
Andrew FerlitschandGitHub 3908580ad6 feat: add notebook for non-TF HPT (#751)
* feat: import automl tabular model

* feat: import automl tabular model

* feat: HPT for non-TF

* feat: HPT for non-TF
2022-07-27 14:57:24 -07:00
Andrew FerlitschandGitHub 77d2cac20a Update README.md 2022-07-27 13:39:38 -07:00
Andrew FerlitschandGitHub a92d5ce473 Update README.md 2022-07-27 13:38:51 -07:00
Andrew FerlitschandGitHub 416ec74af3 add entry 2022-07-27 13:37:51 -07:00
Andrew FerlitschandGitHub 8443bbfe44 feat: notebook for importing automl tabular model (#750)
* feat: import automl tabular model

* feat: import automl tabular model
2022-07-27 13:35:04 -07:00
kthytangandGitHub 23a599068a Update CPR notebooks. (#741)
* Update CPR notebooks.

- Update interfaces
- Fix missing timestamp
- Rename some variables

* Update cpr preprocess notebook.

- Change preprocessor import path.

* Update SDK_Custom_Predict_SDK_Integration.ipynb

* Update SDK_Custom_Predict_and_Handler_SDK_Integration.ipynb

* Update SDK_Pytorch_Custom_Predict.ipynb

* Update SDK_Triton_PyTorch_Local_Prediction.ipynb

* Fix lint and revert path change for pickle dumping preprocessor.
2022-07-27 10:58:28 -07:00
gericdongandGitHub c63bb4c464 New notebook to demonstrate how to enable TensorBoard Profiler (#719)
* New notebook to demonstrate how to enable TensorBoard Profiler

* Reformatted with Lint

* Changed service account handling and added a step to monitor job state

* Addressed review comments

* Addressed technical writerreview comments

* Addressed Ivan review comments

* Switched from GAPIC to Vertex SDK

* Removed an unused package

* Addressed review comments
2022-07-26 14:39:37 -04:00
Ivan CheungandGitHub 2226e915c0 Update CODEOWNERS 2022-07-25 16:24:10 -04:00
Ivan CheungandGitHub cd9f8b1d89 Update CODEOWNERS 2022-07-25 15:01:46 -04:00
Ivan CheungandGitHub aae9ad0422 Update CODEOWNERS 2022-07-25 15:00:33 -04:00
Ivan CheungandGitHub 89d50579a6 Add @GoogleCloudPlatform/caiis-tw to CODEOWNERS
Add @GoogleCloudPlatform/caiis-tw to default.
2022-07-25 15:00:01 -04:00
Ivan CheungandGitHub 2d6afa8313 Added better download instructions (#738)
* Improve download instruc
tions

* Added web download to notebook results list
2022-07-22 18:21:05 -04:00
Ivan CheungandGitHub 00cfb20c36 Notebook CI: Fixed variable replacement to handle numbers (#739)
* Removed replacement of variable comparisons

* Fixed issue with numbers in replacement content
2022-07-22 11:50:39 -04:00
Ivan CheungandGitHub 14c87ae702 Removed replacement of variable comparisons (#737) 2022-07-21 19:21:02 -04:00
e2a6610c2d Add an example use case for custom prediction routines. (#709)
* Add an example use case for custom prediction routines.

* Addressing some PR comments: reworded the readme in a few places, added a 'probe' command to build.py that sends a sample predict request, and pinned versions in requirements. Also fixed a bug where the artifacts_uri passed in during deployment on Vertex AI was not recognized as a directory.

* Autoformat code with black and fix a couple of typing errors.

* Addressing PR comments: Add deployment machine type to the config and add docstring to probe_prediction method.

* Update example to work with new LocalModel interface.

* Update example to work with new LocalModel interface.

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-07-21 12:42:31 -07:00
Ivan CheungandGitHub 145cdd0928 Added a service account injection (#695)
* Added a service account injection

* Revert this

* Added service account injection

* Fixed cloud build file

* Added gcloud version debug info

* Fixed sa injection

* Removed test file

* Revert CODEOWNERS
2022-07-21 15:04:10 -04:00
Michael HuandGitHub 04e1697bca fix workbench link in new tables notebooks (#714) 2022-07-21 09:29:06 -04:00
Ivan CheungandGitHub be785d0389 Allow outputs (#733) 2022-07-20 17:31:12 -04:00
MarcandGitHub 976e346a3d rm open in cloud notebook until tested there, also fix open links to use community for now (#731) 2022-07-20 21:48:07 +01:00
e37caca496 chore(deps): update dependency nbqa to v1.4.0 (#727)
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-07-19 13:06:00 -05:00
MarcandGitHub 7a48fe8850 add community notebook (#729) 2022-07-19 07:52:03 +01:00
Ivan NardiniandGitHub 915a1edba8 inardini - vertex explainable ai example based api example using sdk gapic (#716)
* new notebook

* linter test passed.

* add codeowners

* review

* reviews

* linter test passed.

* last review. linter test passed
2022-07-16 19:12:46 -04:00
MarcandGitHub 424f947b04 avoid linter reformatting that breaks this notebook in colab (#715)
* fix formatting for colab

* disable black formatting selectively
2022-07-12 16:23:29 -07:00
Andrew FerlitschandGitHub c95f73c1a8 fix: bad link (#712)
* feat: notebook on model registry

* feat: notebook on model registry

* feat: workflow notebook

* feat: workflow notebook

* feat: workflow notebook

* fix: objective

* fix: objective

* fix: link

* fix: link
2022-07-07 12:51:14 -07:00
Andrew FerlitschandGitHub 9da033c887 Update README.md 2022-07-06 14:40:51 -07:00
Andrew FerlitschandGitHub f61f9bfdc2 feat: notebook for automl tabular workflow (#710)
* feat: notebook on model registry

* feat: notebook on model registry

* feat: workflow notebook

* feat: workflow notebook

* feat: workflow notebook
2022-07-06 14:26:45 -07:00
b2a17dfc83 inardini - New 20+ Pipeline Operators for BQML notebook (#706)
* google_cloud_pipeline_components_bqml_pipeline_demand_forecasting notebook

* linter test to check with andy

* google_cloud_pipeline_components_bqml_pipeline_demand_forecasting notebook

* linter test to check with andy

* merge

* linter test minor fails. check with andy

* add code owner

* minor changes

* remove components

* linter test passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-07-06 08:38:28 -07:00
sasha-gitgandGitHub 7072219d8b Update build_model_experimentation_lineage_with_prebuild_code.ipynb (#703)
Switch to install from Pypi
2022-07-01 14:40:52 -07:00
Andrew FerlitschandGitHub 57db2f4014 Update README.md 2022-07-01 11:45:37 -07:00
Andrew FerlitschandGitHub 4604b0a0a9 Update README.md 2022-07-01 11:44:38 -07:00
Andrew FerlitschandGitHub c8c26a12ba fix: finish objective cell (#708)
* feat: notebook on model registry

* feat: notebook on model registry
2022-07-01 11:40:28 -07:00
Andrew FerlitschandGitHub 3a8fa3e312 feat: notebook for model registry (#707)
* update: refine experiment notebook

* update: refine experiment notebook

* update: new feature release

* update: new feature release

* update: new feature release

* update: new feature release

* feat: notebook on model registry

* feat: notebook on model registry
2022-07-01 11:25:20 -07:00
bbfba5aaaf add initial automl tables on vertex pipelines notebook (#694)
* add initial automl tables on vertex pipelines notebook

* apply template

* update bucket variable name

* reviewer requested changes

* update notebook with the updated API

* fix typo

* add stage_1_tuning_result_artifact_uri to skip architecture search pipeline

* update parameter for skip architecture search pipeline

* default evaluation to True; update data splits

* update dataset to gs://cloud-samples-data/vertex-ai/tabular-workflows/datasets/safe-driver/train.csv

Co-authored-by: Helin Wang <helin@google.com>
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-07-01 09:54:39 -07:00
Andrew FerlitschandGitHub e30b2182b0 Update get_started_with_vertex_endpoints.ipynb 2022-06-30 20:35:07 -07:00
4c4dade55a samples: Add Prediction CPR preprocess sample. (#662)
* samples: Add Prediction CPR preprocess sample.

* chore: Refined wording and used notebook template for CPR preprocessing
sample.

* samples: Fixed comments for CPR Preprocess sample.

* samples: Fixed wording.

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-30 20:14:35 -07:00
5690d50430 samples: Add Prediction CPR Triton sample. (#661)
* samples: Add Prediction CPR Triton sample.

* chore: Refined wording and used notebook template for CPR Triton sample.

* samples: Fixed comments for CPR Triton samples.

* samples: Fixed wording.

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-30 20:13:00 -07:00
Chun-Hsiang WangandGitHub 10c33f934f samples: Add Prediction CPR SDK sample. (#660)
* samples: Add Prediction CPR SDK sample.

* chore: Refined wording and used notebook template for CPR SDK sample.

* samples: Fixed comments for CPR SDK sample.

* samples: Fixed wording.
2022-06-30 20:07:29 -07:00
Andrew FerlitschandGitHub 0c43cbd563 update: remove install from git branch 2022-06-30 16:24:20 -07:00
Andrew FerlitschandGitHub b640a8f545 update: new feature release (#702)
* update: refine experiment notebook

* update: refine experiment notebook

* update: new feature release

* update: new feature release

* update: new feature release

* update: new feature release
2022-06-30 11:57:50 -07:00
Ivan CheungandGitHub a575528b11 Tweaks to matching engine notebook (#701)
* Tweaks to notebook

* Ran linter

* More tweaks
2022-06-30 11:59:05 -04:00
Andrew FerlitschandGitHub 42a2c4d082 fix: doc link 2022-06-30 08:36:57 -07:00
Andrew FerlitschandGitHub 0bcf44e9fa Update get_started_bqml_training.ipynb 2022-06-30 08:33:06 -07:00
Andrew FerlitschandGitHub 9ac2774ece Update README.md 2022-06-29 21:25:19 -07:00
Andrew FerlitschandGitHub 975c9fe6bc update: refine experiments notebook (#699)
* update: refine experiment notebook

* update: refine experiment notebook
2022-06-29 21:14:11 -07:00
Andrew FerlitschandGitHub 417410f382 Fix: remove hardwired project number (#698)
* fix: remove hardwired project number

* fix: remove hardwired project number
2022-06-29 14:42:51 -07:00
Andrew FerlitschandGitHub 8fdfbe4e31 fix: link 2022-06-29 14:20:04 -07:00
Andrew FerlitschandGitHub 80f977546c fix: title 2022-06-29 09:54:29 -07:00
Ivan NardiniandGitHub c5fe281e32 inardini - experiments cuj2 notebook release (#637)
* experiments cuj2 notebook release

* add andy reviews

* linter test passed

* align notebooks

* linter test passed

* minor changes

* karl bug review fix

* linter test passed

* add -q to install

* linter test passed

* debug

* linter test passed

* PR build fix

* linter test passed. delete debug notebook

* import import tempfile

* linter test passed

* remove pandas install

* linter test passed

* add sklearn

* linter test passed

* test pandas dep

* linter test passed

* minor changes

* linter test passed

* ivan fix
2022-06-29 12:38:16 -04:00
49a2ddaf08 fix: removing TODOs from TabNet notebook (#652)
* moving REGION up

* moving REGION up and csv file name

* fix: changed bucket URL to console

* removing TODOs from Tabnet notebook

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-28 07:26:01 -07:00
e9cba94bb4 inardini - experiments cuj3 notebook release (#638)
* experiments cuj3 notebook release

* add andy reviews

* linter test passed

* align notebooks

* linter test passed

* align notebooks

* linter test passed

* update CODEOWNERS

* sasha bug review fix

* linter test passed

* minor changes

* add -q to install

* linter test passed

* ivan dep fix

* linter test passed

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-06-27 19:15:13 -04:00
fc83cfcea5 samples: Add Prediction CPR PyTorch sample. (#659)
* samples: Add Prediction CPR PyTorch sample.

* chore: Refined wording and used notebook template for PyTorch sample.

* added missing bucket cleanup

Co-authored-by: Andrew Ferlitsch <aferlitsch@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-27 12:23:31 -07:00
e3aa9e8f35 samples: Add Prediction CPR handler sample. (#658)
* samples: Add Prediction CPR handler sample.

* chore: Refined wording and used notebook template.

* added missing bucket cleanup sequence

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-27 12:09:20 -07:00
Ivan CheungandGitHub 37c52abc11 Added a virtualenv to the notebook execution tests which should help with dependency issues (#693)
* Added a virtualenv

* Added a virtualenv for the single yaml

* Debug

* Fixed diff logic for all notebooks case

* Added missing -c
2022-06-26 13:31:52 -04:00
Ivan CheungandGitHub c8320c8764 Revert "Add notebook for co-hosting model (#666)" (#692)
This reverts commit aa5464151d.
2022-06-24 18:26:28 -04:00
b5d51e61b6 inardini - experiments cuj1 notebook release (#636)
* experiments cuj1 notebook release

* add andy reviews

* linter test passed

* align notebooks

* linter test passed

* minor changes

* linter test passed

* minor changes

* linter test passed

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-06-24 15:35:32 -04:00
Ziye XingandGitHub aa5464151d Add notebook for co-hosting model (#666)
* Add notebook for co-hosting model

* Add co-hosting model notebook codeowner
2022-06-24 10:36:26 -07:00
Andrew FerlitschandGitHub 386cecf4c2 upgrade: current notebook standard (#677)
* upgrade: notebook standard

* upgrade: notebook standard

* Update custom_model_training_and_batch_prediction.ipynb
2022-06-24 09:59:49 -07:00
dffdb15c17 Add default kernel_name for notebook execution (#497)
Currently, there is no kernel_name. Hence, the execution test cannot run for notebooks that don't have kernels defined in their .ipynb file.

Side-note: We should use lint to remove the kernel_name from .ipynb as well, as it could include info specific to the author's environment.

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-06-23 19:18:49 -04:00
Andrew FerlitschandGitHub 2f3691eb71 fix: workbench link 2022-06-23 13:55:29 -07:00
Andrew FerlitschandGitHub f456d86555 fix: open in workbench link 2022-06-23 13:52:39 -07:00
Andrew FerlitschandGitHub f534b4e7a5 upgrade: fine tune notebook standard 2022-06-23 13:28:00 -07:00
Andrew FerlitschandGitHub de247cd78b upgrade: current notebook standards (#681)
* upgrade: notebook standard

* upgrade: notebook standard

* fix: formatting
2022-06-23 12:03:55 -07:00
Andrew FerlitschandGitHub 22ad74eb8d Update README.md 2022-06-23 10:06:28 -07:00
Andrew FerlitschandGitHub baf69999fc update: fine-tuning notebook (#689)
* update: touchups

* update: touchups
2022-06-23 10:02:02 -07:00
Mohammad Al-AnsariandGitHub d5057da9bb Added new notebook that creates Vertex AI AutoML text entity extraction dataset from PDFs using Vision API (#683)
* Added new Stage 1 notebook to create unlabelled
Vertex AI AutoML text entity extraction dataset
from collection of PDF files on Google Cloud Storage

* Linted notebook

* Removed TODOs

* Updates per PR comments

* Revered to multiple imports per line
2022-06-23 08:38:14 -07:00
24904a5999 feat: adding code owners and updating graph_paysim (#645)
* adding code owners and updating graph_paysim

* formatted

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-06-22 21:31:55 -05:00
Ivan CheungandGitHub 881a2b45c5 Improved git diff logic (#687) 2022-06-22 21:49:09 -04:00
Andrew FerlitschandGitHub 41fc83ad03 upgrade: current notebook standards (#655)
* update: current standards

* update: current standards

* Update sdk_custom_image_classification_batch_explain.ipynb

* fix: bucket nit
2022-06-22 16:59:39 -07:00
Andrew FerlitschandGitHub 9928276dc3 upgrade: current notebook standard (#653)
* upgrade: current notebook standard

* upgrade: current notebook standard

* Update sdk_automl_tabular_binary_classification_batch_explain.ipynb

* fix: bucket nit
2022-06-22 16:58:42 -07:00
Andrew FerlitschandGitHub 6607f93f5e upgrade: updated curated notebook to current standards (#648)
* upgrade: current standards

* upgrade: current standards

* fix: missed nits

* fix: missed nits

* Update automl-text-classification.ipynb

* Update automl-text-classification.ipynb

* rm extra comma
2022-06-22 16:56:38 -07:00
Andrew FerlitschandGitHub dcc0cfe06e upgrade: current notebook standards (#686)
* upgrade: notebook standard

* upgrade: notebook standard
2022-06-22 16:50:13 -07:00
Andrew FerlitschandGitHub 00d5c5c4bf Update README.md 2022-06-22 15:34:01 -07:00
Andrew FerlitschandGitHub f8152dde19 Update README.md 2022-06-22 15:24:14 -07:00
Andrew FerlitschandGitHub 0586e04c21 upgrade: current notebook standards (#656)
* update: current standards

* update: current standards

* fix: bucket nit
2022-06-22 15:06:01 -07:00
Andrew FerlitschandGitHub 3de18a7fab upgrade: current notebook standards (#674)
* upgrade: current notebook standard

* upgrade: current notebook standard

* fix: bucket

* fix: bucket
2022-06-22 15:03:54 -07:00
Andrew FerlitschandGitHub dc0bf24cc5 Update README.md 2022-06-22 14:58:28 -07:00
Andrew FerlitschandGitHub 8ce4c3070c Update README.md 2022-06-22 14:53:54 -07:00
Andrew FerlitschandGitHub 13c3acb976 Update README.md 2022-06-22 14:50:45 -07:00
Andrew FerlitschandGitHub c1150ff584 Update README.md 2022-06-22 14:39:06 -07:00
Andrew FerlitschandGitHub 4f11d70f7e Update README.md 2022-06-22 14:34:02 -07:00
Andrew FerlitschandGitHub 2bf9a2b317 Update README.md 2022-06-22 14:24:53 -07:00
Andrew FerlitschandGitHub b1e0ad0c4f Update README.md 2022-06-22 14:15:22 -07:00
Andrew FerlitschandGitHub 5624f92f02 Update README.md 2022-06-22 14:12:18 -07:00
Andrew FerlitschandGitHub 1335032954 Update README.md 2022-06-22 14:05:24 -07:00
Andrew FerlitschandGitHub 0b13c66e07 Update README.md 2022-06-22 14:01:55 -07:00
Andrew FerlitschandGitHub ef25b54926 update: add index (#684) 2022-06-22 13:58:06 -07:00
Andrew FerlitschandGitHub 064dbfeefa fix: bucket nit 2022-06-22 12:34:50 -07:00
Andrew FerlitschandGitHub 044c69e7a5 upgrade: current notebook standards (#654)
* update: current standards

* update: current standards
2022-06-22 12:33:26 -07:00
Andrew FerlitschandGitHub 32a46e7471 upgrade: current standards (#649)
* upgrade: current standards

* upgrade: current standards

* fix: missed nits

* fix: missed nits
2022-06-22 12:30:16 -07:00
Andrew FerlitschandGitHub b52d59822d upgrade: current notebook standards (#657)
* update: current standards

* update: current standards

* update: current standards

* update: current standards

* Update sdk_custom_tabular_regression_batch_explain.ipynb

* fix: indent issue

* fix: indent issue

* fix: bucket

* fix: bucket

* fix: image

* fix: image

* fix: cleanup

* fix: cleanup

* fix: cleanup
2022-06-22 11:47:17 -07:00
Andrew FerlitschandGitHub 529995ecde upgrade: current notebook standard (#671)
* upgrade: current notebook standard

* upgrade: current notebook standard

* Update google_cloud_pipeline_components_automl_tabular.ipynb

* fix: bucket

* fix: bucket
2022-06-22 11:35:38 -07:00
Andrew FerlitschandGitHub 0726328c92 upgrade: current notebook standard (#667)
* upgrade: current notebook standard

* upgrade: current notebook standard

* Update model_monitoring.ipynb

* Update model_monitoring.ipynb
2022-06-22 11:21:32 -07:00
Andrew FerlitschandGitHub 090e83c286 fix: more broken links 2022-06-22 11:19:17 -07:00
Andrew FerlitschandGitHub c3802626b9 fix: links issue 672 2022-06-22 11:18:08 -07:00
Andrew FerlitschandGitHub 9570c2477f upgrade: current notebook standards (#682)
* upgrade: current notebook standards

* upgrade: current notebook standards
2022-06-22 11:09:27 -07:00
Andrew FerlitschandGitHub 2b1a898b2a upgrade: current notebook standards (#680)
* upgrade: current notebook standards

* upgrade: current notebook standards
2022-06-22 11:09:04 -07:00
Andrew FerlitschandGitHub f2a42aa66e upgrade: current notebook standard (#679)
* upgrade: notebook standard

* upgrade: notebook standard

* fix: bucket

* fix: bucket
2022-06-22 11:08:37 -07:00
Andrew FerlitschandGitHub 30a03f1fd1 upgrade: current notebook standards (#678)
* upgrade: notebook standard

* upgrade: notebook standard

* Update google_cloud_pipeline_components_model_train_upload_deploy.ipynb

* fix: bucket nits

* fix: bucket
2022-06-22 11:08:08 -07:00
Andrew FerlitschandGitHub ca25448f59 upgrade: current notebook standard (#673)
* upgrade: current notebook standard

* upgrade: current notebook standard

* fix: bucket nit

* fix: bucket nit
2022-06-22 11:07:37 -07:00
Andrew FerlitschandGitHub 8f922710b0 upgrade: current notebook standard (#670)
* upgrade: current notebook standard

* upgrade: current notebook standard

* Update google_cloud_pipeline_components_automl_images.ipynb

* fix: bucket

* fix: bucket
2022-06-22 11:06:31 -07:00
Andrew FerlitschandGitHub 9509c6ab9d upgrade: current notebook standard (#669)
* upgrade: current notebook standard

* upgrade: current notebook standard

* Update lightweight_functions_component_io_kfp.ipynb

* fix: nits

* fix: nits

* fix: nits

* fix: nits
2022-06-22 11:05:47 -07:00
Andrew FerlitschandGitHub ccba176979 upgrade: current notebook standard (#665)
* upgrade: notebook standard

* upgrade: notebook standard

* Update sdk-feature-store.ipynb

* Update sdk-feature-store.ipynb

* Update sdk-feature-store.ipynb

* fix: aip reference

* fix: nits

* fix: nits
2022-06-22 11:05:07 -07:00
Andrew FerlitschandGitHub 1b8f383897 upgrade: current notebook standard (#663)
* update: current standards

* update: current standards

* fix: bucket

* fix: bucket
2022-06-22 09:36:49 -07:00
Andrew FerlitschandGitHub e5cd9e86d2 upgrade: notebook to latest standard (#651)
* fix: missed nits

* fix: missed nits
2022-06-22 08:56:10 -07:00
Andrew FerlitschandGitHub a7e86a4f26 upgrade: current notebook standard (#668)
* upgrade: current notebook standard

* upgrade: current notebook standard

* Update sdk-metric-parameter-tracking-for-locally-trained-models.ipynb
2022-06-21 20:23:18 -07:00
Ivan CheungandGitHub 8f0c73b32c Fixed cleanup scripts (#676) 2022-06-21 20:13:37 -07:00
Andrew FerlitschandGitHub c7d7b48a91 upgrade: notebook to current standards (#650)
* upgrade: current standards

* upgrade: current standards
2022-06-21 18:25:25 -07:00
Karl WeinmeisterandGitHub 583eb90f07 fix: CONTRIBUTING.md did not have nbfmt as final step 2022-06-20 13:56:49 -05:00
c3a9249c0c Workaround tensorboard/GCS issue for Cloud Shell (#386)
* Workaround tensorboard/GCS issue for Cloud Shell

Without `--load_fast=false` there will be `401 Unauthorized` for GCS log loads. 
See https://github.com/tensorflow/tensorboard/issues/4784#issuecomment-868945650

* PR #386: Fix missing import

`import json` was missing.

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-19 10:07:09 -05:00
Karl WeinmeisterandGitHub 81b70e779c ci: Remove protobuf from requirements.txt 2022-06-19 09:38:45 -05:00
Karl WeinmeisterandGitHub 085713a818 ci: Add protobuf to requirements.txt 2022-06-18 17:20:45 -05:00
Karl WeinmeisterandGitHub 5af7c851dc Fix: update typo in GAPIC Feature Store notebook 2022-06-18 17:10:49 -05:00
691312d467 Add import feature analysis config sample code into gapic-feature-sto… (#548)
* Add import feature analysis config sample code into gapic-feature-store.ipynb

* Fixing linter for gapic-feature-store.ipynb

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-06-18 17:09:37 -05:00
650c256c13 Fixes link to colab (#627)
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-06-18 16:26:36 -05:00
9b00c4380b chore(deps): update actions/setup-python action to v4 (#622)
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-06-18 16:21:49 -05:00
Karl WeinmeisterandGitHub 4851457e93 ci: Add Python version to support setup-python v4 2022-06-18 16:19:09 -05:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Karl Weinmeister
1c54878fab build(deps): bump tensorflow (#595)
Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.5.3 to 2.7.2.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/compare/v2.5.3...v2.7.2)

---
updated-dependencies:
- dependency-name: tensorflow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-06-18 16:08:07 -05:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
c139b84454 build(deps): bump tensorflow (#593)
Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.5.3 to 2.7.2.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/compare/v2.5.3...v2.7.2)

---
updated-dependencies:
- dependency-name: tensorflow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-18 16:02:53 -05:00
15c38b4ca6 chore(deps): update dependency pyupgrade to v2.34.0 (#457)
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-06-18 15:59:54 -05:00
Ivan CheungandGitHub 271c949a71 Update README.md (#642) 2022-06-17 14:59:05 -07:00
Andrew FerlitschandGitHub 09b5401434 update: fine-tuning notebook (#641)
* feat: add example of import from dataframe

* feat: add example of import from dataframe

* update: change in required perms

* update: change in required perms

* review: updates from review

* review: updates from review

* updates: fine tuning
2022-06-17 13:41:10 -07:00
dad76547f0 inardini - mobile gaming feature store blog review (#635)
* review content and image

* linter test passed

* andy review fixes

* linter test passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-17 10:39:18 -07:00
Andrew FerlitschandGitHub c14a110c81 Update get_started_with_custom_training_pipeline_components.ipynb 2022-06-16 14:24:08 -07:00
Andrew FerlitschandGitHub d1e16546cc Update get_started_with_bqml_pipeline_components.ipynb 2022-06-16 14:23:29 -07:00
Andrew FerlitschandGitHub f91bc3d0c9 Update get_started_with_bq_tfdv_pipeline_components.ipynb 2022-06-16 14:22:56 -07:00
Andrew FerlitschandGitHub 5168808b6c fix: colab link 2022-06-16 14:22:23 -07:00
Andrew FerlitschandGitHub 501cca7b5e fix: colab link 2022-06-16 14:21:31 -07:00
Andrew FerlitschandGitHub f19d40d858 Update mlops_experimentation.ipynb 2022-06-16 13:49:17 -07:00
Andrew FerlitschandGitHub 5a721ce01d Update get_started_with_visionapi_and_automl.ipynb 2022-06-16 13:48:31 -07:00
Andrew FerlitschandGitHub 66421fb4d8 fix: colab link 2022-06-16 13:47:47 -07:00
Andrew FerlitschandGitHub 3658ee8c88 Update get_started_with_tabnet.ipynb 2022-06-16 13:46:10 -07:00
Andrew FerlitschandGitHub afaab4bb02 Update get_started_with_cmek_training.ipynb 2022-06-16 13:45:08 -07:00
Andrew FerlitschandGitHub c1e004bdff fix: colab link 2022-06-16 13:44:22 -07:00
Andrew FerlitschandGitHub 874e5a3ef5 Update get_started_vertex_training_xgboost.ipynb 2022-06-16 13:43:11 -07:00
Andrew FerlitschandGitHub 51529f370c fix: broken table 2022-06-16 13:41:01 -07:00
Andrew FerlitschandGitHub 5ddf98866c Update get_started_vertex_training_sklearn.ipynb 2022-06-16 13:40:22 -07:00
Andrew FerlitschandGitHub fbb6830876 fix: colab link 2022-06-16 13:30:01 -07:00
Andrew FerlitschandGitHub ee1bb281da fix: colab link 2022-06-16 13:28:16 -07:00
Andrew FerlitschandGitHub da2f7e88fe fix: update location of public dataset bucket 2022-06-16 12:43:15 -07:00
Andrew FerlitschandGitHub 3fb28e353f fix: remove internal link 2022-06-16 12:40:02 -07:00
Andrew FerlitschandGitHub c8e7f44f0a fix: updates from review (#640)
* feat: add example of import from dataframe

* feat: add example of import from dataframe

* update: change in required perms

* update: change in required perms

* review: updates from review

* review: updates from review
2022-06-16 12:36:28 -07:00
3d9049aeeb remove old hard-coded instances for prediction (#633)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-16 11:50:01 -07:00
Andrew FerlitschandGitHub 7b8726af24 fix: perms for using MR in BQML (#634)
* feat: add example of import from dataframe

* feat: add example of import from dataframe

* update: change in required perms

* update: change in required perms
2022-06-15 14:55:17 -07:00
Andrew FerlitschandGitHub 0443b05360 feat: add create tabular dataset from dataframe example (#632)
* feat: add example of import from dataframe

* feat: add example of import from dataframe
2022-06-14 11:44:30 -07:00
Ivan CheungandGitHub e422dbdef2 Added official version of tabular regression batch bq (#331)
* Added official version of tabular regression batch bq

* Ran linter

* Fixed cleanup

* Additional cleanup

* Added working version

* Refactored and made work

* Ran linter and cleaned up

* Renamed aip to aiplatform

* Replaced online with batch

* Renamed notebook

* Ran linter and cleaned up

* Fixed bug

* Fixed SQL by adding backticks

* Install google-cloud-bigquery[all]

* Refactored datasets

* Ran linter

* Removed GCS cells

* Fixed import file

* Fixed SQL issues and added cleanup of training dataset

* Fixed hardcorded table

* Fixed brand names

* Fixed header

* Fixed results table

* Addressed tech writing review comments

* Ran linter
2022-06-14 14:14:06 -04:00
Andrew FerlitschandGitHub ec5fc0b1c8 Update get_started_vertex_training_r.ipynb 2022-06-14 10:05:36 -07:00
Andrew FerlitschandGitHub c52e3f20ba Update get_started_vertex_training_pytorch.ipynb 2022-06-14 10:04:45 -07:00
Andrew FerlitschandGitHub e367dceceb Update get_started_vertex_training_lightgbm.ipynb 2022-06-14 10:04:11 -07:00
Andrew FerlitschandGitHub 19b8666808 Update get_started_vertex_training.ipynb 2022-06-14 10:03:24 -07:00
Andrew FerlitschandGitHub a2df0e9fca Update get_started_vertex_tensorboard.ipynb 2022-06-14 10:01:52 -07:00
Andrew FerlitschandGitHub 73b094550e Update get_started_vertex_feature_store.ipynb 2022-06-14 09:59:24 -07:00
Andrew FerlitschandGitHub d05ae109e1 Update get_started_vertex_experiments.ipynb 2022-06-14 09:57:55 -07:00
Andrew FerlitschandGitHub fdb25791d5 Update get_started_vertex_distributed_training.ipynb 2022-06-14 09:57:19 -07:00
Andrew FerlitschandGitHub 5a88492498 Update get_started_bqml_training.ipynb 2022-06-14 09:56:34 -07:00
Andrew FerlitschandGitHub f19a12b829 Update get_started_automl_training.ipynb 2022-06-14 09:55:53 -07:00
Andrew FerlitschandGitHub 3ed0ea73f4 Update get_started_bq_datasets.ipynb 2022-06-14 09:08:47 -07:00
Andrew FerlitschandGitHub b98fd24a72 Update get_started_bq_datasets.ipynb 2022-06-13 21:29:41 -07:00
Andrew FerlitschandGitHub eb4e9a0f91 Update get_started_vertex_datasets.ipynb 2022-06-13 21:27:16 -07:00
Andrew FerlitschandGitHub ec7c136b0a Update get_started_vertex_datasets.ipynb 2022-06-13 21:26:24 -07:00
Andrew FerlitschandGitHub ee7e43cc1a Update mlops_data_management.ipynb 2022-06-13 20:24:57 -07:00
Andrew FerlitschandGitHub ea9f5f3c5c Update get_started_with_data_labeling.ipynb 2022-06-13 20:24:22 -07:00
Andrew FerlitschandGitHub bd44798412 Update get_started_vertex_datasets.ipynb 2022-06-13 20:23:37 -07:00
Andrew FerlitschandGitHub 2af0cc0f80 fix: test for local execution 2022-06-13 20:22:57 -07:00
Andrew FerlitschandGitHub 5c0fa14d2d Update get_started_bq_datasets.ipynb 2022-06-13 20:21:44 -07:00
Andrew FerlitschandGitHub 7cc50d3203 Update README.md 2022-06-13 13:58:20 -07:00
Andrew FerlitschandGitHub 9c7da13177 Update gapic-vizier-multi-objective-optimization.ipynb 2022-06-13 08:39:33 -07:00
Andrew FerlitschandGitHub 45e0645f0b Update gapic-vizier-multi-objective-optimization.ipynb 2022-06-13 08:38:55 -07:00
Andrew FerlitschandGitHub cb884cc74a Update gapic-vizier-multi-objective-optimization.ipynb 2022-06-13 08:38:22 -07:00
Ivan CheungandGitHub d3a6475580 Fixed mistake in batch prediction request section (#617)
* Fixed mistake in batch prediction request section

* Fixed linter requirements
2022-06-10 17:13:45 -04:00
4e7061b2db added MLPerf benchmark reference and updated Criteo sample to use GRPC for stock containers (#630)
* added MLPerf benchmark reference and updated Criteo sample to use GRPC for stock containers

* addressed feedback for BERT sample and did similar changes to Criteo sample

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-10 12:06:25 -07:00
Ivan CheungandGitHub 0250879f65 Added notebook substitution for common case of 1 notebook (#625) 2022-06-10 14:44:43 -04:00
Andrew FerlitschandGitHub 5cee23ae68 Update get_started_with_autoscaling.ipynb 2022-06-09 15:02:28 -07:00
Andrew FerlitschandGitHub d518558b3d Update README.md 2022-06-09 15:01:55 -07:00
Andrew FerlitschandGitHub 5c085c843f feat: notebook on autoscaling (#629)
* feat: XAI + custom server

* feat: add DIY MLMD for AutoML

* feat: add DIY MLMD for AutoML

* fix: replace BLAH

* fix: replace BLAH

* update: AutoML + MLMD

* update: AutoML + MLMD

* co-hosting

* co-hosting

* feat: new R notebook

* feat: new R notebook

* feat: airflow+vertex

* feat: airflow+vertex

* feat: notebook on autoscaling

* feat: notebook on autoscaling
2022-06-09 14:57:41 -07:00
Michael HuandGitHub 936b434ac4 fix: typo in links in bqml arima notebook (#616)
Notebook used as template had incorrect link format. Apply the same fixes as #514 to the arima notebook.
2022-06-09 17:52:12 -04:00
Michael HuandGitHub 43059c9fd9 fix: pin protobuf version to 3.19.0 (#621) 2022-06-09 12:49:45 -07:00
Andrew FerlitschandGitHub 19f72d426d fix: typos 2022-06-08 11:59:37 -07:00
Andrew FerlitschandGitHub 14ecaf3023 Update README.md 2022-06-08 11:58:18 -07:00
Andrew FerlitschandGitHub 80c93a9b6d feat: airflow with vertex pipelines (#624)
* feat: XAI + custom server

* feat: add DIY MLMD for AutoML

* feat: add DIY MLMD for AutoML

* fix: replace BLAH

* fix: replace BLAH

* update: AutoML + MLMD

* update: AutoML + MLMD

* co-hosting

* co-hosting

* feat: new R notebook

* feat: new R notebook

* feat: airflow+vertex

* feat: airflow+vertex
2022-06-08 11:55:11 -07:00
Andrew FerlitschandGitHub 06a1b4dc57 Update README.md 2022-06-07 09:48:16 -07:00
Andrew FerlitschandGitHub 4e779eedf1 Update README.md 2022-06-07 09:45:10 -07:00
Andrew FerlitschandGitHub afb341f5fd feat: new R notebook (#618)
* feat: XAI + custom server

* feat: add DIY MLMD for AutoML

* feat: add DIY MLMD for AutoML

* fix: replace BLAH

* fix: replace BLAH

* update: AutoML + MLMD

* update: AutoML + MLMD

* co-hosting

* co-hosting

* feat: new R notebook

* feat: new R notebook
2022-06-07 09:39:44 -07:00
e34b0fa115 chore(deps): pin dependency protobuf to v (#606)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-06 18:13:56 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
6fa0345f25 build(deps): bump tensorflow (#596)
Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.5.3 to 2.7.2.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/compare/v2.5.3...v2.7.2)

---
updated-dependencies:
- dependency-name: tensorflow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-06 18:09:52 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Andrew Ferlitsch
dd43ae6639 build(deps): bump tensorflow (#594)
Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.5.3 to 2.7.2.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/compare/v2.5.3...v2.7.2)

---
updated-dependencies:
- dependency-name: tensorflow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-06 18:08:37 -07:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Ivan CheungAndrew Ferlitsch
840385e0a7 build(deps): bump tensorflow (#592)
Bumps [tensorflow](https://github.com/tensorflow/tensorflow) from 2.5.3 to 2.7.2.
- [Release notes](https://github.com/tensorflow/tensorflow/releases)
- [Changelog](https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md)
- [Commits](https://github.com/tensorflow/tensorflow/compare/v2.5.3...v2.7.2)

---
updated-dependencies:
- dependency-name: tensorflow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-06 18:07:48 -07:00
Michael HuandGitHub 9daaf51a1f add bqml arima and vertex forecasting comparison notebook (#581)
Adds a notebook that demonstrates how to compare a Vertex Forecasting model against a BQML ARIMA+ model trained using a first-party GCPC pipeline.
2022-06-06 20:48:30 -04:00
Andrew FerlitschandGitHub 9b2511e54e Update README.md 2022-06-06 13:38:55 -07:00
Andrew FerlitschandGitHub b6674e6540 feat: notebook for co-hosting models (#615)
* feat: XAI + custom server

* feat: add DIY MLMD for AutoML

* feat: add DIY MLMD for AutoML

* fix: replace BLAH

* fix: replace BLAH

* update: AutoML + MLMD

* update: AutoML + MLMD

* co-hosting

* co-hosting
2022-06-06 13:35:47 -07:00
Ivan CheungandGitHub a109cb6d44 fix: Added explanations output to forecasting notebook (#613)
* Added explanations output to forecasting notebook

* Simplified and added XAI

* Fix conflicts

* Ran linter

* Fixed batch prediction request explanation
2022-06-06 10:00:07 -07:00
Ivan CheungandGitHub f730d6b9de Added ability to test a single notebook (#608)
* Added ability to test a single notebook

* Added output_url to table

* Removed ML Ops notebooks
2022-06-06 10:30:31 -04:00
0947f2792d Made some minor changes to Sdk big query custom container training (#522)
* minor changes done

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-05 12:58:45 -07:00
dbf19acde4 Adds the updated telecom-subscriber-churn-prediction notebook to official and removes from community (#506)
* updates and adds the telecom-subscriber-churn-prediction notebook to official and removes from the community

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-05 12:53:21 -07:00
1aaa833153 Adds manual-scaling config and explanation to the Automl-forecasting-batch notebook in official folder (#514)
* adds manual-scaling config and explanation to the notebook

* ran linter test after installing linter requirement updates

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-05 12:50:23 -07:00
c73d995680 Made minor changes to sdk_automl_image_object_detection_batch.ipynb file (#513)
* modified notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-05 12:45:55 -07:00
3fe5028724 Malansari automl vision api notebook update (#612)
* Delete revised version

* Copy notebook from /notebooks/official

* Renamed base notebook

* Added first version by mansari@

* Updated to revised version by andrewferlitsch@

* Added author / reviewer information

Added sample files

* Updated CODEOWNERS

* Fixed links for opening the notebook in Colab/Github/Vertex

Removed installation of and references to pandas

Fixed gcs_annotation_file_name string reference

* Fixed the links for opening notebook (again!)

* Added attribution and references

* Removed references as covered at top

* Updated installation commands to match

* Updated Vertex AI region name to be more clear

* Added db-types dependency for pandas operations
that are now failing

* Minor edits

* Combined package installation and
added a note to ignore the errors

* Minor edit to message

* Added special thanks to andrewferlitsch@

* Updated andrewferlitsch@ GithHub profile link

* Updated sample files URLs to absolute URLs

* Removed empty code block

* Added additional attribution (and the one that did not make it into previous commit!)

* Fixed multi-package import formatting
Switched to pandas instead of db-dtypes

* Fixed isort issue

* Removed unnecessary pandas import

* Formatted the notebook with nbfmt

* Additional notebook formatting

* Updated link to open in Vertex AI Workbench
to point to raw .ipynb file

* Fixed lint issues

* Formatting changes

Added additional APIs to be enabled

* Fixed sample dataset link to point to public version

* Fixed linting issues

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-04 09:14:23 -07:00
Andrew FerlitschandGitHub 44dd24f910 Update README.md 2022-06-02 15:57:04 -07:00
Andrew FerlitschandGitHub c20a9c4e63 update: AutoML + MLMD (#605)
* feat: XAI + custom server

* feat: add DIY MLMD for AutoML

* feat: add DIY MLMD for AutoML

* fix: replace BLAH

* fix: replace BLAH

* update: AutoML + MLMD

* update: AutoML + MLMD
2022-06-02 15:50:05 -07:00
Ivan CheungandGitHub edffdf34b7 Pin protobuf version to avoid broken dependencies. 2022-06-02 17:25:28 -04:00
340c24c5b4 Added custom container explainability notebook (#564)
* Commit for lint

* Commit after name change

* Commit of notebook and CODEOWNERS

Added custom container with xai notebook, and explainable_ai folder in the community folder

* Removed extra copy of file

* Remove extra file

* Updated per review from DPE

* Lint test updates

* linter ran

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-06-02 12:28:15 -07:00
Andrew FerlitschandGitHub 11f20f3f08 fix: replace BLAH (#600)
* feat: XAI + custom server

* feat: add DIY MLMD for AutoML

* feat: add DIY MLMD for AutoML

* fix: replace BLAH

* fix: replace BLAH
2022-06-01 11:19:02 -07:00
Andrew FerlitschandGitHub 199b330aa5 Update get_started_automl_mlmd.ipynb 2022-05-31 18:37:05 -07:00
Andrew FerlitschandGitHub 5143db1024 feat: Add DIY MLMD with AutoML (#598)
* feat: XAI + custom server

* feat: add DIY MLMD for AutoML

* feat: add DIY MLMD for AutoML
2022-05-31 18:35:23 -07:00
Andrew FerlitschandGitHub 2f0bd3de15 fix: correct reference to service 2022-05-31 13:50:51 -07:00
Andrew FerlitschandGitHub 4d6c541967 feat: XAI + custom server (#597) 2022-05-31 13:31:20 -07:00
Andrew FerlitschandGitHub 5228a5c978 Update README.md 2022-05-31 12:47:16 -07:00
Andrew FerlitschandGitHub c6118bd17d feat: start stage 7 (#591)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* feat: swivel and matching engine

* feat: swivel and matching engine

* feat: LightGBM

* feat: LightGBM

* feat: start stage7

* feat: start stage8
2022-05-31 09:48:49 -07:00
Andrew FerlitschandGitHub d2c9e84af4 Add files via upload 2022-05-26 09:30:17 -07:00
Andrew FerlitschandGitHub fe0a0ff055 Update README.md 2022-05-26 09:30:04 -07:00
Andrew FerlitschandGitHub 40e287245d Delete stage5v2.png 2022-05-26 09:29:50 -07:00
Andrew FerlitschandGitHub c79646a537 Add files via upload 2022-05-26 09:26:24 -07:00
Andrew FerlitschandGitHub e293e1c2fb Update README.md 2022-05-26 09:26:09 -07:00
Andrew FerlitschandGitHub f2ab65bd03 Delete stage4v2.png 2022-05-26 09:25:51 -07:00
Andrew FerlitschandGitHub aa686516d3 Add files via upload 2022-05-25 14:42:01 -07:00
Andrew FerlitschandGitHub 11c80a0251 Update README.md 2022-05-25 14:41:45 -07:00
Andrew FerlitschandGitHub c5e9e5812b Delete stage3v2.png 2022-05-25 14:41:29 -07:00
Andrew FerlitschandGitHub 98b126fa0b Update README.md 2022-05-25 14:34:29 -07:00
Andrew FerlitschandGitHub 55553f9e69 Update README.md 2022-05-25 14:33:56 -07:00
Andrew FerlitschandGitHub 563013c745 Add files via upload 2022-05-25 14:33:10 -07:00
Andrew FerlitschandGitHub fefb9778a7 Update README.md 2022-05-25 14:32:53 -07:00
Andrew FerlitschandGitHub be1831082c Update README.md 2022-05-25 14:11:47 -07:00
Andrew FerlitschandGitHub 9e15ee2e8a Add files via upload 2022-05-25 14:11:21 -07:00
Andrew FerlitschandGitHub ceff7d7271 Delete stage2v2.png 2022-05-25 14:10:51 -07:00
Andrew FerlitschandGitHub df9b5cd6f0 Add files via upload 2022-05-24 16:17:27 -07:00
Andrew FerlitschandGitHub bc57801525 Update README.md 2022-05-24 16:17:06 -07:00
Andrew FerlitschandGitHub 1b403373d3 Delete stage1.png 2022-05-24 16:16:49 -07:00
Andrew FerlitschandGitHub 987fb74ca6 Add files via upload 2022-05-24 15:13:15 -07:00
Andrew FerlitschandGitHub 65a209bc7b Update README.md 2022-05-24 15:12:55 -07:00
Andrew FerlitschandGitHub 16e6d9e90f Delete stage6c.png 2022-05-24 15:12:32 -07:00
Andrew FerlitschandGitHub 7ce6bee763 Delete stage6b.png 2022-05-24 15:12:18 -07:00
Andrew FerlitschandGitHub 6d7ca3eb55 Delete stage6a.png 2022-05-24 15:12:05 -07:00
Andrew FerlitschandGitHub 8e9f205e9a Add files via upload 2022-05-24 14:58:15 -07:00
Andrew FerlitschandGitHub 5fdb6c4368 Update README.md 2022-05-24 14:57:50 -07:00
Andrew FerlitschandGitHub 71ebfd402c Delete stage5.png 2022-05-24 14:57:33 -07:00
Andrew FerlitschandGitHub 6e4ca83531 Update README.md 2022-05-24 14:43:12 -07:00
Andrew FerlitschandGitHub 05793d6a3c Add files via upload 2022-05-24 14:42:39 -07:00
Andrew FerlitschandGitHub 3dc374b7db Delete stage4.png 2022-05-24 14:42:13 -07:00
Andrew FerlitschandGitHub 3ac8a4f617 Add files via upload 2022-05-24 14:22:20 -07:00
Andrew FerlitschandGitHub 21b4b5b063 Delete stage3v3.png 2022-05-24 14:22:11 -07:00
Andrew FerlitschandGitHub 9ffd921ca4 Update README.md 2022-05-24 14:21:38 -07:00
Andrew FerlitschandGitHub 14e6ebbb95 Add files via upload 2022-05-24 14:21:08 -07:00
Andrew FerlitschandGitHub 277b685a39 Delete stage3.png 2022-05-24 14:20:58 -07:00
Andrew FerlitschandGitHub 67e7715ed9 Update README.md 2022-05-24 13:59:19 -07:00
Andrew FerlitschandGitHub bb87900209 Add files via upload 2022-05-24 13:58:51 -07:00
Andrew FerlitschandGitHub 96ebe7286b Delete stage2.png 2022-05-24 13:58:24 -07:00
Andrew FerlitschandGitHub 0b3a5dde09 Add files via upload 2022-05-24 13:57:41 -07:00
Andrew FerlitschandGitHub 17a30360b4 Delete stage2.png 2022-05-24 13:57:24 -07:00
Andrew FerlitschandGitHub b386f51916 Update README.md 2022-05-24 13:40:25 -07:00
Andrew FerlitschandGitHub dd4f40c7f4 Add files via upload 2022-05-24 13:39:51 -07:00
Andrew FerlitschandGitHub d402fc085a Delete stage1.jpg 2022-05-24 13:39:38 -07:00
Andrew FerlitschandGitHub a12b9cd60f Add files via upload 2022-05-24 13:38:11 -07:00
Andrew FerlitschandGitHub bf1032d550 Delete stage1.jpg 2022-05-24 13:38:01 -07:00
Andrew FerlitschandGitHub dea05e1e36 Add files via upload 2022-05-24 13:36:59 -07:00
Andrew FerlitschandGitHub a9f0117c82 Update README.md 2022-05-23 17:09:39 -07:00
Andrew FerlitschandGitHub 83f1fe9ecd Add files via upload 2022-05-23 17:08:06 -07:00
Andrew FerlitschandGitHub 7344274037 Add files via upload 2022-05-23 17:06:53 -07:00
Andrew FerlitschandGitHub e36bfa9a3b Add files via upload 2022-05-23 17:03:27 -07:00
Andrew FerlitschandGitHub 950aa245b8 Update README.md 2022-05-23 16:55:52 -07:00
Andrew FerlitschandGitHub ac47b2e370 Update README.md 2022-05-20 13:01:42 -07:00
Andrew FerlitschandGitHub 6662fc809b Update README.md 2022-05-20 13:00:49 -07:00
Andrew FerlitschandGitHub 12b3171d5e feat: LightGBM (#583)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* feat: swivel and matching engine

* feat: swivel and matching engine

* feat: LightGBM

* feat: LightGBM
2022-05-20 12:58:37 -07:00
Andrew FerlitschandGitHub 579d4751bd Update README.md 2022-05-20 12:41:10 -07:00
Andrew FerlitschandGitHub d4c607323d feat: swivel + ME (#582)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* feat: swivel and matching engine

* feat: swivel and matching engine
2022-05-20 12:39:42 -07:00
nayaknishantandGitHub 3ad30738a7 docs: fixing CODEOWNERS and instructions hyperlinks (#580)
When opening a PR, the CODEOWNERS and instructions hyperlinks throw a 404 error because they point to a URL that has been changed. Fixing these hyperlinks.
2022-05-19 13:20:23 -07:00
Andrew FerlitschandGitHub 119273ae7e Ml.googleapis fix (#579)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis
2022-05-19 12:42:55 -07:00
Andrew FerlitschandGitHub 95bc39a685 fix: enable APIs stage5 (#578)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis
2022-05-19 12:30:11 -07:00
Andrew FerlitschandGitHub b054104851 fix: enable APIs stage4 (#577)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis
2022-05-19 12:23:49 -07:00
Andrew FerlitschandGitHub e0e0cf849a fix: enable APIs stage3 (#576)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis
2022-05-19 12:15:29 -07:00
Andrew FerlitschandGitHub c95b3d7088 fix : enable APIs stage2 (#575)
* fix: enable apis

* fix: enable apis

* fix: enable apis

* fix: enable apis
2022-05-19 11:51:49 -07:00
Andrew FerlitschandGitHub 19c2bdb008 fix: enable APIs stage1 (#574)
* fix: enable apis

* fix: enable apis
2022-05-19 11:36:12 -07:00
Andrew FerlitschandGitHub 3c815f3888 update: new template edition (#572)
* fix: new template review updates

* fix: new template review updates

* mport -> import

* fix: dummy code sample required an import

dummy code samples (not otherwise part of template) -- should be self contained since they will be deleted by the template user.

* fix: added install for self-contained code passes ingestion test

* fix: example code (not otherwise part of template) not self-contained.

* fix: continue update so code example is self-contained

* update: numpy already installed in test env
2022-05-19 11:24:19 -07:00
cfcd9b29fd Malansari automl vision api notebook (#573)
* Delete revised version

* Copy notebook from /notebooks/official

* Renamed base notebook

* Added first version by mansari@

* Updated to revised version by andrewferlitsch@

* Added author / reviewer information

Added sample files

* Updated CODEOWNERS

* Fixed links for opening the notebook in Colab/Github/Vertex

Removed installation of and references to pandas

Fixed gcs_annotation_file_name string reference

* Fixed the links for opening notebook (again!)

* Added attribution and references

* Removed references as covered at top

* Updated installation commands to match

* Updated Vertex AI region name to be more clear

* Added db-types dependency for pandas operations
that are now failing

* Minor edits

* Combined package installation and
added a note to ignore the errors

* Minor edit to message

* Added special thanks to andrewferlitsch@

* Updated andrewferlitsch@ GithHub profile link

* Updated sample files URLs to absolute URLs

* Removed empty code block

* Added additional attribution (and the one that did not make it into previous commit!)

* Fixed multi-package import formatting
Switched to pandas instead of db-dtypes

* Fixed isort issue

* Removed unnecessary pandas import

* Formatted the notebook with nbfmt

* Additional notebook formatting

* Updated link to open in Vertex AI Workbench
to point to raw .ipynb file

* Fixed lint issues

* Formatting changes

Added additional APIs to be enabled

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-19 11:14:17 -07:00
Ivan CheungandGitHub 4fca7d98b2 Increases notebook concurrency and linted CI files (#512)
* Fixed private pool issues

* Ran linter

* Added worker timeouts

* Tweaked timeout

* Removed gcloud requirement

* Removed unneeded file
2022-05-18 18:58:54 -04:00
Andrew FerlitschandGitHub dea950bcb6 fix: DPE styling (#570)
* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning
2022-05-18 14:32:30 -07:00
Andrew FerlitschandGitHub 4c43755fb6 Mlops 8v3 (#569)
* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning
2022-05-18 14:11:31 -07:00
Andrew FerlitschandGitHub 374942a9e9 fix: DPE-style tuning (#568) 2022-05-18 14:01:13 -07:00
Andrew FerlitschandGitHub 8add418428 Mlops 8v2 (#567)
* fix: two towers

* fix: two towers

* fix: typos in twotowers

* fix: typos in twotowers

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning
2022-05-18 13:46:24 -07:00
Andrew FerlitschandGitHub 9d73cc4574 fix: DPE style tuning (#566)
* fix: two towers

* fix: two towers

* fix: typos in twotowers

* fix: typos in twotowers

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning

* fix: DPE-style tuning
2022-05-18 13:29:45 -07:00
Andrew FerlitschandGitHub 5edb4bb1bf fix: DPE-styling (#565)
* fix: two towers

* fix: two towers

* fix: typos in twotowers

* fix: typos in twotowers

* fix: DPE-style tuning

* fix: DPE-style tuning
2022-05-18 12:29:01 -07:00
Andrew FerlitschandGitHub 0e811868d3 fix: links 2022-05-18 11:33:56 -07:00
Andrew FerlitschandGitHub 9efcfa25e8 fix: links 2022-05-18 11:27:11 -07:00
48036cf581 vision api notebook - updated link to open in Vertex AI Workbench (#562)
* Delete revised version

* Copy notebook from /notebooks/official

* Renamed base notebook

* Added first version by mansari@

* Updated to revised version by andrewferlitsch@

* Added author / reviewer information

Added sample files

* Updated CODEOWNERS

* Fixed links for opening the notebook in Colab/Github/Vertex

Removed installation of and references to pandas

Fixed gcs_annotation_file_name string reference

* Fixed the links for opening notebook (again!)

* Added attribution and references

* Removed references as covered at top

* Updated installation commands to match

* Updated Vertex AI region name to be more clear

* Added db-types dependency for pandas operations
that are now failing

* Minor edits

* Combined package installation and
added a note to ignore the errors

* Minor edit to message

* Added special thanks to andrewferlitsch@

* Updated andrewferlitsch@ GithHub profile link

* Updated sample files URLs to absolute URLs

* Removed empty code block

* Added additional attribution (and the one that did not make it into previous commit!)

* Fixed multi-package import formatting
Switched to pandas instead of db-dtypes

* Fixed isort issue

* Removed unnecessary pandas import

* Formatted the notebook with nbfmt

* Additional notebook formatting

* Updated link to open in Vertex AI Workbench
to point to raw .ipynb file

* Fixed lint issues

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-18 11:20:39 -07:00
Andrew FerlitschandGitHub 79fd9b4049 Update README.md 2022-05-17 11:05:54 -07:00
Andrew FerlitschandGitHub 46b2181a4e fix: typos in two towers (#563)
* fix: two towers

* fix: two towers

* fix: typos in twotowers

* fix: typos in twotowers
2022-05-17 11:04:01 -07:00
Andrew FerlitschandGitHub d04f25a8bd Update README.md 2022-05-16 15:13:45 -07:00
Andrew FerlitschandGitHub 9f341c350c fix: two towers (#561)
* fix: two towers

* fix: two towers
2022-05-16 15:11:44 -07:00
Ivan CheungandGitHub f22f97f680 fix: Updated matching engine dependency and fixed cases (#557)
* fix: Updated dependency and fixed cases

* Ran linter

* Renamed to Vertex AI Workbench notebook

* Additional text fixes
2022-05-16 13:06:04 -04:00
Andrew FerlitschandGitHub fe75745d44 feat: WIP: twotowers+matching engine (#560)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* update: ModelEvaluation SDK

* update: ModelEvaluation SDK

* feat: matching engine

* feat: matching engine

* feat: wip: twotowers

* feat: wip: twotowers
2022-05-13 14:03:43 -07:00
Andrew FerlitschandGitHub bbc9f1337e Update README.md 2022-05-13 08:56:39 -07:00
Andrew FerlitschandGitHub eb1fa9213a feat: add notebook for matching engine (#559)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* update: ModelEvaluation SDK

* update: ModelEvaluation SDK

* feat: matching engine

* feat: matching engine
2022-05-12 15:55:21 -07:00
Mohammad Al-AnsariandGitHub a7033a6527 Updates to visionapi notebook (#556)
* Delete revised version

* Copy notebook from /notebooks/official

* Renamed base notebook

* Added first version by mansari@

* Updated to revised version by andrewferlitsch@

* Added author / reviewer information

Added sample files

* Updated CODEOWNERS

* Fixed links for opening the notebook in Colab/Github/Vertex

Removed installation of and references to pandas

Fixed gcs_annotation_file_name string reference

* Fixed the links for opening notebook (again!)

* Added attribution and references

* Removed references as covered at top

* Updated installation commands to match

* Updated Vertex AI region name to be more clear

* Added db-types dependency for pandas operations
that are now failing

* Minor edits

* Combined package installation and
added a note to ignore the errors

* Minor edit to message

* Added special thanks to andrewferlitsch@

* Updated andrewferlitsch@ GithHub profile link

* Updated sample files URLs to absolute URLs

* Removed empty code block

* Added additional attribution (and the one that did not make it into previous commit!)

* Fixed multi-package import formatting
Switched to pandas instead of db-dtypes

* Fixed isort issue

* Removed unnecessary pandas import

* Formatted the notebook with nbfmt

* Additional notebook formatting
2022-05-11 11:23:50 -07:00
Andrew FerlitschandGitHub 7e6c2d69c8 update: ModelEval as SDK (#555)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* update: ModelEvaluation SDK

* update: ModelEvaluation SDK
2022-05-10 15:33:52 -07:00
Andrew FerlitschandGitHub 1a21b81804 fix: stage5 DPE style (#554)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench
2022-05-10 14:11:31 -07:00
Andrew FerlitschandGitHub 2bbd520613 fix: stage4 DPE styling (#553)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench
2022-05-10 13:58:44 -07:00
Andrew FerlitschandGitHub 8285e4ebd1 Mlops 8 (#552)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench
2022-05-10 12:56:43 -07:00
Andrew FerlitschandGitHub 859849894e fix: stage3 workbench (#551)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench
2022-05-10 12:38:52 -07:00
Andrew FerlitschandGitHub e74dd48ae0 fix: 2nd round workbench (#550)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench

* fix: check for workbench
2022-05-10 12:12:27 -07:00
Andrew FerlitschandGitHub a14eb71210 fix: check for workbench (#549)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server

* fix: check for workbench

* fix: check for workbench
2022-05-10 11:37:44 -07:00
Mohammad Al-AnsariandGitHub 0b6a9718ff Added author / reviewer informationAdded sample files (#544)
* Delete revised version

* Copy notebook from /notebooks/official

* Renamed base notebook

* Added first version by mansari@

* Updated to revised version by andrewferlitsch@

* Added author / reviewer information

Added sample files

* Updated CODEOWNERS

* Fixed links for opening the notebook in Colab/Github/Vertex

Removed installation of and references to pandas

Fixed gcs_annotation_file_name string reference
2022-05-09 13:59:59 -07:00
Andrew FerlitschandGitHub 6ac0d8a029 Update README.md 2022-05-09 13:48:00 -07:00
Andrew FerlitschandGitHub 2ee013bcab Delete get_started_nvidia_triton_serving.ipynb 2022-05-09 13:47:18 -07:00
Andrew FerlitschandGitHub 1ebb3f5714 Mlops 8 (#547)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server

* feat: triton server

* feat: triton server
2022-05-09 13:46:35 -07:00
Andrew FerlitschandGitHub 11c5134961 Update README.md 2022-05-09 13:40:51 -07:00
Andrew FerlitschandGitHub e328b7268f feat: triton server (#546)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings

* feat: triton server

* feat: triton server
2022-05-09 13:38:37 -07:00
Andrew FerlitschandGitHub d297e99e5a Update get_started_with_machine_management.ipynb 2022-05-09 12:20:03 -07:00
Andrew FerlitschandGitHub 48c7a4c82e fix: spelling 2022-05-09 12:15:07 -07:00
Andrew FerlitschandGitHub eb3b52f863 Update README.md 2022-05-09 12:10:40 -07:00
Andrew FerlitschandGitHub 4e58cca127 Update get_started_with_machine_management.ipynb 2022-05-09 12:09:07 -07:00
Andrew FerlitschandGitHub 182a98768f feat: machine resource settings (#545)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data

* feat: component vs job resource settings

* feat: component vs job resource settings
2022-05-09 12:06:56 -07:00
Andrew FerlitschandGitHub f483447235 Update README.md 2022-05-06 19:07:16 -07:00
Andrew FerlitschandGitHub c59050608b feat: vision api and automl (#543)
* feat: using Vision API for preprocessing data

* feat: using Vision API for preprocessing data
2022-05-06 19:04:43 -07:00
Andrew FerlitschandGitHub 3b9844f92c update: add co-author (#542)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLABA

* feat: add notebook for TFX

* feat: add notebook for TFX

* feat: add notebook for TFX

* fix: mistakes

* fix: mistakes

* fix: vertex ai compatibility

* fix: vertex ai compatibility

* fix: workbench auth

* fix: workbench auth

* update: add co-author

* update: add co-author
2022-05-06 15:27:05 -07:00
Andrew FerlitschandGitHub ee301a22f6 clean: remove BLAH 2022-05-06 12:38:30 -07:00
Andrew FerlitschandGitHub b7d16f66aa fix: workbench auth (#541)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLABA

* feat: add notebook for TFX

* feat: add notebook for TFX

* feat: add notebook for TFX

* fix: mistakes

* fix: mistakes

* fix: vertex ai compatibility

* fix: vertex ai compatibility

* fix: workbench auth

* fix: workbench auth
2022-05-06 10:18:06 -07:00
Andrew FerlitschandGitHub 57aad5b802 fix: compat issue with Vertex AI and TFX Transform (#540)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLABA

* feat: add notebook for TFX

* feat: add notebook for TFX

* feat: add notebook for TFX

* fix: mistakes

* fix: mistakes

* fix: vertex ai compatibility

* fix: vertex ai compatibility
2022-05-05 19:04:13 -07:00
Andrew FerlitschandGitHub 9e311433ba fix: mistakes in tfx notebook (#539)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLABA

* feat: add notebook for TFX

* feat: add notebook for TFX

* feat: add notebook for TFX

* fix: mistakes

* fix: mistakes
2022-05-05 14:58:04 -07:00
Andrew FerlitschandGitHub 04b310927a Update README.md 2022-05-05 13:36:36 -07:00
Andrew FerlitschandGitHub 2fed3ad014 feat: add TFX pipeline (#538)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLABA

* feat: add notebook for TFX

* feat: add notebook for TFX

* feat: add notebook for TFX
2022-05-05 13:34:22 -07:00
Andrew FerlitschandGitHub 0ec94e0af6 fix: IS_COLAB (#535)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLABA
2022-05-04 13:55:11 -07:00
9470be0900 adds the updated service-account code to mlops/stage3/get_started_with_dataproc_serverless_pipeline_components notebook (#529)
* adds the updated service-account setting code to notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-04 10:04:55 -07:00
479a0c6271 adds the updated service-account code to mlops/stage3/get_started_with_automl_pipeline_components notebook (#528)
* adds the updated service-account setting code to the notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-04 10:04:13 -07:00
053f9c397f adds the updated service-account code to mlops/stage3/get_started_with_kubeflow_pipelines notebook (#527)
* adds updated service-account setting code to the notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-04 10:03:39 -07:00
Andrew FerlitschandGitHub 2c82469756 fix: service account 2022-05-03 08:33:17 -07:00
Andrew FerlitschandGitHub fdfc7009d0 fix: correct IS_COLAB (#531)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work

* fix: IS_COLAB

* fix: IS_COLAB
2022-05-02 14:25:08 -07:00
Andrew FerlitschandGitHub 59fcfe137d fix: typo in stage 2022-05-02 14:00:16 -07:00
Andrew FerlitschandGitHub 9b434b32bc feat: more eval examples (#530)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* feat: more model eval work

* feat: more model eval work
2022-05-02 13:19:07 -07:00
fc27cd8628 Added service account fetch code for colab in get_started_with_rapid_prototyping_bqml_automl file (#520)
* made changes

* ran linter test

* added minor changes

* ran linter test

* made changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-02 09:21:45 -07:00
a62f03c396 Added service account fetch code for colab in get_started_with_custom_training_pipeline_components file (#519)
* made changes

* ran linter test

* made minor changes

* ran linter test

* made changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-02 09:21:08 -07:00
a270439814 Added service account fetch code for colab in get_started_with_bqml_pipeline_components file (#518)
* changes made

* ran linter test

* made minor changes

* ran linter test

* made changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-05-02 09:20:18 -07:00
sudarshan-SpringMLandGitHub a97af4a078 Added service account fetch code for colab in get_started_with_bq_tfdv_pipeline_components file (#517)
* added service account code for colab

* ran linter test

* made changes

* ran linter test
2022-05-02 09:19:29 -07:00
Andrew FerlitschandGitHub d7127cc22f fix: IS_COLAB (#526)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB
2022-04-29 15:25:49 -07:00
Andrew FerlitschandGitHub 802ab4edd8 fix: DPE-styling (#525)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: IS_COLAB

* fix: IS_COLAB

* fix: IS_COLAB
2022-04-29 15:10:19 -07:00
Andrew FerlitschandGitHub ae7f28fb31 fix: DPE-styling updates (#524)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag
2022-04-29 14:06:59 -07:00
f63e3e6e4c Added colab link and made changes in the code in such a way that docker commands can run on colab environment for the file get_started_vertex_training_pytorch (#508)
* Added colab in the notebook

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-29 11:55:51 -07:00
Andrew FerlitschandGitHub b9bb497ebc fix: IS_COLAB (#523)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag

* fix: add IS_COLAB flag
2022-04-29 11:54:21 -07:00
Andrew FerlitschandGitHub 4368b9e7f8 feat: GAPIC->SDK for private endpoint (#516)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model

* feat: GAPIC->SDK for private endpoints

* feat: GAPIC->SDK for private endpoints
2022-04-28 09:59:49 -07:00
2e9cb5d2cf minor change for 'Get started with dataflow pipeline components' (#500)
* Add minor changes to get_started_with_dataflow_pipeline_components

* minor changes and tested

* remove variable dataflow_wait_op, since not used in other places.

* remove variable dataflow_wait_op, since not used in other places

* removed unused import

* Run linter test

* Add gcloud project set when using colab

* Run linter

* correct anem toColab logo Run in Colab

* run linter

* correct the list of items to remove

* Run linter

* Run liinter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-27 16:45:20 -07:00
9ec8a93e05 Minor changes has been done to pipelines_intro_kfp (#494)
* minor changes done

* ran linter test

* chnanged the as per review coments

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-27 09:42:34 -07:00
3ed8778656 Made few changes to sdk-feature-store (#486)
* Added vertexai notebook

* Ran the linter test

* Made the required changes based on the comments

* Ran linter test again

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-27 09:39:03 -07:00
Andrew FerlitschandGitHub bf5e3cf870 fix: delete tmp BQ model (#510)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker

* fix: delete tmp BQ model

* fix: delete tmp BQ model
2022-04-27 09:30:35 -07:00
c23215893d minor changes on stage1 ml ops - Get started vertex datasets (#474)
* Add minor changes to get_started_vertex_datasets notebook

* run linter

* Run Linter test

* Add google authentication cell for colab execution

* run linter

* correct the project id definition

* Run linter

* Add project id cell

* run liner

* Added imports that are required

* run linter test

* Add gcloud project set

* Run linter

* add linter run

* Running linter test

* run linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-25 10:11:27 -07:00
Andrew FerlitschandGitHub 1c96f7ca71 fix: notebook run in colab (#505)
* feat: add colab code for docker

* feat: add colab code for docker

* fix: add colab support for docker

* fix: add colab support for docker
2022-04-22 18:50:29 -07:00
Andrew FerlitschandGitHub 0d5661835b feat: add docker support in Colab (#504)
* feat: add colab code for docker

* feat: add colab code for docker
2022-04-22 13:54:29 -07:00
fe1a3c0bc9 Adds Colab part and minor changes to ml_ops/stage2/get_started_bqml_training notebook (#491)
* adds the ml_ops/stage2/get_Started_bqml_training notebook to official and removes the same from community folder

* ran linter test

* updates the textual content

* ran linter test

* moves the updated stage2/get-started-bqml notebook back to the communit folder

* ran linter test

* updates the header according to the template

* ran linter test

* adds colab part and minor changes

* ran linter test

* retains the newly added code lost in conflicts

* ran linter test

* converts vertex to vertex ai

* ran linter test

* moves deletion of temporary BQ table outside delete_storage condition

* ran linter test

* adds bigquery-storage dependency to the notebook tested on Colab

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-22 11:09:49 -07:00
82bffb87f1 Made some minor changes to sdk-metric-parameter-tracking-for-locally-trained-models (#480)
* Added to correct path

* Ran linter test

* Made some changes

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-22 00:05:57 -07:00
sudarshan-SpringMLandGitHub 741c6732f1 Made minor changes to sdk-metric-parameter-tracking-for-custom-jobs file (#479)
* modified file

* modified file

* ran linter test

* deleted file in community folder

* ran linter test

* changed folder name in links

* ran linter test

* resolved comments

* ran linter test

* modified file

* ran linter test
2022-04-22 00:05:07 -07:00
9d8caf7888 Added markup text mentioning the role provided to service account used by notebook instance & provided key-version value while destroying it in notebook get_started_with_cmek_training (#495)
* Changes made to notebook

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-21 23:37:19 -07:00
e63d354413 Made minor changes to rapid_prototyping_bqml_automl file and moved file from community to official (#496)
* added file

* modified notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-21 22:44:18 -07:00
831c515477 Adding official version for Fraud detection notebook (#321)
* deleted file in community folder

* modified notebook

* ran linter test

* renamed managed_notebooks folder to workbench

* ran linter

* resolved comments

* ran linter test

* pulled new version of branch

* ran linter again

* resolved comments

* ran linter test

* removed %%time and added --user flag to all pip installs

* ran linter test

* added debug statements

* ran linter test

* added verbose

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-21 22:07:58 -07:00
Andrew FerlitschandGitHub 06ba5d6804 fix: SaraRob installation updates (#501)
* feat: improve notebook for metric compare

* feat: improve notebook for metric compare

* feat: improve notebook for metric compare

* feat: improve notebook for metric compare

* feat: improve notebook for metric compare
2022-04-21 11:37:44 -07:00
0137cd106e adds Colab part and minor changes to ml_ops/stage2/get_started_vertex_experiments notebook in community folder (#493)
* updates the get-started-vertex-experiments notebook in the community folder

* ran linter test

* adds the costs section

* ran linter test

* adds colab part and minor changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-21 09:20:29 -07:00
8b3b63d714 Adds Colab part and minor changes to ml_ops/stage2/get_started_automl_training notebook (#492)
* updates the get-started-automl-training notebook

* ran linter test

* adds --user flag during installation step

* ran linter test

* updates the clean up step

* ran linter test

* adds colab part and minor changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-21 09:19:34 -07:00
bf79916f29 Adds Colab part to ml_ops/stage1/get_started_bq_datasets notebook (#490)
* adds the updated mlops-stage1-get_started_bq_datasets notebook to the official branch and removes it from the community branch

* removes second instance of create_bigquery_dataset() function

* ran linter test successfully

* adds costs section

* ran linter test successfully

* updates the dependency installation step and GCS bucket explanation

* ran linter test

* adds pyarrow to the installations

* ran linter test

* removes unnecessary installations + adds silent install + moves the notebook back from official to community folder + adds IS_TESTING condition during clean-up

* ran linter test

* resolves the move up?? comment and builtin comment

* ran linter test

* updates textual content about package installation

* ran linter test

* resolves the future-tense and  dependency installations comments

* ran linter test

* updates the header according to template

* ran linter test

* adds Colab part and minor changes

* ran linter test

* updates the enable apis step in setup project section

* ran linter test

* changes vertex to vertex ai

* ran linter test

* moves temporary BQ table deletion outside the delete_storage condition

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-21 09:17:49 -07:00
6bf462f79d Notebook fix to handle GCS outputs and resolve (AutoML Tabular Forecasting notebook error: no row field 'name' #453) (#477)
* notebook fix to handle gcs output

* linter test

* minor bug fix and markup added

* linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-21 09:13:52 -07:00
Andrew FerlitschandGitHub 106cdee495 feat: update model eval metrics for comparison (#498)
* feat: improve notebook for metric compare

* feat: improve notebook for metric compare

* feat: improve notebook for metric compare
2022-04-20 19:21:23 -07:00
dfb7301733 Inardini - feature store demo blog review (#484)
* review for blog

* linter code passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-18 15:17:17 -07:00
da707b2cbc Made minor changes to custom-tabular-bq-managed-dataset file (#473)
* modified notebook

* modified file

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-18 15:07:07 -07:00
873ba9dde9 Made minor changes to get_started_with_rapid_prototyping_bqml_automl file (#459)
* modified file

* made linter changes

* made changes

* linter test issues resolved

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-18 15:06:27 -07:00
Andrew FerlitschandGitHub 15c452f39d fix: Issue 451, add db-dtypes to requirements (#458)
* fix: issue 451

* fix: issue 451
2022-04-18 12:14:56 -07:00
Andrew FerlitschandGitHub be7111815b fix: getting SERVICE ACCOUNT 2022-04-18 10:59:44 -07:00
17db1a952b Tabnet - Add serving (#482)
* Start a new branch for TabNet tutorial.

* Clean version Created using Colaboratory

* Created using Colaboratory

* Remove unused import

* format lint

* Remove unused import

* Created using Colaboratory

* Remove unused import

* Fix the first iteration of reviewing except the image location

* add import

* Update the image to vertex

* Force delete the BQ to avoid waiting

* Add codeowner for TabNet

* Remove - from folder name

* Add deployment in Vertex AI

* Add delete the resource

Co-authored-by: Long Le <longtle@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-15 12:51:55 -07:00
Andrew FerlitschandGitHub 455143d0f0 Update README.md 2022-04-15 12:26:06 -07:00
Andrew FerlitschandGitHub f0892852cb Update README.md 2022-04-15 12:24:39 -07:00
Andrew FerlitschandGitHub ca48556d0c feat: add tabnet notebook (#483)
* feat: add BQML+MR example

* feat: add BQML+MR example

* feat: add TFE optimizzed

* feat: add TFE optimizzed

* feat: add raw predict example

* feat: add raw predict example

* feat: add tabnet notebook

* feat: add tabnet notebook
2022-04-15 12:21:51 -07:00
Aleksey VlasenkoandGitHub f961aa3174 Minor updates basing on team feedback (#481) 2022-04-15 10:56:46 -07:00
64c8eca7df Refresh of Distributed Hyperparameter Tuning for Colab (#461)
* notebook refresh from vertex ai sdk project

* linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-15 08:49:36 -07:00
b3332c1742 minro changes to get_started_with_hpt_pipeline_components (#465)
* minor changes made to notebook

* ran lintertest

* added coment

* ran lintertest

* made changes sujjested in git review

* ran linter test

* changes done as per review

* ran lintertest

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-14 17:02:23 -07:00
Aleksey VlasenkoandGitHub b35f697a75 Adding samples for Vertex AI Prediction optimized TensorFlow runtime (#475)
* adding Vertex AI optimized TensorFlow runtime samples

* updated URLs, added code to import benchmark.py

* fixed 'Open in Vertex AI Workbench' links

* final cleanup

* added @vlasesnkoalexey as an owner of notebooks/community/vertex_endpoints/optimized_tensorflow_runtime

* rerun linter
2022-04-14 10:14:27 -07:00
3bc32a1d48 Adds Colab part to the ml_ops/stage3/get_started_with_automl_pipelines notebook (#472)
* updates the get-started-automl-pipelines in the mlops/stage3 folder inside community folder

* replaces the unused variable deploy_op with _

* removes the unused Model import

* adds the costs section

* ran linter test

* adds Colab part to the notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 11:52:06 -07:00
d66f851554 Adds Colab part to the ml_ops/stage3/get_started_with_kubeflow_pipelines notebook (#471)
* updates the mlops/stage3/get_started_with_kubeflow_pipelines.ipynb notebook

* fixes unused variables

* fixes conflicting function names

* ran linter test

* adds colab changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 11:51:34 -07:00
d733f107e1 Made minor changes to get_started_with_custom_training_pipeline_components file (#470)
* added colab related content

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 11:51:01 -07:00
805e2e1c83 Made minor changes to get_started_with_bqml_pipeline_components file (#469)
* made colab related changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 11:50:18 -07:00
03dc17d9d7 updates ml_ops/stage3/get_started_with_dataproc_serverless_pipelines notebook (adds delete-batch code + adds colab part + updates textual content) in community folder (#464)
* updates: adds delete-batch code  + adds colab part + updates textual content

* sets delete_bucket to False as default

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 11:49:26 -07:00
a4909f823e Adds changes for Colab support to the ml_ops/stage2/get-started-with-vertex-featstore notebook (#462)
* updates get-started-featurestore notebook in mlops/stage2

* ran linter test

* adds the colab changes and minor textual changes

* ran linter test

* adds the colab changes to the notebook and minor textual changes

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 11:48:58 -07:00
e91b259595 Made minor changes to file get_started_vertex_training_xgboost.ipynb (#436)
* modified file

* run linter test

* run in colab

* added coment

* run lintertest

* changed as per review coments

* ran lintertest

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 10:08:04 -07:00
14284046e4 Made minor changes to get_started_vertex_tensorboard (#437)
* Adding a notebook

* Ran linter test

* Added Colab

* Ran the linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 10:07:24 -07:00
59a9a5e6ba Notebook Refresh E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Distributed Training (#434)
* notebook refresh from vertex ai sdk project

* update with linter test changes

* linter fix

* linter issue

* notebook colab workbench links

* linter test

* linter fix

* linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-12 10:06:01 -07:00
Andrew FerlitschandGitHub f3b0a9e0c0 Update README.md 2022-04-11 18:56:52 -07:00
Andrew FerlitschandGitHub 92b572a364 feat: add raw predict example (#468)
* feat: add BQML+MR example

* feat: add BQML+MR example

* feat: add TFE optimizzed

* feat: add TFE optimizzed

* feat: add raw predict example

* feat: add raw predict example
2022-04-11 18:53:45 -07:00
014be9b530 Made minor changes to get_started_with_data_labeling_2 (#463)
* added colab link and made colab related changes

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-11 16:07:13 -07:00
fa675e0082 inardini real time churn feature store demo fixes (#455)
* add new notebook version

* linter test done. passed

* simple fix

* add images

* linter test done

* fix image name

* fix file name in the notebook

* linter code run. done

* linter code run. done

* name fixes. linter code done. passed.

* fix project id and region

* test done

* format

* linter test done.

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-11 16:01:27 -07:00
Andrew FerlitschandGitHub 113cbb9709 Update README.md 2022-04-11 14:54:27 -07:00
Andrew FerlitschandGitHub b72bdc8112 Update README.md 2022-04-11 12:31:03 -07:00
Andrew FerlitschandGitHub 0842fa8354 Update README.md 2022-04-11 12:30:38 -07:00
Andrew FerlitschandGitHub 4e4f3f4095 Ml ops 7v6 (#467)
* feat: add BQML+MR example

* feat: add BQML+MR example

* feat: add TFE optimizzed

* feat: add TFE optimizzed
2022-04-11 12:16:47 -07:00
Andrew FerlitschandGitHub d014febeb9 Update README.md 2022-04-11 11:37:42 -07:00
Andrew FerlitschandGitHub a3264df643 feat: add BQML + MR example (#466)
* feat: add BQML+MR example

* feat: add BQML+MR example
2022-04-11 11:36:50 -07:00
f0208e3e37 Made minor changes to get_started_with_custom_training_pipeline_components (#456)
* modified file

* modified notebook

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-08 09:31:37 -07:00
f84e1b9cbc Updates ml_ops/stage3/get-started-kubeflow-pipeline-notebook in the community folder (#449)
* updates the mlops/stage3/get_started_with_kubeflow_pipelines.ipynb notebook

* fixes unused variables

* fixes conflicting function names

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-08 09:31:05 -07:00
16b2086031 Made minor changes to get_started_with_bqml_pipeline_components (#444)
* modified notebook

* linter modifications made

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-08 09:30:20 -07:00
0e24ba565d Updates ml_ops/stage3/get-started-automl-pipeline-notebook in the community folder (#440)
* updates the get-started-automl-pipelines in the mlops/stage3 folder inside community folder

* replaces the unused variable deploy_op with _

* removes the unused Model import

* adds the costs section

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-08 09:29:37 -07:00
49718b02a5 Made minor changes to get_started_with_bq_tfdv_pipeline_components (#439)
* modified notebook

* linter test issues resolved

* ran linter test

* added colab option

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-08 09:29:03 -07:00
63031ed364 Updates ml_ops/stage2/get_started_vertex_featurestore notebook in community folder. (#426)
* updates get-started-featurestore notebook in mlops/stage2

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-08 09:26:57 -07:00
9fd325e25b Made minor changes to file get_started_with_data_labeling (#425)
* modified notebook

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-04-08 09:22:12 -07:00
93af43419c Updates Mlops/stage2/get-started-automl-training notebook in the community folder (#409)
* updates the get-started-automl-training notebook

* ran linter test

* adds --user flag during installation step

* ran linter test

* updates the clean up step

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-07 13:03:29 -07:00
c8f0cdb74a Refresh of Distributed Hyperparameter Tuning Notebook (#454)
* notebook refresh

* linter test

* notebook refresh added corrected cleanup

* linter test

* notebook refresh added corrected cleanup

* linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-07 14:07:47 -05:00
19368fe5cc inardini google cloud pipelines dataproc tabular (#445)
* add dataproc components tabular notebook

* add src package

* add codeowner

* linter test done. almost ok except for the flake8 E231. need to follow up with andy

* fix typos based on andy review

* linter test done. review with andy

* hyperparameter_tuning_op fix

* project name

* add delete repo

* fix image

* linter test done

* fix image reference

* fix typo image reference

* minor fixes

* karl fixes

* karl fixes on links

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-07 10:10:33 -07:00
6a05e0eb6c inardini real time churn feature store demo (#448)
* add new notebook version

* linter test done. passed

* simple fix

* add images

* linter test done

* fix image name

* fix file name in the notebook

* linter code run. done

* linter code run. done

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-07 10:21:22 -05:00
40d643f11c Change bq://bigquery-public-data:iowa_liquor_sales_forecasting.2021_sales_predict for PREDICTION_DATASET_BQ_PATH (#423)
Co-authored-by: Jungwoon Lee <jungwoonlee@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-07 09:10:10 -05:00
Andrew FerlitschandGitHub 72009cd21b fix: misspelling of BigQuery 2022-04-06 20:15:07 -07:00
Andrew FerlitschandGitHub cc9a50f40b Update get_started_with_vertex_private_endpoints.ipynb 2022-04-06 19:56:51 -07:00
Andrew FerlitschandGitHub e3135e8875 Update README.md 2022-04-06 17:42:45 -07:00
Andrew FerlitschandGitHub 59eb297151 feat: add notebook for private endpoints (#450)
* feat: add notebook for FastAPI server

* feat: add notebook for FastAPI server

* feat: add notebook for FastAPI server

* feat: notebook for private endpoints

* feat: notebook for private endpoints
2022-04-06 17:41:10 -07:00
32b0c1c89e Mco mvmm (#420) - move model monitoring notebook from community to official
* license tweak

* remove unused import json

* fixed a missing import

* add sleep(300) to test my theory

* add missing newline

* put sleep behind a conditional

* revert new notebook name to previous name for compatibility with extant links

* fix quoting syntax error

* reformatted due to relint

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-06 22:37:53 +01:00
3328a8190d Adding sample to use (auto) scaling config for Feature Store online store (#367)
* Add example using auto scale

* Format with nbqa

* Complete sentence

* Give the sample for CreateFeaturestoreRequest only, instead of actual call to create FS to avoid duplicate resource or extra cleanup.

* Remove unused import

* Remove version pinning

* Add try block to avoid error when test was not cleanup properly.

* Lint

* Fix import

* Merge print lro result with the call in the same try block

* Fix typo

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Morgan Du <morgandu@google.com>
2022-04-05 17:02:49 -07:00
7aa6acdca6 fix UnboundLocalError in TF-Agents Bandits Guide (#446)
In "Step by Step Guide to Building Reinforcement Learning Applications using Vertex AI", the replay_buffer was unbound if training_data_spec_transformation_fn was provided to the train() function

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-04-05 16:30:40 -05:00
Andrew FerlitschandGitHub 7926ff1264 Update README.md 2022-04-05 11:10:12 -07:00
Andrew FerlitschandGitHub 67b926dfb4 feat: add notebook for FastAPI server (#447)
* feat: add notebook for FastAPI server

* feat: add notebook for FastAPI server

* feat: add notebook for FastAPI server
2022-04-05 11:08:09 -07:00
327f9e7a4b Fix typo in notebook heading. (#443)
* Fix typo in notebook heading.

* Fix linting issues.

Co-authored-by: Win Woo <wwoo@google.com>
2022-04-05 08:43:47 -05:00
Andrew FerlitschandGitHub 8be220d089 fix missing + 2022-04-04 14:40:27 -07:00
Andrew FerlitschandGitHub 2dad40f49f bucket setting fine-tuning 2022-04-04 14:39:45 -07:00
Andrew FerlitschandGitHub 99b724028f Update README.md 2022-04-04 13:51:43 -07:00
Andrew FerlitschandGitHub 909fbcb0d4 feat: notebook for TF Serving binary (#442)
* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: workaround for blocking issue

* update: workaround for blocking issue

* fix: reconfigure endpoint

* fix: reconfigure endpoint

* feat: add get started with TF serving functions

* feat: add get started with TF serving functions

* feat: notebook for TF Serving

* feat: notebook for TF Serving
2022-04-04 13:49:39 -07:00
Andrew FerlitschandGitHub 351fc3e4d3 fix: remove unused print_op 2022-04-04 09:05:33 -07:00
252b3d31a3 Inardini bqml components pipeline official blog (#416)
* bqml pipeline notebook for official blog

* add notebook to CODEOWNERS

* add author name

* requirements commenting fix

* linter test done

* unpin the maintenance version for kfp

* fix: install conflicts

* Update google_cloud_pipeline_components_bqml_text.ipynb

* add karl fix

* lint test done

* add andy fixes

* linter test done

* flip order of the special METADATA fix

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@gmail.com>
2022-04-04 09:00:17 -07:00
Andrew FerlitschandGitHub bfdfaab38c Update README.md 2022-04-01 16:11:28 -07:00
Andrew FerlitschandGitHub 21a5963f84 feat: notebook for tf serving functions (#438)
* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: workaround for blocking issue

* update: workaround for blocking issue

* fix: reconfigure endpoint

* fix: reconfigure endpoint

* feat: add get started with TF serving functions

* feat: add get started with TF serving functions
2022-04-01 16:09:39 -07:00
9452249dce Added a new section called "Grant Dataproc roles to the Service Account" (#433)
* Ml ops 7v2 (#429)

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* Update README.md

* Add files via upload

* Update README.md

* Delete stage6b.png

* Delete stage6c.png

* Add files via upload

* Delete stage6b.png

* Delete stage6c.png

* Add files via upload

* Delete stage6b.png

* feat: new notebook on endpoints (#430)

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: workaround for blocking issue

* update: workaround for blocking issue

* wrong location

* Create README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* fix: links

* fix: title

* fix: example for reconfiguring the traffic split (#431)

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: workaround for blocking issue

* update: workaround for blocking issue

* fix: reconfigure endpoint

* fix: reconfigure endpoint

* Add section on granting Dataproc IAM roles.

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@gmail.com>
Co-authored-by: Win Woo <wwoo@google.com>
2022-03-31 20:14:16 -07:00
Andrew FerlitschandGitHub 49a9df058f fix: example for reconfiguring the traffic split (#431)
* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: workaround for blocking issue

* update: workaround for blocking issue

* fix: reconfigure endpoint

* fix: reconfigure endpoint
2022-03-31 15:27:27 -07:00
Andrew FerlitschandGitHub f99b7e5d17 fix: title 2022-03-31 12:28:15 -07:00
Andrew FerlitschandGitHub ac03c57a94 fix: links 2022-03-31 12:27:47 -07:00
Andrew FerlitschandGitHub 2e4cf648c5 Update README.md 2022-03-31 12:27:01 -07:00
Andrew FerlitschandGitHub f000baa328 Update README.md 2022-03-31 12:26:35 -07:00
Andrew FerlitschandGitHub 113f89604a Update README.md 2022-03-31 12:26:01 -07:00
Andrew FerlitschandGitHub 5019a004ce Update README.md 2022-03-31 12:25:42 -07:00
Andrew FerlitschandGitHub a577f3844a Create README.md 2022-03-31 12:25:31 -07:00
Andrew FerlitschandGitHub 88c7f0f690 wrong location 2022-03-31 12:24:20 -07:00
Andrew FerlitschandGitHub a18792499a feat: new notebook on endpoints (#430)
* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: workaround for blocking issue

* update: workaround for blocking issue
2022-03-31 12:23:22 -07:00
Andrew FerlitschandGitHub 0b5fc8bb3c Delete stage6b.png 2022-03-30 19:34:52 -07:00
Andrew FerlitschandGitHub 1f77410fda Add files via upload 2022-03-30 19:34:31 -07:00
Andrew FerlitschandGitHub 45fb57f29c Delete stage6c.png 2022-03-30 19:34:11 -07:00
Andrew FerlitschandGitHub 3380b394eb Delete stage6b.png 2022-03-30 19:34:03 -07:00
Andrew FerlitschandGitHub 1286cc5044 Add files via upload 2022-03-30 19:33:20 -07:00
Andrew FerlitschandGitHub 1ce1af791c Delete stage6c.png 2022-03-30 19:31:24 -07:00
Andrew FerlitschandGitHub 2587e329ee Delete stage6b.png 2022-03-30 19:31:15 -07:00
Andrew FerlitschandGitHub 37d4816051 Update README.md 2022-03-30 19:30:19 -07:00
Andrew FerlitschandGitHub d9dff882b8 Add files via upload 2022-03-30 19:29:41 -07:00
Andrew FerlitschandGitHub 26cc2c5278 Update README.md 2022-03-30 19:21:49 -07:00
Andrew FerlitschandGitHub 69aff1bdc4 Ml ops 7v2 (#429)
* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook
2022-03-30 19:20:41 -07:00
Andrew FerlitschandGitHub 567994f2b1 fix: add missing details to objective in endpoint notebooks (#428)
* update: more details to objective on endpoint notebook

* update: more details to objective on endpoint notebook
2022-03-30 19:16:02 -07:00
Andrew FerlitschandGitHub e316c7b8aa Update README.md 2022-03-30 17:31:59 -07:00
Andrew FerlitschandGitHub c07a059a8b Update README.md 2022-03-30 17:30:46 -07:00
Andrew FerlitschandGitHub 7b4bbffc41 feat: add endpoint notebook (#427)
* feat: add data labeling notebook

* feat: add data labeling notebook

* update: details on dsl.Condition

* update: details on dsl.Condition

* feat: add TFHub model example

* feat: add TFHub model example

* feat: add endpoint notebook

* feat: add endpoint notebook
2022-03-30 15:44:54 -07:00
bdc011ef34 Made some minor changes to get_started_vertex_training_pytorch (#406)
* Added notebook

* Ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-30 08:21:22 -05:00
Andrew FerlitschandGitHub 44ea0d7c61 Update README.md 2022-03-28 17:00:01 -07:00
Andrew FerlitschandGitHub aa950e5ee4 feat: add TFHub model example (#422)
* feat: add data labeling notebook

* feat: add data labeling notebook

* update: details on dsl.Condition

* update: details on dsl.Condition

* feat: add TFHub model example

* feat: add TFHub model example
2022-03-28 16:57:04 -07:00
Andrew FerlitschandGitHub 247906e50e fix: WORKDIR in Dockerfile 2022-03-28 15:52:28 -07:00
81b2493a44 Made minor changes to get_started_vertex_training_r (#417)
* addd file

* modified file

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-03-28 13:26:54 -07:00
WhiteSource RenovateandGitHub 97b0edb222 chore(deps): update dependency black to v22.3.0 (#421) 2022-03-28 14:23:25 -05:00
sudarshan-SpringMLandGitHub f0a9e4b9fe added mlops folder to tested_folders file (#418) 2022-03-28 10:37:21 -05:00
Andrew FerlitschandGitHub f35bbcaec5 update: details on dsl.Condition (#415)
* feat: add data labeling notebook

* feat: add data labeling notebook

* update: details on dsl.Condition

* update: details on dsl.Condition
2022-03-26 09:51:01 -07:00
Andrew FerlitschandGitHub 2822061dc9 Update README.md 2022-03-25 16:00:46 -07:00
Andrew FerlitschandGitHub be481c8d17 feat: add data labeling notebook (#414)
* feat: add data labeling notebook

* feat: add data labeling notebook
2022-03-25 15:56:22 -07:00
Andrew FerlitschandGitHub 605a972122 fix: testing issues (#413)
* fix: testing issues

* fix: testing issues
2022-03-25 13:26:53 -07:00
Andrew FerlitschandGitHub 66d98d9fe7 fix: testing issues (#412)
* fix: test failures

* fix: test failures
2022-03-25 10:58:39 -07:00
Krishna Chaitanya MovvaandGitHub 6445ed37c9 Updates the Mlops/stage2/ get-started-vertex-experiments notebook in the community folder (#410)
* updates the get-started-vertex-experiments notebook in the community folder

* ran linter test

* adds the costs section

* ran linter test
2022-03-25 10:52:21 -05:00
Andrew FerlitschandGitHub ca745aeee8 fix: better cleanup (#407)
* update: for official

* update: for official

* cleanup: add deleting model/endpoint created from pipeline

* cleanup: add deleting model/endpoint created from pipeline

* feat: add dataproc notebook

* feat: add dataproc notebook

* fix: better cleanup

* fix: better cleanup
2022-03-24 18:58:43 -07:00
f806b4927b Adds updated Mlops/stage1/get-started-bq notebook to the community folder (#392)
* adds the updated mlops-stage1-get_started_bq_datasets notebook to the official branch and removes it from the community branch

* removes second instance of create_bigquery_dataset() function

* ran linter test successfully

* adds costs section

* ran linter test successfully

* updates the dependency installation step and GCS bucket explanation

* ran linter test

* adds pyarrow to the installations

* ran linter test

* removes unnecessary installations + adds silent install + moves the notebook back from official to community folder + adds IS_TESTING condition during clean-up

* ran linter test

* resolves the move up?? comment and builtin comment

* ran linter test

* updates textual content about package installation

* ran linter test

* resolves the future-tense and  dependency installations comments

* ran linter test

* updates the header according to template

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-24 14:16:51 -05:00
2942eb5d7f minor changes on Sdk automl tabular regression online bq1 (#369)
* add automl tabular regression online bq with minor changes

* Run Linter

* Fix errors from the CLA test

* run linter

* resolve issue.

* run Linter

* Merge

* test lint

* fix for linter test

* add automl tabular regression online bq with minor changes

* Run Linter

* Fix errors from the CLA test

* run linter

* resolve issue.

* run Linter

* Merge

* test lint

* fix for linter test

* Fix Bucket name variable

* run linter

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-24 14:16:30 -05:00
2a5d6650ee Adds updated Mlops/stage2/get-started-bqml-training notebook to the community folder (#397)
* adds the ml_ops/stage2/get_Started_bqml_training notebook to official and removes the same from community folder

* ran linter test

* updates the textual content

* ran linter test

* moves the updated stage2/get-started-bqml notebook back to the communit folder

* ran linter test

* updates the header according to the template

* ran linter test

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-24 14:11:01 -05:00
Andrew FerlitschandGitHub 43e971f57a Update README.md 2022-03-24 11:38:17 -07:00
Andrew FerlitschandGitHub 785779613b feat: add dataproc notebook (#405)
* update: for official

* update: for official

* cleanup: add deleting model/endpoint created from pipeline

* cleanup: add deleting model/endpoint created from pipeline

* feat: add dataproc notebook

* feat: add dataproc notebook
2022-03-23 15:43:53 -07:00
Andrew FerlitschandGitHub 481193f0ca cleanup: delete created resources in the pipeline (#404)
* update: for official

* update: for official

* cleanup: add deleting model/endpoint created from pipeline

* cleanup: add deleting model/endpoint created from pipeline
2022-03-23 14:06:58 -07:00
Karl WeinmeisterandGitHub 2cb3cccd14 Fix: Linting issues in two tower notebook (#402) 2022-03-22 16:08:12 -05:00
7c16766994 minor changes in sdk automl image object detection batch (#370)
* Add minor changes to automl image object detection

* run linter

* Correct the milli nodes hours

* fix errors

* fix getenv

* Run linter

* remove tabular notebook, wrongly added

* Correct the bucket varible and minor changes to text

* Run linter

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-03-22 13:18:27 -07:00
Andrew FerlitschandGitHub 448d18deca update: for official (#401)
* update: for official

* update: for official
2022-03-22 09:26:34 -07:00
97022b0733 Feat: Add Pluto on Workbench tutorial (#399)
* Initial commit

* Undo master commit

* Initial commit

* Update CODEOWNERS

* Add links to resolve PR comments

Co-authored-by: Ward K Harold <wkh@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-22 10:10:46 -05:00
c2a3e2d4cd deprecate: gapic XAI notebooks replaced by SDK notebooks (#394)
* deprecate: replaced by SDK notebook

* deprecate: replaced by SDK notebook

* deprecate: replaced by SDK notebook

* deprecate: replaced by SDK notebook

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-22 09:46:47 -05:00
manuelamunateguiandGitHub b2dfcf17c8 E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Training for Scikit-Learn (#398)
* notebook refresh

* linter test after refresh
2022-03-22 09:37:09 -05:00
Andrew FerlitschandGitHub d061f09281 fix: replace os.environ with os.getenv - 2nd batch (#396)
* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv

* fix: replace os.environ with os.getenv
2022-03-19 12:02:47 -05:00
daa64efd40 fix: replace os.environ with os.getenv (#393)
* fix: use os.getenv()

* fix: use os.getenv()

* fix: use os.getenv()

* fix: use os.getenv()

* fix: use os.getenv()

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-18 16:44:34 -05:00
Andrew FerlitschandGitHub a37deabe27 Update README.md 2022-03-18 13:15:34 -07:00
Andrew FerlitschandGitHub 6009ef0def Update README.md 2022-03-18 13:14:34 -07:00
Andrew FerlitschandGitHub edc644b0d0 Update README.md 2022-03-18 13:13:15 -07:00
Andrew FerlitschandGitHub 1297af8baf Create README.md 2022-03-18 13:11:38 -07:00
Andrew FerlitschandGitHub b8b1b6675b Update README.md 2022-03-18 13:09:51 -07:00
Andrew FerlitschandGitHub 7d3b7abc44 fix: review updates (#395)
* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook

* feat: finalize CPR notebook

* feat: finalize CPR notebook

* feat: notebook for bqml+automl

* feat: notebook for bqml+automl

* review: edits per Erwin review

* review: edits per Erwin review
2022-03-18 12:09:53 -07:00
Rajesh ThallamandGitHub 9a572f298e [community-content] Notebook to demo NVIDIA Triton Inference Server on Vertex AI Prediction (#391)
* Add NVIDIA Triton on Vertex AI Prediction official notebook

* Add NVIDIA Triton on Vertex AI Prediction official notebook

* Add NVIDIA Triton on Vertex AI Prediction official notebook

* Add NVIDIA Triton on Vertex AI Prediction community notebook

* Add NVIDIA Triton on Vertex AI Prediction community notebook

* Add NVIDIA Triton on Vertex AI Prediction community notebook

* Fixes based on feedback to NVIDIA Triton on Vertex AI Prediction community notebook
2022-03-18 11:31:01 -05:00
b53ca9e678 Tabnet (#375)
* Start a new branch for TabNet tutorial.

* Clean version Created using Colaboratory

* Created using Colaboratory

* Remove unused import

* format lint

* Remove unused import

* Created using Colaboratory

* Remove unused import

* Fix the first iteration of reviewing except the image location

* add import

* Update the image to vertex

* Force delete the BQ to avoid waiting

* Add codeowner for TabNet

* Remove - from folder name

Co-authored-by: Long Le <longtle@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-17 17:20:01 -05:00
Andrew FerlitschandGitHub 9aceec161a Update README.md 2022-03-17 14:50:24 -07:00
Andrew FerlitschandGitHub 98b186ed55 feat: notebook for bqml+automl combined (#390)
* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook

* feat: finalize CPR notebook

* feat: finalize CPR notebook

* feat: notebook for bqml+automl

* feat: notebook for bqml+automl
2022-03-17 14:46:29 -07:00
sudarshan-SpringMLandGitHub f23ee1b5a8 Made small changes to Get started vertex vizier notebook (#389)
* modified notebook

* ran linter test

* modified notebook changed copyright licence year

* ran linter test
2022-03-17 10:03:19 -05:00
c6d779f1fc Featurestore colab update (#387)
* update featurestore colab comment

* delete some changes

* delete some changes 2

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-16 21:31:22 -05:00
Andrew FerlitschandGitHub 8908b27b08 feat: finish CPR notebook (#388)
* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook

* feat: finalize CPR notebook

* feat: finalize CPR notebook
2022-03-16 14:00:03 -07:00
Andrew FerlitschandGitHub 8947c9b116 feat: more CPR (#385)
* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook

* feat: add CPR notebook
2022-03-15 11:56:29 -07:00
Andrew FerlitschandGitHub 9464caac6e Update README.md 2022-03-14 17:40:15 -07:00
Andrew FerlitschandGitHub 98ce91c575 feat: add CPR notebook (#384)
* feat: add CPR notebook

* feat: add CPR notebook
2022-03-14 17:38:47 -07:00
Andrew FerlitschandGitHub 07f8feda3d Update README.md 2022-03-14 11:19:31 -07:00
Andrew FerlitschandGitHub a4e0496ff5 feat: CMEK training (#383)
* feat: add FS from panda

* feat: add FS from panda

* feat: add CMEK example

* feat: add CMEK example
2022-03-14 11:15:35 -07:00
cf162c02c8 chore(deps): update dependency pyupgrade to v2.31.1 (#381)
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-14 09:34:58 -05:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Karl Weinmeister
831aae94df build(deps): bump pillow (#378)
Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.0.0 to 9.0.1.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/9.0.0...9.0.1)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-14 09:33:36 -05:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Karl Weinmeister
3fd9f28778 build(deps): bump pillow (#379)
Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.0.0 to 9.0.1.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/9.0.0...9.0.1)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-14 09:32:20 -05:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
a656e8e2a8 build(deps): bump pillow (#380)
Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.0.0 to 9.0.1.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/9.0.0...9.0.1)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-14 09:30:19 -05:00
Morgan DuandGitHub 2f02152703 fix: pip install google-cloud-aiplatform (#376) 2022-03-10 12:00:08 -06:00
9d08f8ce67 Using BQML 1st-party components and upgrading to 1.0.0 of google-cloud-pipeline-components (#372)
* Using BQML 1st-party components and 1.0.0 of google-cloud-pipeline-components

* Using BQML 1st-party components and upgrading to 1.0.0 of google-cloud-pipeline-components

* Using BQML 1st-party components and upgrading to 1.0.0 of google-cloud-pipeline-components

* Using BQML 1st-party components and upgrading to 1.0.0 of google-cloud-pipeline-components

* Using BQML components and upgrade to 1.0.0 of GCPC

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-09 13:34:12 -06:00
ec6d508793 adds automl-text-sentiment-analysis-online notebook (#293)
* adds automl-text-sentiment-analysis-online notebook

* adds the cleaned up automl-text-sentiment-analysis notebook after running linter test

* adds textual content on what the dataset predicts in the dataset section

* ran the linter test after the update

* adds textual content on what the dataset predicts in the dataset section

* ran the linter test after the update

* corrects the IMPORT_FILE parameter in the notebook

* ran linter test after update

* deletes the source file from the community/sdk folder

* updates the colab, git & workbench links in the notebook

* ran linter test

* updates the license year to 2022 and simplifies the clean-up step for bucket-deletion

* ran linter test

* adds TESTING env condition while deleting the buckets

* ran linter test successfully

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-09 13:09:10 -06:00
WhiteSource RenovateandGitHub 772e35ea75 chore(deps): update dependency nbqa to v1.3.1 (#374) 2022-03-09 08:24:16 -06:00
Andrew FerlitschandGitHub 1d28f886c8 feat: add example of FS values from dataframe (#373)
* feat: add FS from panda

* feat: add FS from panda
2022-03-08 17:44:59 -08:00
Andrew FerlitschandGitHub d3dc8aeb9a fix: missing create dataset schema (#371)
* fix: missing dataset create

* fix: missing dataset create
2022-03-07 11:53:39 -08:00
WhiteSource RenovateandGitHub a07d762934 chore(deps): update dependency nbqa to v1.3.0 (#368) 2022-03-07 09:53:42 -06:00
Andrew FerlitschandGitHub 85ac9e127d update: v1 (#366)
* fix: v1 upgrades

* fix: v1 upgrades

* fix: v1 upgrades

* fix: v1 upgrades

* update: v1

* update: v1
2022-03-04 17:47:56 -08:00
Gal ZahaviandGitHub 011c2823ff Update CODEOWNERS (#361) 2022-03-04 22:43:10 +02:00
Karl WeinmeisterandGitHub f28a94f03f docs: Add visualization of repo structure to README.md (#364) 2022-03-04 12:46:26 -06:00
5ecfc80cb9 Adds minor changes(license year and clean-up step) to Sdk automl video action recognition batch notebook (#355)
* adds the automl-video-action-recognition-notebook

* ran linter test

* fixes the dag variable by replacing with job

* ran linter test

* fixes the dag variable by replacing with job

* ran linter test

* corrects the IMPORT_FILE parameter in the notebook

* ran linter test after update

* updates the colab, git & vertex-ai links

* ran linter test

* updates the license year to 2022 and simplifies the lean-up step for bucket created

* ran linter test

* removes the file from the community folder

* adds the TESTING env condition while deleting the buckets

* ran linter test successfully

* adds TESTING env condition while deleting the bucket

* ran linter test successfully

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-04 12:44:39 -06:00
Andrew FerlitschandGitHub e5e36ba050 fix: upgrades to v1 (#360)
* fix: v1 upgrades

* fix: v1 upgrades

* fix: v1 upgrades

* fix: v1 upgrades
2022-03-03 20:05:36 -08:00
Andrew FerlitschandGitHub 0ad9116d6a fix: v1 upgrades (#359)
* fix: v1 upgrades

* fix: v1 upgrades
2022-03-03 17:49:45 -08:00
0516032443 Update CODEOWNERS (#354)
* Update CODEOWNERS

* Update CODEOWNERS

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-03 10:23:19 -06:00
95d211c90f Fixing minor issues in sdk_automl_text_entity_extraction_online.ipynb (#329)
* modified colab,github,vertexAI links and added vertex logo

* ran linter

* resolved comments

* ran linter

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-03 10:17:48 -06:00
12d6a75ef7 Fixing minor issues in sdk_automl_video_object_tracking_batch.ipynb (#328)
* changed master to main for links and added vertex AI logo

* ran linter

* resolved comments

* ran linter

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-03-03 10:07:50 -06:00
Andrew FerlitschandGitHub 06153dc373 Update README.md 2022-03-02 11:45:01 -08:00
Andrew FerlitschandGitHub 02afa91fc3 Ml ops 6v3 (#352)
* fix: eval comp improvement

* fix: eval comp improvement

* feat: add to KFP get started
2022-03-02 10:38:42 -08:00
Karl WeinmeisterandGitHub c8b212789f Revert "ci: Apply filter to format_and_lint_job (#348)" (#351)
This reverts commit 95256d3fcf.
2022-03-02 09:44:03 -06:00
Karl WeinmeisterandGitHub 95256d3fcf ci: Apply filter to format_and_lint_job (#348)
* ci: Apply filter to format_and_lint_job

Only run when PR contains a notebook file

* Minor fix
2022-03-02 09:29:38 -06:00
Karl WeinmeisterandGitHub 8a6d174c99 Create README.md for notebooks folder 2022-03-01 19:44:41 -06:00
WhiteSource RenovateandGitHub d36cf7f662 chore(deps): update actions/setup-python action to v3 (#337) 2022-03-01 19:04:32 -06:00
WhiteSource RenovateandGitHub 1b02a542c8 chore(deps): update actions/checkout action to v3 (#347) 2022-03-01 19:02:39 -06:00
Ivan CheungandGitHub 45430bb010 Fixed minor issues (#345) 2022-03-01 14:56:50 -06:00
Ivan CheungandGitHub be2a139ade Delete notebooks/community/feature_store/assets directory 2022-02-28 20:21:17 -05:00
70d77b24f6 feature store e2e with assets (#343)
* A notebook that shows Vertex AI feature store capabilities in a real-world scenario (#296)

* A notebook that shows Vertex AI feature store capabilities in a real-world scenario

* new notebook version

* fix CODEOWNERS

* comment to the feature store monitoring api

* format notebook

* fix CODEOWNERS

* fix CODEOWNERS as required

* new version

* new notebook version

* notebook cleaning

* new update

* add fix to pass lint test

* resolve conflict

* import libraries fix

* update image

* update notebook

* fix comment

* new notebook version

* new notebook and assets

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>

* Added files in their old folder

* Deleted unneeded file

* Ran linter

* Fixed CODEOWNERS

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: ivanmkc <ivans.mailbox@gmail.com>
2022-02-28 19:23:15 -05:00
Ivan CheungandGitHub 50c25d6d7b Revert "A notebook that shows Vertex AI feature store capabilities in a real-world scenario (#296)" (#338)
This reverts commit 5bcdc0bc64.
2022-02-28 11:01:39 -05:00
5bcdc0bc64 A notebook that shows Vertex AI feature store capabilities in a real-world scenario (#296)
* A notebook that shows Vertex AI feature store capabilities in a real-world scenario

* new notebook version

* fix CODEOWNERS

* comment to the feature store monitoring api

* format notebook

* fix CODEOWNERS

* fix CODEOWNERS as required

* new version

* new notebook version

* notebook cleaning

* new update

* add fix to pass lint test

* resolve conflict

* import libraries fix

* update image

* update notebook

* fix comment

* new notebook version

* new notebook and assets

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-02-28 07:47:26 -08:00
eff0f95b58 Automl links fix (#330)
* fixing links to open notebook - main and images

* linter test changes

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-02-27 15:57:25 -06:00
50b53d31bd Jfacevedo endpoints tfhub obj detect (#319)
* Deploying TF Hub object detection model using Vertex endpoints

* Add user to codeowners

* fix path in CODEOWNERS

* clear all outputs

* run linter

* manual lint fix

* fix more linting errors

* order imports in alphabetical order

* run linter

* made changes requested on feedback

* automate fetching endpoint model id

* fix hardcoded value in bash command

* generalize region endpoint and project in bash cell

* retrieve endpoint and model ids programatically

* fix formatting

* run linter

* Remove pipfile

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-02-27 15:55:54 -06:00
Andrew FerlitschandGitHub b5a56852f3 fix: automl eval component improvement (#333)
* fix: eval comp improvement

* fix: eval comp improvement
2022-02-25 12:07:06 -08:00
b7486e34ad Sdk automl video action recognition batch (#310)
* adds the automl-video-action-recognition-notebook

* ran linter test

* fixes the dag variable by replacing with job

* ran linter test

* fixes the dag variable by replacing with job

* ran linter test

* corrects the IMPORT_FILE parameter in the notebook

* ran linter test after update

* updates the colab, git & vertex-ai links

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-02-25 11:31:19 -06:00
3edc5f1425 Notebook template (#326)
* modified vertex AI link

* minor change

* changed master to main and added vertex logo

* ran lint

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-02-25 10:16:34 -06:00
65b4b73cb5 Add google_cloud_pipeline_components_model_upload_predict_evaluate notebook (#288)
* Add google_cloud_pipeline_components_model_upload_predict_evaluate notebook.ipynb

* format with linter

* add import for tensorflow when in the testing environment

* linter

* fix dependency issues for testing env

* address comments

* eval component  does not output gcp_resources yet, still in experimental

* added location to aip.init

* add deletion for model and batch prediction jobs

* typo, missed a comma.

* linter

* Remove tensorflow import + use gsutil to check if artifacts exist.

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-02-24 15:36:35 -08:00
Ivan CheungandGitHub 186c08e8c3 Update sdk_matching_engine_for_indexing.ipynb 2022-02-24 17:47:53 -05:00
Ivan CheungandGitHub 7721aa0def Added matching engine with SDK notebook (#327)
* Matching engine

* Added notebook

* Updated CODEOWNERS

* Fixed links

* Added logo

* Renamed Workbench
2022-02-24 14:57:16 -05:00
4987c60e03 updating gcloud usage because a flag was renamed (#320)
Co-authored-by: Yicheng Fang <yichengfang@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
2022-02-24 09:33:33 -06:00
Andrew FerlitschandGitHub cd845f7fdd feat: start on model eval notebook (#325)
* fix: bqml export format

* fix: bqml export format

* feat: start on custom model eval

* feat: start on custom model eval
2022-02-23 12:56:01 -08:00
Andrew FerlitschandGitHub 9e84d9e782 fix: bqml doc for exporting model (#324)
* fix: bqml export format

* fix: bqml export format
2022-02-23 12:44:43 -08:00
nayaknishantandGitHub 23c7fcc97f fix: changed bucket URL from pantheon to console (#323)
* moving REGION up

* moving REGION up and csv file name

* fix: changed bucket URL to console
2022-02-23 13:17:12 -06:00
e4024efbc7 feat: add community notebook for Vertex AI SDK Feature Store with Pandas (#311)
* feat: add sdk-feature-store-pandas notebook

* fix: add ldap to codeowners

* feat: add sdk-feature-store-pandas notebook

* fix: add ldap to codeowners

* fix: lint

* fix: addressed feedback

* fix: format

* fix: lint

* Linted

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: ivanmkc <ivans.mailbox@gmail.com>
2022-02-23 10:22:28 -08:00
Ivan CheungandGitHub c4d53108af Matching Engine: Updated location for data (#322)
Switched to gs://cloud-samples-data/vertex-ai/matching_engine/glove-100-angular.hdf5
2022-02-23 12:03:48 -05:00
281 changed files with 141729 additions and 27572 deletions
@@ -1 +1,2 @@
ratemate
google-cloud-aiplatform
+29 -25
View File
@@ -1,45 +1,49 @@
from typing import List
from ratemate import RateLimit
from resource_cleanup_manager import (
ResourceCleanupManager,
DatasetResourceCleanupManager,
EndpointResourceCleanupManager,
ModelResourceCleanupManager,
DatasetResourceCleanupManager,
ModelResourceCleanupManager,
EndpointResourceCleanupManager,
ResourceCleanupManager,
)
rate_limit = RateLimit(max_count=25, per=60, greedy=False)
def run_cleanup_managers(managers: List[ResourceCleanupManager], is_dry_run: bool):
for manager in managers:
type_name = manager.type_name
for manager in managers:
type_name = manager.type_name
print(f"Fetching {type_name}'s...")
resources = manager.list()
print(f"Found {len(resources)} {type_name}'s")
for resource in resources:
if not manager.is_deletable(resource):
continue
print(f"Fetching {type_name}'s...")
resources = manager.list()
print(f"Found {len(resources)} {type_name}'s")
for resource in resources:
try:
if not manager.is_deletable(resource):
continue
if is_dry_run:
resource_name = manager.resource_name(resource)
print(f"Will delete '{type_name}': {resource_name}")
else:
try:
manager.delete(resource)
except Exception as exception:
print(exception)
if is_dry_run:
resource_name = manager.resource_name(resource)
print(f"Will delete '{type_name}': {resource_name}")
else:
rate_limit.wait() # wait before deleting
manager.delete(resource)
except Exception as exception:
print(exception)
print("")
print("")
is_dry_run = False
if is_dry_run:
print("Starting cleanup in dry run mode...")
print("Starting cleanup in dry run mode...")
# List of all cleanup managers
managers = [
DatasetResourceCleanupManager(),
EndpointResourceCleanupManager(),
ModelResourceCleanupManager(),
DatasetResourceCleanupManager(),
EndpointResourceCleanupManager(),
ModelResourceCleanupManager(), # ModelResourceCleanupManager must follow EndpointResourceCleanupManager due to deployed models blocking model deletion.
]
run_cleanup_managers(managers=managers, is_dry_run=is_dry_run)
@@ -1,8 +1,9 @@
import abc
from typing import Any, Type
from google.cloud import aiplatform
from typing import Any
from proto.datetime_helpers import DatetimeWithNanoseconds
from google.cloud.aiplatform import base
from proto.datetime_helpers import DatetimeWithNanoseconds
# If a resource was updated within this number of seconds, do not delete.
RESOURCE_UPDATE_BUFFER_IN_SECONDS = 60 * 60 * 8
@@ -40,7 +41,7 @@ class ResourceCleanupManager(abc.ABC):
# Check that it wasn't created too recently, to prevent race conditions
if time_difference <= RESOURCE_UPDATE_BUFFER_IN_SECONDS:
print(
f"Skipping '{resource}' due update_time being '{time_difference}', which is less than '{RESOURCE_UPDATE_BUFFER_IN_SECONDS}'."
f"Skipping '{resource}' due to update_time being '{time_difference}', which is less than '{RESOURCE_UPDATE_BUFFER_IN_SECONDS}'."
)
return False
@@ -50,7 +51,7 @@ class ResourceCleanupManager(abc.ABC):
class VertexAIResourceCleanupManager(ResourceCleanupManager):
@property
@abc.abstractmethod
def vertex_ai_resource(self) -> base.VertexAiResourceNounWithFutureManager:
def vertex_ai_resource(self) -> Type[base.VertexAiResourceNounWithFutureManager]:
pass
@property
@@ -60,7 +61,9 @@ class VertexAIResourceCleanupManager(ResourceCleanupManager):
def list(self) -> Any:
return self.vertex_ai_resource.list()
def resource_name(self, resource: Any) -> str:
def resource_name(
self, resource: Type[base.VertexAiResourceNounWithFutureManager]
) -> str:
return resource.display_name
def delete(self, resource):
@@ -74,12 +77,33 @@ class VertexAIResourceCleanupManager(ResourceCleanupManager):
class DatasetResourceCleanupManager(VertexAIResourceCleanupManager):
vertex_ai_resource = aiplatform.datasets._Dataset
dataset_types = [
aiplatform.ImageDataset,
aiplatform.TabularDataset,
aiplatform.TextDataset,
aiplatform.TimeSeriesDataset,
aiplatform.VideoDataset,
]
def list(self) -> Any:
return [
dataset
for dataset_type in self.dataset_types
for dataset in dataset_type.list()
]
class EndpointResourceCleanupManager(VertexAIResourceCleanupManager):
vertex_ai_resource = aiplatform.Endpoint
def delete(self, resource):
# TODO: Remove this once https://github.com/googleapis/python-aiplatform/issues/1441 is fixed
resource._sync_gca_resource()
for deployed_model_id in [
models.id for models in resource._gca_resource.deployed_models
]:
resource._undeploy(deployed_model_id=deployed_model_id)
resource.delete(force=True)
+25 -2
View File
@@ -17,6 +17,7 @@
import argparse
import pathlib
import execute_changed_notebooks_helper
@@ -61,6 +62,18 @@ parser.add_argument(
help="The GCP region. This is used to inject a variable value into the notebook before running.",
required=True,
)
parser.add_argument(
"--variable_service_account",
type=str,
help="A service account. This is used to inject a variable value into the notebook before running. This is not the account that will run the notebook.",
required=True,
)
parser.add_argument(
"--variable_vpc_network",
type=str,
help="The full VPC network name. See https://cloud.google.com/compute/docs/networks-and-firewalls#networks. Format is projects/{project}/global/networks/{network}, where {project} is a project number, as in '12345', and {network} is network name. See <https://cloud.google.com/compute/docs/reference/rest/v1/networks/insert> for details. This is used to inject a variable value into the notebook before running.",
required=False,
)
parser.add_argument(
"--staging_bucket",
type=str,
@@ -73,6 +86,13 @@ parser.add_argument(
help="The GCP directory for storing executed notebooks.",
required=True,
)
parser.add_argument(
"--timeout",
type=int,
help="Timeout in seconds",
default=86400,
required=False,
)
parser.add_argument(
"--private_pool_id",
type=str,
@@ -100,8 +120,11 @@ execute_changed_notebooks_helper.process_and_execute_notebooks(
container_uri=args.container_uri,
staging_bucket=args.staging_bucket,
artifacts_bucket=args.artifacts_bucket,
should_parallelize=args.should_parallelize,
timeout=args.timeout,
variable_project_id=args.variable_project_id,
variable_region=args.variable_region,
private_pool_id=args.private_pool_id if not "default" else None,
should_parallelize=args.should_parallelize,
variable_service_account=args.variable_service_account,
variable_vpc_network=args.variable_vpc_network,
private_pool_id=args.private_pool_id,
)
+164 -54
View File
@@ -17,18 +17,24 @@ import concurrent
import dataclasses
import datetime
import functools
import git
import operator
import os
import pathlib
import nbformat
import re
import subprocess
from typing import List, Optional
from tabulate import tabulate
import operator
import execute_notebook_helper
import execute_notebook_remote
from utils import util, NotebookProcessors
import nbformat
from google.cloud.devtools.cloudbuild_v1.types import BuildOperationMetadata
from ratemate import RateLimit
from tabulate import tabulate
from utils import NotebookProcessors, util
# A buffer so that workers finish before the orchestrating job
WORKER_TIMEOUT_BUFFER_IN_SECONDS: int = 60 * 60
def format_timedelta(delta: datetime.timedelta) -> str:
@@ -62,11 +68,20 @@ class NotebookExecutionResult:
build_id: str
error_message: Optional[str]
@property
def output_uri_web(self) -> Optional[str]:
if self.output_uri.startswith("gs://"):
return f"https://storage.googleapis.com/{self.output_uri[5:]}"
else:
return None
def _process_notebook(
notebook_path: str,
variable_project_id: str,
variable_region: str,
variable_service_account: str,
variable_vpc_network: Optional[str],
):
# Read notebook
with open(notebook_path) as f:
@@ -78,6 +93,8 @@ def _process_notebook(
replacement_map={
"PROJECT_ID": variable_project_id,
"REGION": variable_region,
"SERVICE_ACCOUNT": variable_service_account,
"VPC_NETWORK": variable_vpc_network,
},
)
@@ -103,18 +120,33 @@ def _create_tag(filepath: str) -> str:
return tag
rate_limit = RateLimit(max_count=50, per=60, greedy=True)
def process_and_execute_notebook(
container_uri: str,
staging_bucket: str,
artifacts_bucket: str,
variable_project_id: str,
variable_region: str,
variable_service_account: str,
variable_vpc_network: Optional[str],
private_pool_id: Optional[str],
deadline: datetime.datetime,
notebook: str,
should_get_tail_logs: bool = False,
) -> NotebookExecutionResult:
rate_limit.wait() # wait before creating the task
print(f"Running notebook: {notebook}")
# Handle empty strings
if not variable_vpc_network:
variable_vpc_network = None
if not private_pool_id:
private_pool_id = None
# Create paths
notebook_output_uri = "/".join([artifacts_bucket, pathlib.Path(notebook).name])
@@ -140,19 +172,27 @@ def process_and_execute_notebook(
notebook_path=notebook,
variable_project_id=variable_project_id,
variable_region=variable_region,
variable_service_account=variable_service_account,
variable_vpc_network=variable_vpc_network,
)
# Upload the pre-processed code to a GCS bucket
code_archive_uri = util.archive_code_and_upload(staging_bucket=staging_bucket)
# Calculate timeout in seconds
timeout_in_seconds = max(
int((deadline - datetime.datetime.now()).total_seconds()), 1
)
operation = execute_notebook_remote.execute_notebook_remote(
code_archive_uri=code_archive_uri,
notebook_uri=notebook,
notebook_output_uri=notebook_output_uri,
container_uri=container_uri,
tag=tag,
region=variable_region,
private_pool_id=private_pool_id,
private_pool_region=variable_region,
timeout_in_seconds=timeout_in_seconds,
)
operation_metadata = BuildOperationMetadata(mapping=operation.metadata)
@@ -215,20 +255,40 @@ def get_changed_notebooks(
# Find notebooks
notebooks = []
# Instantiate GitPython objects
repo = git.Repo(os.getcwd())
index = repo.index
if base_branch:
print(f"Looking for notebooks that changed from branch: {base_branch}")
notebooks = subprocess.check_output(
["git", "diff", "--name-only", f"origin/{base_branch}..."] + test_paths
)
# Get the point at which this branch branches off from main
branching_commits = repo.merge_base("HEAD", f"origin/{base_branch}")
if len(branching_commits) > 0:
branching_commit = branching_commits[0]
print(f"Looking for notebooks that changed from branch: {branching_commit}")
notebooks = [
diff.b_path
for diff in index.diff(branching_commit, paths=test_paths)
if diff.b_path is not None
]
else:
notebooks = []
else:
print(f"Looking for all notebooks.")
notebooks = subprocess.check_output(["git", "ls-files"] + test_paths)
notebooks_str = subprocess.check_output(["git", "ls-files"] + test_paths)
notebooks = notebooks_str.decode("utf-8").split("\n")
notebooks = notebooks.decode("utf-8").split("\n")
notebooks = [notebook for notebook in notebooks if notebook.endswith(".ipynb")]
notebooks = [notebook for notebook in notebooks if len(notebook) > 0]
notebooks = [notebook for notebook in notebooks if pathlib.Path(notebook).exists()]
if len(notebooks) > 0:
print(f"Found {len(notebooks)} notebooks:")
for notebook in notebooks:
print(f"\t{notebook}")
return notebooks
@@ -237,10 +297,13 @@ def process_and_execute_notebooks(
container_uri: str,
staging_bucket: str,
artifacts_bucket: str,
should_parallelize: bool,
timeout: int,
variable_project_id: str,
variable_region: str,
private_pool_id: Optional[str],
should_parallelize: bool,
variable_service_account: str,
variable_vpc_network: Optional[str] = None,
private_pool_id: Optional[str] = None,
):
"""
Run the notebooks that exist under the folders defined in the test_paths_file.
@@ -267,17 +330,27 @@ def process_and_execute_notebooks(
Required. The value for REGION to inject into notebooks.
should_parallelize (bool):
Required. Should run notebooks in parallel using a thread pool as opposed to in sequence.
timeout (str):
Required. Timeout string according to https://cloud.google.com/build/docs/build-config-file-schema#timeout.
"""
notebook_execution_results: List[NotebookExecutionResult] = []
if len(notebooks) > 0:
# Calculate deadline
deadline = datetime.datetime.now() + datetime.timedelta(
seconds=max(timeout - WORKER_TIMEOUT_BUFFER_IN_SECONDS, 0)
)
if len(notebooks) > 1:
notebook_execution_results: List[NotebookExecutionResult] = []
print(f"Found {len(notebooks)} modified notebooks: {notebooks}")
if should_parallelize and len(notebooks) > 1:
print(
"Running notebooks in parallel, so no logs will be displayed. Please wait..."
)
with concurrent.futures.ThreadPoolExecutor(max_workers=None) as executor:
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
print(f"Max workers: {executor._max_workers}")
notebook_execution_results = list(
executor.map(
functools.partial(
@@ -287,7 +360,10 @@ def process_and_execute_notebooks(
artifacts_bucket,
variable_project_id,
variable_region,
variable_service_account,
variable_vpc_network,
private_pool_id,
deadline,
),
notebooks,
)
@@ -300,48 +376,82 @@ def process_and_execute_notebooks(
artifacts_bucket=artifacts_bucket,
variable_project_id=variable_project_id,
variable_region=variable_region,
variable_service_account=variable_service_account,
variable_vpc_network=variable_vpc_network,
private_pool_id=private_pool_id,
deadline=deadline,
notebook=notebook,
)
for notebook in notebooks
]
print("\n=== RESULTS ===\n")
results_sorted = sorted(
notebook_execution_results,
key=lambda result: result.is_pass,
reverse=True,
)
# Print results
print(
tabulate(
[
[
result.name,
"PASSED" if result.is_pass else "FAILED",
format_timedelta(result.duration),
result.log_url,
result.output_uri,
result.output_uri_web,
]
for result in results_sorted
],
headers=[
"build_tag",
"status",
"duration",
"log_url",
"output_uri",
"output_uri_web",
],
)
)
print("\n=== END RESULTS===\n")
total_notebook_duration = functools.reduce(
operator.add,
[datetime.timedelta(seconds=0)]
+ [result.duration for result in results_sorted],
)
print(
f"Cumulative notebook duration: {format_timedelta(total_notebook_duration)}"
)
# Raise error if any notebooks failed
if not all([result.is_pass for result in results_sorted]):
raise RuntimeError("Notebook failures detected. See logs for details")
elif len(notebooks) == 1:
notebook = notebooks[0]
# Pre-process notebook by substituting variable names
_process_notebook(
notebook_path=notebook,
variable_project_id=variable_project_id,
variable_region=variable_region,
variable_service_account=variable_service_account,
variable_vpc_network=variable_vpc_network,
)
execute_notebook_helper.execute_notebook(
notebook_source=notebook,
output_file_or_uri="/".join(
[artifacts_bucket, pathlib.Path(notebook).name]
),
should_log_output=True,
)
else:
print("No notebooks modified in this pull request.")
print("\n=== RESULTS ===\n")
results_sorted = sorted(
notebook_execution_results,
key=lambda result: result.is_pass,
reverse=True,
)
# Print results
print(
tabulate(
[
[
result.name,
"PASSED" if result.is_pass else "FAILED",
format_timedelta(result.duration),
result.log_url,
]
for result in results_sorted
],
headers=["build_tag", "status", "duration", "log_url"],
)
)
print("\n=== END RESULTS===\n")
total_notebook_duration = functools.reduce(
operator.add,
[datetime.timedelta(seconds=0)]
+ [result.duration for result in results_sorted],
)
print(f"Cumulative notebook duration: {format_timedelta(total_notebook_duration)}")
# Raise error if any notebooks failed
if not all([result.is_pass for result in results_sorted]):
raise RuntimeError("Notebook failures detected. See logs for details")
+1
View File
@@ -16,6 +16,7 @@
"""A CLI to download (optional) and run a single notebook locally"""
import argparse
import execute_notebook_helper
parser = argparse.ArgumentParser(description="Run a single notebook locally.")
+19 -8
View File
@@ -15,17 +15,20 @@
"""Methods to run a notebook locally"""
import sys
import os
import errno
import papermill as pm
import os
import shutil
import sys
from utils import util
import papermill as pm
from google.cloud.aiplatform import utils
from utils import util
# This script is used to execute a notebook and write out the output notebook.
# This is used to force papermill to use this kernel to run the notebook instead of any defined inside the notebook itself
DEFAULT_KERNEL_NAME = "python3"
def execute_notebook(
notebook_source: str,
@@ -50,6 +53,17 @@ def execute_notebook(
execution_exception = None
print("\n=== DOWNLOAD EXECUTED NOTEBOOK ===\n")
print(f"Please debug the executed notebook by downloading the executed notebook:")
print("Option 1. Using gsutil. Run the following command in your terminal.")
print(f'\tgsutil cp "{output_file_or_uri}" .')
print("Option 2. Using this link.")
print(f"\thttps://storage.googleapis.com/{output_file_or_uri[5:]}")
print("\n======\n")
# Execute notebook
try:
# Execute notebook
@@ -58,6 +72,7 @@ def execute_notebook(
output_path=notebook_source,
progress_bar=should_log_output,
request_save_on_cell_execute=should_log_output,
kernel_name=DEFAULT_KERNEL_NAME,
log_output=should_log_output,
stdout_file=sys.stdout if should_log_output else None,
stderr_file=sys.stderr if should_log_output else None,
@@ -71,10 +86,6 @@ def execute_notebook(
util.upload_file(notebook_source, remote_file_path=output_file_or_uri)
print("\n=== EXECUTION FINISHED ===\n")
print(
f"Please debug the executed notebook by downloading: {output_file_or_uri}"
)
print("\n======\n")
else:
# Create directories if they don't exist
if not os.path.exists(os.path.dirname(output_file_or_uri)):
+18 -19
View File
@@ -16,22 +16,18 @@
"""Methods to run a notebook on Google Cloud Build"""
from re import sub
from typing import Optional
import google.auth
import yaml
from google.api_core import client_options, operation
from google.cloud.aiplatform import utils
from google.cloud.devtools import cloudbuild_v1
from google.cloud.devtools.cloudbuild_v1.types import Source, StorageSource
from google.protobuf import duration_pb2
from yaml.loader import FullLoader
import google.auth
from google.cloud.devtools import cloudbuild_v1
from google.cloud.devtools.cloudbuild_v1.types import Source, StorageSource
from typing import Optional
import yaml
from google.cloud.aiplatform import utils
from google.api_core import operation, client_options
CLOUD_BUILD_FILEPATH = ".cloud-build/notebook-execution-test-cloudbuild-single.yaml"
TIMEOUT_IN_SECONDS = 86400
SERVICE_BASE_PATH = "cloudbuild.googleapis.com"
@@ -40,12 +36,14 @@ def execute_notebook_remote(
notebook_uri: str,
notebook_output_uri: str,
container_uri: str,
region: str,
private_pool_id: Optional[str],
private_pool_region: Optional[str],
tag: Optional[str],
timeout_in_seconds: Optional[int] = None,
) -> operation.Operation:
"""Create and execute a single notebook on Google Cloud Build"""
# Load build steps from YAML
cloudbuild_config = yaml.load(open(CLOUD_BUILD_FILEPATH), Loader=FullLoader)
substitutions = {
@@ -57,13 +55,14 @@ def execute_notebook_remote(
build = cloudbuild_v1.Build()
options: Optional[client_options.ClientOptions] = None
if private_pool_id:
substitutions["_PRIVATE_POOL_NAME"] = private_pool_id
build.options = cloudbuild_config["options"]
if private_pool_id and private_pool_region:
# substitutions["_PRIVATE_POOL_NAME"] = private_pool_id
build.options = cloudbuild_config.get("options")
build.options.pool = {"name": private_pool_id}
# Switch to the regional endpoint of the pool
options = client_options.ClientOptions(
api_endpoint=f"{region}-{SERVICE_BASE_PATH}"
api_endpoint=f"{private_pool_region}-{SERVICE_BASE_PATH}"
)
# Authorize the client with Google defaults
@@ -85,8 +84,8 @@ def execute_notebook_remote(
build.steps = cloudbuild_config["steps"]
build.substitutions = substitutions
build.timeout = duration_pb2.Duration(seconds=TIMEOUT_IN_SECONDS)
build.queue_ttl = duration_pb2.Duration(seconds=TIMEOUT_IN_SECONDS)
build.timeout = duration_pb2.Duration(seconds=timeout_in_seconds)
build.queue_ttl = duration_pb2.Duration(seconds=timeout_in_seconds)
if tag:
build.tags = [tag]
@@ -4,28 +4,35 @@ steps:
entrypoint: /bin/sh
args:
- -c
- 'gcloud config list'
- 'gcloud config list --quiet'
# Check the Python version
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- 'python3 .cloud-build/CheckPythonVersion.py'
- python3 .cloud-build/CheckPythonVersion.py -q
# Create a virtual environment
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- python3 -m venv workspace/env
# Install Python dependencies
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- 'python3 -m pip install -U pip && python3 -m pip install -U --user -r .cloud-build/requirements.txt'
- . workspace/env/bin/activate &&
python3 -m pip -q install -U pip &&
python3 -m pip -q install -U -r .cloud-build/requirements.txt
# Install Python dependencies and run testing script
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- 'python3 -m pip install -U pip && python3 -m pip freeze && python3 .cloud-build/execute_notebook_cli.py --notebook_source "${_NOTEBOOK_GCS_URI}" --output_file_or_uri "${_NOTEBOOK_OUTPUT_GCS_URI}"'
- |
. workspace/env/bin/activate &&
python3 .cloud-build/execute_notebook_cli.py --notebook_source "${_NOTEBOOK_GCS_URI}" --output_file_or_uri "${_NOTEBOOK_OUTPUT_GCS_URI}"
env:
- 'IS_TESTING=1'
timeout: 86400s
options:
pool:
name: ${_PRIVATE_POOL_NAME}
@@ -4,35 +4,42 @@ steps:
entrypoint: /bin/sh
args:
- -c
- 'gcloud config list'
- gcloud config list --quiet
# Check the Python version
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- 'python3 .cloud-build/CheckPythonVersion.py'
# Fetch base branch if required
- python3 .cloud-build/CheckPythonVersion.py -q
# Fetch full repo for diff purposes
- name: gcr.io/cloud-builders/git
args: [fetch, --unshallow, --quiet]
# Create a virtual environment
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- 'if [ -n "${_BASE_BRANCH}" ]; then git fetch origin "${_BASE_BRANCH}":refs/remotes/origin/"${_BASE_BRANCH}"; else echo "Skipping fetch."; fi'
- python3 -m venv workspace/env
# Install Python dependencies
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- 'python3 -m pip install -U pip && python3 -m pip install -U --user -r .cloud-build/requirements.txt'
- . workspace/env/bin/activate &&
python3 -m pip -q install -U pip &&
python3 -m pip -q install -U -r .cloud-build/requirements.txt
# Install Python dependencies and run testing script
# TODO: Only pass in private_pool_id if it is set
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- 'python3 -m pip install -U pip && python3 -m pip freeze && python3 .cloud-build/execute_changed_notebooks_cli.py --test_paths_file "${_TEST_PATHS_FILE}" --base_branch "${_FORCED_BASE_BRANCH}" --container_uri ${_PYTHON_IMAGE} --staging_bucket ${_GCS_STAGING_BUCKET} --artifacts_bucket ${_GCS_STAGING_BUCKET}/executed_notebooks/PR_${_PR_NUMBER}/BUILD_${BUILD_ID} --variable_project_id ${PROJECT_ID} --variable_region ${_GCP_REGION} `if [ ! -z "${_PRIVATE_POOL_NAME}" ]; then echo "--private_pool_id ${_PRIVATE_POOL_NAME}"; fi`'
- |
. workspace/env/bin/activate &&
python3 .cloud-build/execute_changed_notebooks_cli.py --test_paths_file "${_TEST_PATHS_FILE}" --base_branch "${_FORCED_BASE_BRANCH}" --container_uri ${_PYTHON_IMAGE} --staging_bucket ${_GCS_STAGING_BUCKET} --artifacts_bucket ${_GCS_STAGING_BUCKET}/executed_notebooks/PR_${_PR_NUMBER}/BUILD_${BUILD_ID} --variable_project_id ${PROJECT_ID} --variable_region ${_GCP_REGION} --variable_service_account ${_GCP_SERVICE_ACCOUNT} --variable_vpc_network "${_GPC_VPC_NETWORK_NAME}" `if [ ! -z "${_PRIVATE_POOL_NAME}" ]; then echo "--private_pool_id ${_PRIVATE_POOL_NAME}"; fi`
env:
- 'IS_TESTING=1'
timeout: 86400s
options:
pool:
name: ${_PRIVATE_POOL_NAME}
name: ${_PRIVATE_POOL_NAME}
+2 -1
View File
@@ -9,4 +9,5 @@ tabulate
google-cloud-aiplatform
google-cloud-storage
google-cloud-build
gcloud
ratemate
GitPython
+1 -1
View File
@@ -1,5 +1,5 @@
notebooks/official/vizier/gapic-vizier-multi-objective-optimization.ipynb
notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb
notebooks/official/matching_engine/intro-swivel.ipynb
notebooks/official/ml_metadata/sdk-metric-parameter-tracking-for-locally-trained-models.ipynb
notebooks/official/pipelines/metrics_viz_run_compare_kfp.ipynb
notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb
+1
View File
@@ -0,0 +1 @@
notebooks/official/pipelines/metrics_viz_run_compare_kfp.ipynb
+4 -2
View File
@@ -13,8 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from nbconvert.preprocessors import Preprocessor
from typing import Dict
from nbconvert.preprocessors import Preprocessor
from . import UpdateNotebookVariables as update_notebook_variables
@@ -60,4 +62,4 @@ class UpdateVariablesPreprocessor(Preprocessor):
executable_cells.append(cell)
notebook.cells = executable_cells
return notebook, resources
return notebook, resources
+26 -3
View File
@@ -35,8 +35,8 @@ Variables in conditionals can also be replaced:
def get_updated_value(content: str, variable_name: str, variable_value: str) -> str:
return re.sub(
rf"({variable_name}.*?=.*?[\",\'])\[.+?\]([\",\'].*?)",
rf"\1{variable_value}\2",
rf"({variable_name}.*? = .*?[\",\'])\[.+?\]([\",\'].*?)",
rf"\g<1>{variable_value}\g<2>",
content,
flags=re.M,
)
@@ -78,4 +78,27 @@ def test_region():
variable_name="REGION",
variable_value="us-central1",
)
assert new_content == 'REGION = "us-central1" # @param {type:"string"}'
assert new_content == 'REGION = "us-central1" # @param {type:"string"}'
def test_region_equal_equals_ignore():
# Tests that == is ignored
new_content = get_updated_value(
content='REGION == "[your-region]" # @param {type:"string"}',
variable_name="REGION",
variable_value="us-central1",
)
assert new_content == 'REGION == "[your-region]" # @param {type:"string"}'
def test_service_account():
# Tests that == is ignored
new_content = get_updated_value(
content='SERVICE_ACCOUNT = "[your-service-account]" # @param {type:"string"}',
variable_name="SERVICE_ACCOUNT",
variable_value="12345-compute@developer.gserviceaccount.com",
)
assert (
new_content
== 'SERVICE_ACCOUNT = "12345-compute@developer.gserviceaccount.com" # @param {type:"string"}'
)
+7 -7
View File
@@ -1,13 +1,13 @@
from datetime import datetime
from typing import Optional
from google.cloud import storage
from google.cloud.aiplatform import utils
from google.auth import credentials as auth_credentials
import os
import subprocess
import tarfile
import uuid
from datetime import datetime
from typing import Optional
from google.auth import credentials as auth_credentials
from google.cloud import storage
from google.cloud.aiplatform import utils
def download_file(bucket_name: str, blob_name: str, destination_file: str) -> str:
@@ -57,4 +57,4 @@ def archive_code_and_upload(staging_bucket: str):
print(f"Uploaded source code archive to {source_archived_file_gcs}")
return source_archived_file_gcs
return source_archived_file_gcs
+19 -9
View File
@@ -1,18 +1,28 @@
If you are opening a PR for `Official Notebooks` under the [notebooks/official](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/official) folder, follow this mandatory checklist:
**REQUIRED:** Add a summary of your PR here, typically including why the change is needed and what was changed. Include any design alternatives for discussion purposes.
<br>
--- YOUR PR SUMMARY GOES HERE ---
<br><br><br>
**REQUIRED:** Fill out the below checklists or remove if irrelevant
1. If you are opening a PR for `Official Notebooks` under the [notebooks/official](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/official) folder, follow this mandatory checklist:
- [ ] Use the [notebook template](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/notebook_template.ipynb) as a starting point.
- [ ] Follow the style and grammar rules outlined in the above notebook template.
- [ ] Verify the notebook runs successfully in Colab since the automated tests cannot guarantee this even when it passes.
- [ ] Passes all the required automated checks. You can locally test for formatting and linting with these [instructions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/docs/contributing.md#code-quality-checks).
- [ ] Passes all the required automated checks. You can locally test for formatting and linting with these [instructions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/CONTRIBUTING.md#code-quality-checks).
- [ ] You have consulted with a tech writer to see if tech writer review is necessary. If so, the notebook has been reviewed by a tech writer, and they have approved it.
- [ ] This notebook has been added to the [CODEOWNERS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/docs/CODEOWNERS) file under `# Official Notebooks` section, pointing to the author or the author's team.
- [ ] This notebook has been added to the [CODEOWNERS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/official/CODEOWNERS) file under the `Official Notebooks` section, pointing to the author or the author's team.
- [ ] The Jupyter notebook cleans up any artifacts it has created (datasets, ML models, endpoints, etc) so as not to eat up unnecessary resources.
<br>
If you are opening a PR for `Community Notebooks` under the [notebooks/community](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/community) folder:
- [ ] This notebook has been added to the [CODEOWNERS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/docs/CODEOWNERS) file under the `# Community Notebooks` section, pointing to the author or the author's team.
- [ ] Passes all the required formatting and linting checks. You can locally test with these [instructions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/docs/contributing.md#code-quality-checks).
2. If you are opening a PR for `Community Notebooks` under the [notebooks/community](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/community) folder:
- [ ] This notebook has been added to the [CODEOWNERS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/CODEOWNERS) file under the `Community Notebooks` section, pointing to the author or the author's team.
- [ ] Passes all the required formatting and linting checks. You can locally test with these [instructions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/CONTRIBUTING.md#code-quality-checks).
If you are opening a PR for `Community Content` under the [community-content](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/community-content) folder:
<br>
3. If you are opening a PR for `Community Content` under the [community-content](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/community-content) folder:
- [ ] Make sure your main `Content Directory Name` is descriptive, informative, and includes some of the key products and attributes of your content, so that it is differentiable from other content
- [ ] The main content directory has been added to the [CODEOWNERS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/docs/CODEOWNERS) file under the `# Community Content` section, pointing to the author or the author's team.
- [ ] Passes all the required formatting and linting checks. You can locally test with these [instructions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/docs/contributing.md#code-quality-checks).
- [ ] The main content directory has been added to the [CODEOWNERS](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/community-content/CODEOWNERS) file under the `Community Content` section, pointing to the author or the author's team.
- [ ] Passes all the required formatting and linting checks. You can locally test with these [instructions](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/CONTRIBUTING.md#code-quality-checks).
+4 -2
View File
@@ -7,9 +7,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Fetch pull request branch
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch base main branch
+4 -3
View File
@@ -2,8 +2,9 @@ git+https://github.com/tensorflow/docs
ipython
jupyter
nbconvert
black==22.1.0
pyupgrade==2.31.0
black==22.6.0
pyupgrade==2.34.0
isort==5.10.1
flake8==4.0.1
nbqa==1.2.3
nbqa==1.4.0
+2 -2
View File
@@ -68,7 +68,7 @@ if [ ${#notebooks[@]} -gt 0 ]; then
if [ "$is_test" = true ]; then
echo "Running nbfmt..."
python3 -m tensorflow_docs.tools.nbfmt --remove_outputs --test "$notebook"
python3 -m tensorflow_docs.tools.nbfmt --test "$notebook"
NBFMT_RTN=$?
# echo "Running black..."
# python3 -m nbqa black "$notebook" --check
@@ -93,7 +93,7 @@ if [ ${#notebooks[@]} -gt 0 ]; then
python3 -m nbqa isort "$notebook"
ISORT_RTN=$?
echo "Running nbfmt..."
python3 -m tensorflow_docs.tools.nbfmt --remove_outputs "$notebook"
python3 -m tensorflow_docs.tools.nbfmt "$notebook"
NBFMT_RTN=$?
echo "Running flake8..."
python3 -m nbqa flake8 "$notebook" --show-source --extend-ignore=W391,E501,F821,E402,F404,W503,E203,E722,W293,W291
+1 -1
View File
@@ -48,8 +48,8 @@ then you will need to manually address them before submitting your PR.
nbqa black "$notebook"
nbqa pyupgrade "$notebook"
nbqa isort "$notebook"
python3 -m tensorflow_docs.tools.nbfmt --remove_outputs "$notebook"
nbqa flake8 "$notebook" --extend-ignore=W391,E501,F821,E402,F404,W503,E203,E722,W293,W291
python3 -m tensorflow_docs.tools.nbfmt --remove_outputs "$notebook"
```
## Code Reviews
+13 -1
View File
@@ -6,7 +6,19 @@ Welcome to the Google Cloud [Vertex AI](https://cloud.google.com/vertex-ai/docs/
## Overview
The repository contains [Notebooks](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/master/notebooks) and [Community Content](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/master/community-content) that demonstrate how to develop and manage ML workflows using Google Cloud Vertex AI.
The repository contains [notebooks](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/master/notebooks) and [community content](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/master/community-content) that demonstrate how to develop and manage ML workflows using Google Cloud Vertex AI.
## Repository structure
```bash
├── community-content - Sample code and tutorials contributed by the community
├── notebooks
│ ├── community - Notebooks contributed by the community
│ ├── official - Notebooks demonstrating use of each Vertex AI service
│ │ ├── automl
│ │ ├── custom
│ │ ├── ...
```
## Contributing
+2
View File
@@ -3,3 +3,5 @@
/pytorch_text_classification_using_vertex_sdk_and_gcloud @RajeshThallam
/pytorch_text_classification_using_vertex_sdk_and_gcloud @RajeshThallam @ultrons
/sklearn_text_classification_from_script_using_vertex_sdk @maxhardt
/pluto_on_workbench @wkharold
/cpr-examples @samthrasher
@@ -0,0 +1,5 @@
testdata/*
build.py
test.py
state_dict.pth
config.json
@@ -0,0 +1,5 @@
cpr_model_server.py
entrypoint.py
state_dict.pth
config.json
**/__pycache__
@@ -0,0 +1,93 @@
# CPR Example: PyTorch Image Models (timm)
## About CPR
CPR ([custom prediction routines](https://github.com/googleapis/python-aiplatform/blob/custom-prediction-routine/google/cloud/aiplatform/prediction/README.md)) is a framework designed by Google Cloud developers to make it easier to combine machine learning models with custom preprocessing and postprocessing logic in a real-time serving application.
## Using this example
This code is a self-contained example of a custom model server project built using CPR.
As is, you can use it to serve the ViT-Small image classification model from Ross Wightman's [`timm`](https://github.com/rwightman/pytorch-image-models) library of image model implementations in PyTorch. Both CPU and GPU are supported.
You can also consider using the code here as a template for your own CPR project if you want to use a different model from `timm`, a different PyTorch model, or an entirely different framework.
### Requirements
In order to use this example, you'll need Docker and Python 3 installed on your system.
To get started, first create a virtual environment in an empty directory:
```sh
mkdir cpr-example
python3 -m venv cpr-example
cd cpr-example && source bin/activate
```
Then, clone the [vertex-ai-samples repo](https://github.com/GoogleCloudPlatform/vertex-ai-samples) in that directory:
```sh
git clone https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
cd vertex-ai-samples/community-content/cpr-examples/timm_serving
```
Finally, install the Python modules required to build and run the model server:
```sh
pip install -r requirements.txt
```
### Predictor
The `TimmPredictor` class in `timm_serving/predictor.py` implements most of the important logic for the server.
- `load(artifacts_dir)`: The predictor's `load` method is called when the server starts up in order to set up the predictor, usually by loading model weights and any artifacts needed for preprocessing and postprocessing. In this example, we initialize the saved model from the `state_dict.pth` file located inside the `artifacts_dir` folder and create the preprocessing transform from the model config.
- `preprocess`, `predict`, `postprocess`: These methods are applied in sequence to the deserialized JSON data from each request.
- `preprocess` decodes images from base64 and apply cropping, scaling and normalizing transforms.
- `predict` runs the ViT-Small model on the preprocessed images and returns class scores.
- `postprocess` finds the top five classes and packs the class names, probabilities, and indices in a serializable result.
### Building the container
To build the model server locally, run the build command:
```sh
python build.py build
```
You can edit configuration values such as the model server's base image, the name and tag assigned to the image, and the path where model weights are stored locally.
When you run the build command, model weights are downloaded and the model server container is built.
### Running local tests
`test.py` contains a suite of unit tests for the predictor as well as end-to-end tests for the model server.
To run the tests:
```sh
python test.py
```
All of the test images are public domain.
- [Cat](https://commons.wikimedia.org/wiki/File:Stray_cat_on_wall.jpg)
- [Airplane](https://commons.wikimedia.org/wiki/File:Airplanes_jets.jpg)
- The infamous [mandrill](https://commons.wikimedia.org/wiki/File:Wikipedia-sipi-image-db-mandrill-4.2.03.png)
### Deploying to Vertex AI
Before uploading or deploying the container, you'll need to modify `config.py` to set appropriate values for:
- `project_id`: Your GCP project id.
- `region`: Region where the model will be uploaded and deployed.
- `repository`: [Artifact Registry repository](https://cloud.google.com/artifact-registry/docs/repositories/create-repos) in your project where the container image will be uploaded.
- `artifacts_gcs_dir`: Folder in a [Google Cloud Storage bucket](https://cloud.google.com/storage/docs/creating-buckets) where the model weights will be uploaded.
Once this is done, first upload the model:
```sh
python build.py upload
```
Then deploy it:
```sh
python build.py deploy
```
If you run the deploy command again, it will create a new endpoint. If you want to undeploy the model, you can do so using the Vertex AI dashboard on the Google Cloud console, or use `gcloud ai endpoints undeploy` from the command line.
After deploying successfully, you can run `python build.py probe` to send a sample request to the deployed model.
@@ -0,0 +1,117 @@
# Copyright 2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Build the model server container."""
import json
import logging
import os
import pathlib
from typing import Sequence
from absl import app
from absl import logging
from config import CPRConfig
from google.cloud import aiplatform
from google.cloud.aiplatform import prediction as cpr
import smart_open
import timm
from timm_serving import predictor
import torch
def build_container(config: CPRConfig, tag: str) -> cpr.LocalModel:
"""Build the model server container.
Args:
tag: Output image tag.
Returns:
LocalModel exposing the built model server.
"""
return cpr.LocalModel.build_cpr_model(
src_dir=os.path.join(os.getcwd()),
output_image_uri=tag,
base_image=config.base_image,
predictor=predictor.TimmPredictor,
requirements_path=os.path.join(os.getcwd(), "requirements.txt"),
)
def save_model_artifact(destination: str) -> None:
"""Save a copy of the model state dict."""
model = timm.create_model(predictor.TimmPredictor.TIMM_MODEL_NAME, pretrained=True)
dest_file = os.path.join(destination, predictor.TimmPredictor.WEIGHTS_FILE)
with smart_open.open(dest_file, "wb") as f:
torch.save(model, f)
logging.info("Saved model to %s", dest_file)
logging.info("%s parameters", sum(p.numel() for p in model.parameters()))
def upload_model(config: CPRConfig) -> aiplatform.Model:
"""Tag and upload the model server."""
ar_tag = (
f"{config.region}-docker.pkg.dev/{config.project_id}"
f"/{config.repository}/{config.image}"
)
local_model = build_container(config, tag=ar_tag)
aiplatform.init(project=config.project_id, location=config.region)
local_model.push_image()
aip_model = aiplatform.Model.upload(
local_model=local_model,
display_name=predictor.TimmPredictor.TIMM_MODEL_NAME,
artifact_uri=config.artifact_gcs_dir,
)
config.model_name = aip_model.resource_name
config.save()
return aip_model
def deploy_model(config: CPRConfig) -> aiplatform.Endpoint:
"""Deploy the model server to a Vertex Prediction endpoint."""
aiplatform.init(project=config.project_id, location=config.region)
aip_model = aiplatform.Model(model_name=config.model_name)
endpoint = aip_model.deploy(machine_type=config.machine_type)
config.endpoint_name = endpoint.resource_name
config.save()
return endpoint
def probe_prediction(config: CPRConfig, request_path: str) -> None:
"""Send a sample prediction request to the Vertex Prediction endpoint."""
aiplatform.init(project=config.project_id, location=config.region)
aip_endpoint = aiplatform.Endpoint(endpoint_name=config.endpoint_name)
with open(request_path) as f:
logging.info(aip_endpoint.predict(**json.load(f)))
def main(argv: Sequence[str]):
config = CPRConfig()
if pathlib.Path(config.config_file).exists():
config.load()
actions = set(argv[1:])
if "build" in actions:
build_container(config, config.image)
save_model_artifact(config.artifact_local_dir)
if "upload" in actions:
save_model_artifact(config.artifact_gcs_dir)
upload_model(config)
if "deploy" in actions:
deploy_model(config)
if "probe" in actions:
probe_prediction(config, request_path="sample_request.json")
if __name__ == "__main__":
app.run(main)
@@ -0,0 +1,76 @@
# Copyright 2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import dataclasses
import json
@dataclasses.dataclass
class CPRConfig(object):
"""Configure the build process by editing the default values here.
config_file: File path used to save values in this config. (Some
values, such as the model name, are generated at build time and
depended on by future steps, so saving it allows this script to
deploy the model without re-uploading it, for example.)
base_image: Base Docker image on top of which the model server will
be built. By default, a Debian-based Python 3 image without GPU
support will be used.
image: Name and tag assigned to the built model server image.
artifact_local_dir: Local directory where a copy of the pretrained model weights
will be saved.
region: Google Cloud Region where the model will be uploaded during the
build process.
project_id: Google Cloud project ID.
repository: Name of the Artifact Registry repository where the container
will be uploaded.
artifact_gcs_dir: Location on GCS where a copy of the pretrained model
weights will be uploaded.
model_name: Full resource path of the uploaded model. This is a write-only
field, the value is generated by Vertex AI when the model is uploaded.
endpoint_name: Full resource path of the created endpoint. This is a
write-only field, the value is generated by Vertex AI when the model is
deployed to an endpoint.
machine_type: Machine type to use when deploying the model.
"""
config_file: str = "config.json"
base_image: str = "python:3.10-bullseye"
image: str = "timm_predictor:latest"
artifact_local_dir: str = ""
region: str = "us-central1"
project_id: str = "samthrasher-experimental"
repository: str = "cpr-images"
artifact_gcs_dir: str = "gs://samthrasher-cpr-example/timm-vit224/"
model_name: str = ""
endpoint_name: str = ""
machine_type: str = "n1-standard-2"
def save(self):
with open(self.config_file, "w") as f:
json.dump(dataclasses.asdict(self), f, indent=2)
def load(self):
with open(self.config_file) as f:
self.__init__(**json.load(f))
@@ -0,0 +1,8 @@
absl-py==1.1.0
fastapi==0.75.2
uvicorn==0.18.2
timm==0.5.4
smart_open==6.0.0
google-cloud-storage>=1.26.0,<2.0.0dev
google-cloud-aiplatform[prediction] @ git+https://github.com/googleapis/python-aiplatform.git@custom-prediction-routine
File diff suppressed because one or more lines are too long
@@ -0,0 +1,249 @@
"""Test the timm_serving predictor."""
import base64
import json
import logging
import os
import pickle
from typing import List, Dict
from absl import flags
from absl import logging
from absl.testing import absltest
from config import CPRConfig
import fastapi
from google.cloud import aiplatform
from google.cloud.aiplatform import prediction as cpr
import PIL
from timm_serving import predictor
import torch
VIT_SMALL_PARAMS = 22878952
def b64_encode_file(path: str) -> str:
"""Encode a file's contents as base64.
Args:
path: Path to the file.
Returns:
Base64-encoded contents of the file.
"""
with open(path, "rb") as f:
return str(base64.b64encode(f.read()), encoding="utf-8")
def make_instance_dict(
image_paths: List[str], base64_encodings: List[str]
) -> Dict[str, List[str]]:
"""Generate a dictionary similar to a parsed prediction server request.
Args:
image_paths: Paths to image files to include.
base64_encodings: Pre-encoded base64 strings.
Returns:
Dictionary of instances in the format accepted by the preprocessor.
"""
instances = [s for s in base64_encodings]
for path in image_paths:
instances.append(b64_encode_file(path))
return {"instances": instances}
def count_parameters(model: torch.nn.Module):
"""Count the parameters in a Pytorch model.
Args:
model: Pytorch model (nn.Module).
Returns:
Number of parameters in the model.
"""
return sum(p.numel() for p in model.parameters())
class PredictorUnitTests(absltest.TestCase):
"""Unit tests for timm_serving.predictor."""
def setUp(self):
super().setUp()
self.config = CPRConfig()
self.config.load()
self.predictor = predictor.TimmPredictor()
def test_load_from_saved_state_dict_ok(self):
self.predictor.load(self.config.artifact_local_dir)
self.assertEqual(count_parameters(self.predictor._model), VIT_SMALL_PARAMS)
def test_load_bad_path(self):
with self.assertRaises(FileNotFoundError):
self.predictor.load("testdata/")
with self.assertRaisesRegex(ValueError, "not a directory"):
self.predictor.load("blah")
def test_load_bad_data(self):
with self.assertRaises(pickle.UnpicklingError):
self.predictor.load("testdata/bad_model_1")
with self.assertRaisesRegex(RuntimeError, "Invalid magic number"):
self.predictor.load("testdata/bad_model_2")
def test_preprocess_ok(self):
self.predictor.load(self.config.artifact_local_dir)
instance_dict = make_instance_dict(
base64_encodings=[],
image_paths=[
"testdata/airplane.jpg",
"testdata/mandrill.tiff",
"testdata/mandrill.tiff",
"testdata/cat_alpha.png",
],
)
result = self.predictor.preprocess(instance_dict)
self.assertEqual(result.size(), torch.Size([4, 3, 224, 224]))
self.assertEqual(result.dtype, torch.float32)
def test_preprocess_no_instances(self):
self.predictor.load(self.config.artifact_local_dir)
with self.assertRaises(fastapi.HTTPException) as ctx:
self.predictor.preprocess({})
self.assertEqual(ctx.exception.status_code, 400)
self.assertRegex(ctx.exception.detail, 'must contain "instances"')
def test_preprocess_wrong_shape_instances(self):
self.predictor.load(self.config.artifact_local_dir)
instance_dict = {"instances": [[b64_encode_file("testdata/mandrill.tiff")]]}
with self.assertRaises(fastapi.HTTPException) as ctx:
self.predictor.preprocess(instance_dict)
self.assertEqual(ctx.exception.status_code, 400)
self.assertRegex(ctx.exception.detail, "not 'list'")
def test_preprocess_bad_base64(self):
self.predictor.load(self.config.artifact_local_dir)
instance_dict = make_instance_dict(base64_encodings=["!@#$"], image_paths=[])
with self.assertRaises(fastapi.HTTPException) as ctx:
self.predictor.preprocess(instance_dict)
self.assertEqual(ctx.exception.status_code, 400)
self.assertRegex(ctx.exception.detail, "[Bb]ase64")
def test_preprocess_not_image_data(self):
self.predictor.load(self.config.artifact_local_dir)
instance_dict = make_instance_dict(
base64_encodings=[], image_paths=["testdata/bad.jpg"]
)
with self.assertRaises(fastapi.HTTPException) as ctx:
self.predictor.preprocess(instance_dict)
self.assertEqual(ctx.exception.status_code, 400)
self.assertRegex(ctx.exception.detail, "image file")
def test_predict_ok(self):
self.predictor.load(self.config.artifact_local_dir)
inputs = torch.zeros(size=[2, 3, 224, 224], dtype=torch.float32)
if torch.cuda.device_count() > 0:
inputs = inputs.cuda()
result = self.predictor.predict(inputs)
self.assertEqual(result.size(), torch.Size([2, 1000]))
self.assertEqual(result.dtype, torch.float32)
def test_postprocess_ok(self):
class_probs = torch.zeros(size=[2, 1000])
class_probs[0, 0] = 1
class_probs[1, 123] = 1
result = self.predictor.postprocess(class_probs)
predictions = result["predictions"]
self.assertLen(predictions[0]["class_names"], 5)
self.assertLen(predictions[0]["indices"], 5)
self.assertLen(predictions[0]["probabilities"], 5)
self.assertLen(predictions[1]["class_names"], 5)
self.assertLen(predictions[1]["indices"], 5)
self.assertLen(predictions[1]["probabilities"], 5)
self.assertContainsSubsequence(predictions[0]["class_names"][0], "tench")
self.assertContainsSubsequence(
predictions[1]["class_names"][0], "spiny lobster"
)
class ServerEndToEndTests(absltest.TestCase):
"""End-to-end tests for the model server, using LocalEndpoint."""
def setUp(self):
super().setUp()
self.config = CPRConfig()
self.config.load()
self.local_model = cpr.LocalModel(
serving_container_spec=aiplatform.gapic.ModelContainerSpec(
image_uri=self.config.image
)
)
self.local_endpoint = self.local_model.deploy_to_local_endpoint(
artifact_uri=self.config.artifact_local_dir or os.getcwd()
)
self.local_endpoint.serve()
def tearDown(self):
self.local_endpoint.stop()
super().tearDown()
def test_e2e_healthcheck_ok(self):
health_check_response = self.local_endpoint.run_health_check()
self.assertEqual(health_check_response.status_code, 200)
self.assertEqual(health_check_response.content, b"{}")
def test_e2e_predict_ok(self):
predict_request = json.dumps(
make_instance_dict(
base64_encodings=[],
image_paths=[
"testdata/mandrill.tiff",
],
)
)
response = self.local_endpoint.predict(
request=predict_request, headers={"Content-Type": "application/json"}
)
logging.info(response.content)
self.assertEqual(response.status_code, 200)
predictions = response.json()["predictions"]
self.assertContainsSubsequence(predictions[0]["class_names"][0], "baboon")
def test_e2e_predict_bad_json_returns_400(self):
predict_request = "blah"
response = self.local_endpoint.predict(
request=predict_request, headers={"Content-Type": "application/json"}
)
logging.info(response.content)
self.assertEqual(response.status_code, 400)
def test_e2e_predict_no_instances_returns_400(self):
predict_request = json.dumps({})
response = self.local_endpoint.predict(
request=predict_request, headers={"Content-Type": "application/json"}
)
logging.info(response.content)
self.assertEqual(response.status_code, 400)
def test_e2e_predict_bad_base64_returns_400(self):
predict_request = json.dumps(
make_instance_dict(base64_encodings=["blah"], image_paths=[])
)
response = self.local_endpoint.predict(
request=predict_request, headers={"Content-Type": "application/json"}
)
logging.info(response.content)
self.assertEqual(response.status_code, 400)
def test_e2e_predict_bad_image_returns_400(self):
predict_request = json.dumps(
make_instance_dict(base64_encodings=[], image_paths=["testdata/bad.jpg"])
)
response = self.local_endpoint.predict(
request=predict_request, headers={"Content-Type": "application/json"}
)
logging.info(response.content)
self.assertEqual(response.status_code, 400)
if __name__ == "__main__":
absltest.main()
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

@@ -0,0 +1 @@
some non-image data
@@ -0,0 +1 @@
some non-image data
Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

File diff suppressed because it is too large Load Diff
@@ -0,0 +1,178 @@
# Copyright 2022 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Adapts a pretrained TIMM image classification model to the CPR framework.
Documentation for the TIMM (Torch IMage Models) library is here:
https://rwightman.github.io/pytorch-image-models/
Its source can also be found here:
https://github.com/rwightman/pytorch-image-models
"""
import base64
import binascii
import io
import os
from typing import Dict, List, Union
from fastapi import HTTPException
from google.cloud.aiplatform import prediction as cpr
from pathlib import Path
import PIL
import smart_open
import timm
import torch
import torch.nn.functional as F
with open(Path(__file__).parent.absolute().joinpath("imagenet.txt")) as f:
IMAGENET_CLASSES = f.read().splitlines()
class TimmPredictor(cpr.predictor.Predictor):
"""Predictor class for image models based on TIMM."""
TIMM_MODEL_NAME = os.getenv("TIMM_MODEL_NAME", default="vit_small_patch32_224")
WEIGHTS_FILE = "state_dict.pth"
NUM_TOP_CLASSES_TO_RETURN = 5
def __init__(self):
self._cuda = torch.cuda.device_count() > 0
def load(self, artifacts_uri: str = ""):
"""Initializes the model and preprocessing transforms.
Args:
artifacts_uri: Directory where state dict is stored. Can be a
GCS URI or local path.
"""
if artifacts_uri:
artifact_path = os.path.join(artifacts_uri)
if not (os.path.isdir(artifact_path) or artifact_path.startswith("gs://")):
raise ValueError("Provided artifact_uri is not a directory.")
else:
artifact_path = os.getcwd()
artifact_path = os.path.join(artifact_path, self.WEIGHTS_FILE)
with smart_open.open(artifact_path, "rb") as f:
self._model = torch.load(f)
if self._cuda:
self._model.cuda()
config = timm.data.resolve_data_config(model=self.TIMM_MODEL_NAME, args=[])
self._transform = timm.data.create_transform(
is_training=False, use_prefetcher=False, **config
)
def preprocess(self, request_dict: Dict[str, List[str]]) -> torch.Tensor:
"""Performs preprocessing.
By default, the server expects a request body consisting of a valid JSON
object. This will be parsed by the handler before it's evaluated by the
preprocess method.
Args:
request_dict: Parsed request body. We expect that the input consists of
a list of base64-encoded image files under the "instances" key. (Any
image format that PIL.image.open can handle is okay.)
Returns:
torch.Tensor containing the preprocessed images as a batch. If GPU is
available, the result tensor will be stored on GPU.
"""
if "instances" not in request_dict:
raise HTTPException(
status_code=400,
detail='Request must contain "instances" as a top-level key.',
)
tensors = []
for (i, image) in enumerate(request_dict["instances"]):
# We use Base64 encoding to handle image data.
# This is probably the best we can do while still using JSON input.
# Overriding the input format requires building a custom Handler.
try:
image_bytes = base64.b64decode(image, validate=True)
except (binascii.Error, TypeError) as e:
raise HTTPException(
status_code=400,
detail=f"Base64 decoding of the input image at index {i} failed:"
f" {str(e)}",
)
try:
pil_image = PIL.Image.open(io.BytesIO(image_bytes)).convert("RGB")
except PIL.UnidentifiedImageError:
raise HTTPException(
status_code=400,
detail=f"The input image at index {i} could not be identified as an"
" image file.",
)
tensors.append(self._transform(pil_image))
with torch.inference_mode():
result = torch.stack(tensors)
if self._cuda:
result = result.cuda()
return result
def predict(self, instances: torch.Tensor) -> torch.Tensor:
"""Performs prediction.
Args:
instances: torch.Tensor with type torch.float32 and shape
[?, 3, 224, 224], containing the pre-processed input images.
Returns:
Vector of scores with type torch.float32 and shape [?, 1000],
representing the model's estimate of the likelihood that the
input belongs to the Imagenet class with that index.
"""
with torch.inference_mode():
class_scores = self._model(instances)
return class_scores
def postprocess(
self, class_scores: torch.Tensor
) -> Dict[str, List[Dict[str, Union[str, int, float]]]]:
"""Translate the model output into a classification result.
Args:
class_scores: torch.Tensor with type torch.float32 and shape
[?, 1000], containing the scores assigned to each class by
the model.
Returns:
Dictionary containing the list of classification results. Each
classification result contains the probabilities, class names, and
class indices of the classes with the top class scores as reported by
the model.
"""
class_probs = F.softmax(class_scores, dim=1)
top_k = class_probs.topk(self.NUM_TOP_CLASSES_TO_RETURN)
top_k_values = top_k.values.numpy().tolist()
top_k_indices = top_k.indices.numpy().tolist()
predictions = [
dict(
probabilities=values,
indices=indices,
class_names=[IMAGENET_CLASSES[int(class_num)] for class_num in indices],
)
for (values, indices) in zip(top_k_values, top_k_indices)
]
return {"predictions": predictions}
@@ -0,0 +1,52 @@
# Overview
*Pluto* is a programming environment for Julia, designed to be interactive and helpful. It provides a familiar notebook interface but it is not a Jupyter notebook. The biggest difference is that Pluto notebooks are reactive, changing a variable or function in one cell causes the cells that depend on that variable or function to be reevaluated. Pluto also provides useful interaction mechanisms that allow users to dynamically interact with the notebooks computation state.
The JuliaCon 2020 presentation: [Interactive notebooks ~ Pluto.jl]() provides a good introduction to Pluto. The source is at [fonsp/Pluto.jl]()
# Install Pluto
## Create a Vertex AI JupyterLab Instance
1. From the [GCP console](https://console.cloud.google.com) "hamburger menu"
select Vertex AI > Workbench
2. Click NEW NOTEBOOK
* Choose Python 3 if you won't be using a GPU
* Choose Python 3 (CUDA Toolkit xx.y) if you do want use a GPU
3. Give the notebook an appropriate name
4. Edit Notebook properties if you have special requirements otherwise accept the defaults and click CREATE
5. When the notebook instance is ready click OPEN JUPYTERLAB
## Configure JupyterLab
1. Open a terminal by clicking the Terminal icon.
1. Install the plutoserver
pip3 install git+https://github.com/fonsp/pluto-on-jupyterlab.git
1. In a browser go to [julialang.org/downloads](https://julialang.org/downloads/)
1. In the Current stable release right click on the `Generic Linux on x86 / 64-bit (glibc)` link
Select copy link address
1. Back in the terminal switch to root via
sudo -i
1. Download the release to /opt and install julia in /usr/local/bin
```bash
cd /opt
wget <paste the release link address>
tar xf <name of the downloaded tar file>
ln -s /opt/<julia-x.y.z>/bin/julia /usr/local/bin
^d
```
1. Add the Pluto package to Julia
```bash
julia
julia> ]add Pluto
julia> bksp
julia> using Pluto
julia> ^d
```
1. From the JupyterLab menu bar select File > Shut Down
# Start Pluto
1. Click OPEN JUPYTERLAB in the Workbench
1. In the Notebook section of the Launcher click Pluto.jl
1. The welcome to Pluto.jl screen should appear
@@ -1,474 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a6b56b1c7b76"
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c414a395a19b"
},
"source": [
"# PyTorch Image Classification Multi-Node Distributed Data Parallel Training on CPU using Vertex Training with Custom Container"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "b98238e32cf7"
},
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/master/community-content/pytorch_image_classification_distributed_data_parallel_training_with_vertex_sdk/multi_node_ddp_gloo_vertex_training_with_custom_container.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
"</table>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "03d216c7f7b1"
},
"source": [
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "c5ac73516218"
},
"outputs": [],
"source": [
"PROJECT_ID = \"YOUR PROJECT ID\"\n",
"BUCKET_NAME = \"gs://YOUR BUCKET NAME\"\n",
"REGION = \"YOUR REGION\"\n",
"SERVICE_ACCOUNT = \"YOUR SERVICE ACCOUNT\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0b5ae674177e"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "19a9b3bdd553"
},
"outputs": [],
"source": [
"content_name = \"pt-img-cls-multi-node-ddp-cust-cont\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "57bf6f8b4361"
},
"source": [
"## Local Training"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "e5d8a3443da0"
},
"outputs": [],
"source": [
"! ls trainer"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "07f79309472d"
},
"outputs": [],
"source": [
"! cat trainer/requirements.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "e16cd8bb7483"
},
"outputs": [],
"source": [
"! pip install -r trainer/requirements.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0b8a210718c4"
},
"outputs": [],
"source": [
"! cat trainer/task.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "c0c6e7dfb3c6"
},
"outputs": [],
"source": [
"%run trainer/task.py --epochs 5 --no-cuda --local-mode"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "31dfdeede587"
},
"outputs": [],
"source": [
"! ls ./tmp"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "48d56ec621cc"
},
"outputs": [],
"source": [
"! rm -rf ./tmp"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8f3ea1210749"
},
"source": [
"## Vertex Training using Vertex SDK and Custom Container"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "93002a20a2a6"
},
"source": [
"### Build Custom Container"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4130ce43fd08"
},
"outputs": [],
"source": [
"hostname = \"gcr.io\"\n",
"image_name = content_name\n",
"tag = \"latest\"\n",
"\n",
"custom_container_image_uri = f\"{hostname}/{PROJECT_ID}/{image_name}:{tag}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2f1fc5b05240"
},
"outputs": [],
"source": [
"! cd trainer && docker build -t $custom_container_image_uri -f Dockerfile ."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "b4f274f499ac"
},
"outputs": [],
"source": [
"! docker run --rm $custom_container_image_uri --epochs 5 --no-cuda --local-mode"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ee1a0a06d0b4"
},
"outputs": [],
"source": [
"! docker push $custom_container_image_uri"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cb763be12fc9"
},
"outputs": [],
"source": [
"! gcloud container images list --repository $hostname/$PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "10c8cc6b3334"
},
"source": [
"### Initialize Vertex SDK"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1a12348169fa"
},
"outputs": [],
"source": [
"! pip install -r requirements.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "42e981cefe41"
},
"outputs": [],
"source": [
"from google.cloud import aiplatform\n",
"\n",
"aiplatform.init(\n",
" project=PROJECT_ID,\n",
" staging_bucket=BUCKET_NAME,\n",
" location=REGION,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "73c92c9298e9"
},
"source": [
"### Create a Vertex Tensorboard Instance"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bde509558cd5"
},
"outputs": [],
"source": [
"content_name = content_name + \"-cpu\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6d7908c0083c"
},
"outputs": [],
"source": [
"tensorboard = aiplatform.Tensorboard.create(\n",
" display_name=content_name,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "a1f0a4f54037"
},
"source": [
"#### Option: Use a Previously Created Vertex Tensorboard Instance\n",
"\n",
"```\n",
"tensorboard_name = \"Your Tensorboard Resource Name or Tensorboard ID\"\n",
"tensorboard = aiplatform.Tensorboard(tensorboard_name=tensorboard_name)\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "a4cac84e04ac"
},
"source": [
"### Run a Vertex SDK CustomContainerTrainingJob"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "f92e8fdd44ee"
},
"outputs": [],
"source": [
"display_name = content_name\n",
"gcs_output_uri_prefix = f\"{BUCKET_NAME}/{display_name}\"\n",
"\n",
"replica_count = 4\n",
"machine_type = \"n1-standard-4\"\n",
"\n",
"args = [\n",
" \"--backend\",\n",
" \"gloo\",\n",
" \"--no-cuda\",\n",
" \"--batch-size\",\n",
" \"128\",\n",
" \"--epochs\",\n",
" \"25\",\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ae4c57df7e07"
},
"outputs": [],
"source": [
"custom_container_training_job = aiplatform.CustomContainerTrainingJob(\n",
" display_name=display_name,\n",
" container_uri=custom_container_image_uri,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "35cf3ecdf0df"
},
"outputs": [],
"source": [
"custom_container_training_job.run(\n",
" args=args,\n",
" base_output_dir=gcs_output_uri_prefix,\n",
" replica_count=replica_count,\n",
" machine_type=machine_type,\n",
" tensorboard=tensorboard.resource_name,\n",
" service_account=SERVICE_ACCOUNT,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "49d10dded73b"
},
"outputs": [],
"source": [
"print(f\"Custom Training Job Name: {custom_container_training_job.resource_name}\")\n",
"print(f\"GCS Output URI Prefix: {gcs_output_uri_prefix}\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "78398f52807b"
},
"source": [
"### Training Output Artifact"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "fc74422de1d1"
},
"outputs": [],
"source": [
"! gsutil ls $gcs_output_uri_prefix"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5e99a6a05b10"
},
"source": [
"## Clean Up Artifact"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "b0c1b3f7466b"
},
"outputs": [],
"source": [
"! gsutil rm -rf $gcs_output_uri_prefix"
]
}
],
"metadata": {
"colab": {
"name": "multi_node_ddp_gloo_vertex_training_with_custom_container.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
@@ -1,347 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a6b56b1c7b76"
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "20a5ea0081d0"
},
"source": [
"# PyTorch Image Classification Multi-Node Distributed Data Parallel Training on GPU using Vertex Training with Custom Container"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8752d4a255fb"
},
"source": [
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/master/community-content/pytorch_image_classification_distributed_data_parallel_training_with_vertex_sdk/multi_node_ddp_nccl_vertex_training_with_custom_container.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
"</table>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "03d216c7f7b1"
},
"source": [
"## Setup"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "c5ac73516218"
},
"outputs": [],
"source": [
"PROJECT_ID = \"YOUR PROJECT ID\"\n",
"BUCKET_NAME = \"gs://YOUR BUCKET NAME\"\n",
"REGION = \"YOUR REGION\"\n",
"SERVICE_ACCOUNT = \"YOUR SERVICE ACCOUNT\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0b5ae674177e"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "19a9b3bdd553"
},
"outputs": [],
"source": [
"content_name = \"pt-img-cls-multi-node-ddp-cust-cont\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5307fe28b633"
},
"source": [
"## Vertex Training using Vertex SDK and Custom Container"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "46cb58c7fbf9"
},
"source": [
"### Built Custom Container"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "97e66e9f9bab"
},
"outputs": [],
"source": [
"hostname = \"gcr.io\"\n",
"image_name = content_name\n",
"tag = \"latest\"\n",
"\n",
"custom_container_image_uri = f\"{hostname}/{PROJECT_ID}/{image_name}:{tag}\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ae9b29c4773f"
},
"source": [
"### Initialize Vertex SDK"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "dc1e84d5dec2"
},
"outputs": [],
"source": [
"! pip install -r requirements.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6964be27b98e"
},
"outputs": [],
"source": [
"from google.cloud import aiplatform\n",
"\n",
"aiplatform.init(\n",
" project=PROJECT_ID,\n",
" staging_bucket=BUCKET_NAME,\n",
" location=REGION,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "594a91f438f2"
},
"source": [
"### Create a Vertex Tensorboard Instance"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "93134273261e"
},
"outputs": [],
"source": [
"content_name = content_name + \"-gpu\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "c2bd82dbcd9b"
},
"outputs": [],
"source": [
"tensorboard = aiplatform.Tensorboard.create(\n",
" display_name=content_name,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ebc593c6472e"
},
"source": [
"#### Option: Use a Previously Created Vertex Tensorboard Instance\n",
"\n",
"```\n",
"tensorboard_name = \"Your Tensorboard Resource Name or Tensorboard ID\"\n",
"tensorboard = aiplatform.Tensorboard(tensorboard_name=tensorboard_name)\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0769e8e34c2f"
},
"source": [
"### Run a Vertex SDK CustomContainerTrainingJob"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "023f33ece826"
},
"outputs": [],
"source": [
"display_name = content_name\n",
"gcs_output_uri_prefix = f\"{BUCKET_NAME}/{display_name}\"\n",
"\n",
"replica_count = 1\n",
"machine_type = \"n1-standard-4\"\n",
"accelerator_count = 4\n",
"accelerator_type = \"NVIDIA_TESLA_K80\"\n",
"\n",
"args = [\n",
" \"--backend\",\n",
" \"nccl\",\n",
" \"--batch-size\",\n",
" \"128\",\n",
" \"--epochs\",\n",
" \"25\",\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "d4b599e726ef"
},
"outputs": [],
"source": [
"custom_container_training_job = aiplatform.CustomContainerTrainingJob(\n",
" display_name=display_name,\n",
" container_uri=custom_container_image_uri,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "81321e3bdf7f"
},
"outputs": [],
"source": [
"custom_container_training_job.run(\n",
" args=args,\n",
" base_output_dir=gcs_output_uri_prefix,\n",
" replica_count=replica_count,\n",
" machine_type=machine_type,\n",
" accelerator_count=accelerator_count,\n",
" accelerator_type=accelerator_type,\n",
" tensorboard=tensorboard.resource_name,\n",
" service_account=SERVICE_ACCOUNT,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "5100712c2c4c"
},
"outputs": [],
"source": [
"print(f\"Custom Training Job Name: {custom_container_training_job.resource_name}\")\n",
"print(f\"GCS Output URI Prefix: {gcs_output_uri_prefix}\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f9b77676e5a6"
},
"source": [
"### Training Output Artifact"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0e171ce95ace"
},
"outputs": [],
"source": [
"! gsutil ls $gcs_output_uri_prefix"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cf1b74a12b87"
},
"source": [
"## Clean Up Artifact"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a0b15089c341"
},
"outputs": [],
"source": [
"! gsutil rm -rf $gcs_output_uri_prefix"
]
}
],
"metadata": {
"colab": {
"name": "multi_node_ddp_nccl_vertex_training_with_custom_container.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
@@ -1,4 +1,4 @@
google-cloud-bigquery==2.20.0
tensorflow==2.5.3
pillow==9.0.0
tensorflow==2.7.2
pillow==9.0.1
tf-agents==0.8.0
@@ -1,4 +1,4 @@
google-cloud-pubsub==2.5.0
pillow==9.0.0
pillow==9.0.1
tf-agents==0.8.0
tensorflow==2.5.3
tensorflow==2.7.2
@@ -1,5 +1,5 @@
dataclasses==0.6
google-cloud-aiplatform==1.8.1
tensorflow==2.5.3
pillow==9.0.0
tensorflow==2.7.2
pillow==9.0.1
tf-agents==0.8.0
@@ -706,8 +706,8 @@
" else:\n",
" data_spec = training_data_spec_transformation_fn(\n",
" agent.policy.trajectory_spec)\n",
" replay_buffer = trainer.get_replay_buffer(data_spec, environment.batch_size,\n",
" steps_per_loop)\n",
" replay_buffer = trainer.get_replay_buffer(data_spec, environment.batch_size,\n",
" steps_per_loop)\n",
"\n",
" # `step_metric` records the number of individual rounds of bandit interaction;\n",
" # that is, (number of trajectories) * batch_size.\n",
@@ -1 +1 @@
tensorflow==2.5.3
tensorflow==2.7.2
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -113,8 +113,8 @@
},
"outputs": [],
"source": [
"! gcloud beta ai custom-jobs local-run \\\n",
" --base-image=$BASE_IMAGE_URI \\\n",
"! gcloud ai custom-jobs local-run \\\n",
" --executor-image-uri=$BASE_IMAGE_URI \\\n",
" --script=$SCRIPT_PATH \\\n",
" --output-image-uri=$OUTPUT_IMAGE_NAME \\\n",
" -- \\\n",
+5
View File
@@ -0,0 +1,5 @@
The [official](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/official) folder contains notebooks organized by Google Cloud product. These are tested weekly and maintained by Google.
The [community](https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/community) folder contains notebooks that may be created by Google or external contributors. They are not necessary maintained.
Contributions to the repo should use the [notebook template](https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/notebook_template.ipynb) as a starting point.
+21 -12
View File
@@ -3,19 +3,28 @@
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
/sdk/sdk_* @aferlitsch
/gapic @aferlitsch
/ml_ops @aferlitsch
/model_monitoring/* @mco
/sdk/sdk_* @andrewferlitsch
/gapic @andrewferlitsch
/gapic/custom/showcase_custom_image_classification_online_explain_example_based_api.ipynb @inardini
/ml_ops @andrewferlitsch
/model_monitoring/* @mco-gh
/structured_data/rapid_prototyping_* @rafael-carvalho
/managed_notebooks/ @notebooks-team
/sdk/SDK_FBProphet_Forecasting_Online.ipynb @brianchunkang
/managed_notebooks/
/bigquery_ml/ @polong
/sdk/SDK_FBProphet_Forecasting_Online.ipynb @brianchunkang
/pipelines/google_cloud_pipeline_components_TPU_model_train_upload_deploy.ipynb @brianchunkang
/sdk/SDK_AutoML_Forecasting_Model_Training_Example.ipynb @thehardikv
/sdk/sdk_automl_forecasting_evaluating_a_model.ipynb @thehardikv
/matching_engine @yinghsienwu
/neo4j @benofben @htappen
/explainable_ai/SDK_Custom_Container_XAI.ipynb @brianchunkang
/matching_engine/sdk_matching_engine_for_indexing.ipynb @ivanmkc
/matching_engine/matching_engine_for_indexing.ipynb @yinghsienwu
/sdk/pytorch_lightning_custom_container_training.ipynb @brianchunkang
/tensorboard @yfang1 @wattli
/feature_store @nayaknishant
/tensorboard @yfang1
/feature_store @nayaknishant @morgandu
/prediction @googleapis/vertex-prediction-team
/vertex_endpoints/tf_hub_obj_detection/deploy_tfhub_object_detection_on_vertex_endpoints.ipynb @entrpn
/vertex_endpoints/nvidia-triton/nvidia-triton-custom-container-prediction.ipynb @RajeshThallam
/vertex_endpoints/optimized_tensorflow_runtime @vlasenkoalexey
/notebooks/community/ml_ops/stage2/get_started_with_visionapi_and_automl.ipynb @mansari
/notebooks/community/neo4j/graph_paysim.ipynb @benofben @laeg
/notebooks/community/ml_ops/stage1/get_started_with_visionapi_and_vertex_datasets.ipynb @mansari
/notebooks/community/pipelines/google_cloud_pipeline_components_bqml_pipeline_demand_forecasting.ipynb @inardini
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

@@ -180,7 +180,7 @@
},
"outputs": [],
"source": [
"! pip install {USER_FLAG} --upgrade git+https://github.com/googleapis/python-aiplatform.git@main"
"! pip install {USER_FLAG} --upgrade google-cloud-aiplatform"
]
},
{
@@ -742,7 +742,7 @@
"source": [
"### Source Data Format and Layout\n",
"\n",
"BigQuery table/Avro/CSV are supported as input data types. No matter what format you are using, each imported entity *must* have an ID; also, each entity can *optionally* have a timestamp, specifying when the feature values are generated. This Colab uses Avro as an input, located at this public [bucket](https://pantheon.corp.google.com/storage/browser/cloud-samples-data-us-central1/vertex-ai/feature-store/datasets). The Avro schemas are as follows:\n",
"BigQuery table/Avro/CSV are supported as input data types. No matter what format you are using, each imported entity *must* have an ID; also, each entity can *optionally* have a timestamp, specifying when the feature values are generated. This Colab uses Avro as an input, located at this public [bucket](https://console.cloud.google.com/storage/browser/cloud-samples-data-us-central1/vertex-ai/feature-store/datasets). The Avro schemas are as follows:\n",
"\n",
"**For the Users entity**:\n",
"```\n",
File diff suppressed because it is too large Load Diff
@@ -459,7 +459,7 @@
},
"outputs": [],
"source": [
"! gsutil cp gs://cloud-samples-data/ai-platform-unified/matching_engine/glove-100-angular.hdf5 ."
"! gsutil cp gs://cloud-samples-data/vertex-ai/matching_engine/glove-100-angular.hdf5 ."
]
},
{
+2 -2
View File
@@ -12,7 +12,7 @@ The purpose of this set of notebooks and markdown files is to demonstrate Google
2. [Experimentation](stage2)
3. [Formalization](stage3)
4. [Evaluation](stage4)
5. Deployment
6. Serving
5. [Deployment](stage5)
6. [Serving](stage6)
7. Monitoring
8. Continuous Training
+49 -33
View File
@@ -22,17 +22,56 @@ The first stage in MLOps is the collection and preparation for the purpose of de
- Data is preprocessed for training and evaluation using Dataflow.
- Data augmentation is performed on-the-fly and is coupled with model feeding.
<img src='stage1.jpg'>
<img src='stage1v2.png'>
## Notebooks
### Get Started
[Get Started with BQ datasets](get_started_bq_datasets.ipynb)
[Get started with Vertex AI datasets](get_started_vertex_datasets.ipynb)
```
The steps performed include:
- Create a Vertex AI `Dataset` resource for:
- image data
- text data
- video data
- tabular data
- forecasting data
- Search `Dataset` resources using a filter.
- Read a sample of a `BigQuery` dataset into a dataframe.
- Generate statistics and data schema using TensorFlow Data Validation from the samples in the dataframe.
- Detect anomalies in new data using TensorFlow Data Validation.
- Generate a TFRecord feature specification using TensorFlow Transform from the data schema.
- Export a dataset and convert to TFRecords.
```
[Get started with Dataflow](get_started_dataflow.ipynb)
```
The steps performed include:
- Offline preprocessing of data:
- Serially - w/o dataflow
- Parallel - with dataflow
- Upstream preprocessing of data:
- tabular data
- image data
```
[Create an unlabelled Vertex AI AutoML text entity extraction dataset from pdfs using Vision API](get_started_with_visionapi_and_vertex_datasets.ipynb)
```
The steps performed include:
1. Using `Vision API` to perform Optical Character Recognition (OCR) to extract text from PDF files.
2. Processing the results and saving them to text files.
3. Generating a `Vertex AI Dataset` import file.
4. Creating a new unlabelled text entity extraction `Vertex AI Dataset` resource in `Vertex AI`.
```
[Get started with BigQuery datasets](get_started_bq_datasets.ipynb)
```
The steps performed include:
- Create a Vertex AI `Dataset` resource from `BigQuery` table -- compatible for `AutoML` training.
- Extract a copy of the dataset from `BigQuery` to a CSV file in Cloud Storage -- compatible for `AutoML` or custom training.
- Select rows from a `BigQuery` dataset into a `pandas` dataframe -- compatible for custom training.
@@ -42,47 +81,25 @@ The steps performed include:
- Extract data from `BigQuery` table into a `DMatrix` -- compatible for custom training `XGBoost` models.
```
[Get Started with Vertex datasets](get_started_vertex_datasets.ipynb)
[Get started with Vertex AI data labeling](get_started_with_data_labeling.ipynb)
```
The steps performed include:
- Create a Vertex AI `Dataset` resource for:
- image data
- text data
- video data
- tabular data
- forecasting data
- Create a Specialist Pool for data labelers.
- Create a data labeling job.
- Submit the data labeling job.
- List data labeling jobs.
- Cancel a data labeling job.
- Search `Dataset` resources using a filter.
- Read a sample of a `BigQuery` dataset into a dataframe.
- Generate statistics and data schema using TensorFlow Data Validation from the samples in the dataframe.
- Detect anomalies in new data using TensorFlow Data Validation.
- Generate a TFRecord feature specification using TensorFlow Transform from the data schema.
- Export a dataset and convert to TFRecords.
```
[Get Started with Dataflow](get_started_dataflow.ipynb)
```
The steps performed include:
- Offline preprocessing of data:
- Serially - w/o dataflow
- Parallel - with dataflow
- Upstream preprocessing of data:
- tabular data
- image data
```
### E2E Stage Example
[Stage 1: Data Management](mlops_data_management.ipynb)
```
The steps performed include:
- Explore and visualize the data.
- Create a Vertex AI `Dataset` resource from `BigQuery` table -- for AutoML training.
- Extract a copy of the dataset to a CSV file in Cloud Storage.
@@ -92,4 +109,3 @@ The steps performed include:
- Generate a TFRecord feature specification using TensorFlow Data Validation from the data schema.
- Preprocess a portion of the BigQuery data using `Dataflow` -- for custom training.
```
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -34,13 +34,18 @@
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_bq_datasets.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_bq_datasets.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_bq_datasets.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage1/get_started_bq_datasets.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -59,17 +64,6 @@
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 1 : data management: get started with BigQuery datasets."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset you use only the fields year, month and day to predict the value of mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -104,7 +98,7 @@
"source": [
"### Recommendations\n",
"\n",
"When doing E2E MLOps on Google Cloud, the following best practices with structured (tabular) data in BigQuery:\n",
"When doing E2E MLOps on Google Cloud, following are the best practices when dealing with structured (tabular) data in BigQuery:\n",
"\n",
"- For AutoML training:\n",
" - Create a managed dataset with Vertex AI `TabularDataset`.\n",
@@ -124,7 +118,7 @@
" - Within the generator (upstream)\n",
" - Within the model (downstream)\n",
" - XGBoost model training:\n",
" - Use BigQuery ML builtin XGBoost training.\n",
" - Use BigQuery ML built-in XGBoost training.\n",
" - Alternatively, create a DMatrix generator from CSV files extracted from BigQuery table.\n",
" - Pytorch model training:\n",
" - Extract the BigQuery to a pandas dataframe.\n",
@@ -132,12 +126,39 @@
" - Create a DataLoader generator from the pandas dataframe.\n",
"\n",
"\n",
"- Alternately:\n",
"- Alternatively:\n",
" - Extract the BigQuery table to CSV files.\n",
" - Preprocess the CSV files.\n",
" - Create a tf.data.Dataset generator from the CSV files."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). In this version of the dataset you consider the fields year, month and day to predict the value of mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9e483012a752"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"- Cloud Storage\n",
"- BigQuery\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing), [Cloud Storage pricing](https://cloud.google.com/storage/pricing) and [BigQuery pricing](https://cloud.google.com/bigquery/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -146,7 +167,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the following packages to execute this notebook."
]
},
{
@@ -157,40 +178,26 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "install_xgboost"
},
"source": [
"Install the latest GA version of *XGBoost* library as well."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_xgboost"
},
"outputs": [],
"source": [
"! pip3 install -U xgboost $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"# Install the packages\n",
"! pip3 install --upgrade pyarrow $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install -U xgboost $USER_FLAG -q\n",
"! pip3 install -U tensorflow $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q"
]
},
{
@@ -222,6 +229,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -298,7 +331,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -325,6 +361,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -335,12 +432,7 @@
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you submit a custom training job using the Vertex SDK, you upload a Python package\n",
"containing your training code to a Cloud Storage bucket. Vertex AI runs\n",
"the code from this package. In this tutorial, Vertex AI also saves the\n",
"trained model that results from your job in the same bucket. You can then\n",
"create an `Endpoint` resource based on this output in order to serve\n",
"online predictions.\n",
"When you create a dataset resource using the Vertex SDK, you can provide a Cloud Storage bucket that contains the data. Vertex AI creates the dataset resource from the data. In this tutorial, Vertex AI also creates a dataset resource from your data in the Cloud Storage bucket.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
@@ -353,7 +445,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -364,8 +457,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -385,7 +479,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -405,7 +499,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -414,9 +508,6 @@
"id": "setup_vars"
},
"source": [
"### Set up variables\n",
"\n",
"Next, set up some variables used throughout the tutorial.\n",
"### Import libraries and define constants"
]
},
@@ -428,75 +519,12 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_bq"
},
"source": [
"#### Import BigQuery\n",
"\n",
"Import the BigQuery package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_bq"
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aiplatform\n",
"import pandas as pd\n",
"import xgboost as xgb\n",
"from google.cloud import bigquery"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_xgboost"
},
"source": [
"#### Import XGBoost\n",
"\n",
"Import the XGBoost package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_xgboost"
},
"outputs": [],
"source": [
"import xgboost as xgb"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_pandas"
},
"source": [
"#### Import pandas\n",
"\n",
"Import the pandas package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_pandas"
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -516,7 +544,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, location=REGION)"
"aiplatform.init(project=PROJECT_ID, location=REGION)"
]
},
{
@@ -538,7 +566,7 @@
},
"outputs": [],
"source": [
"bqclient = bigquery.Client()"
"bqclient = bigquery.Client(project=PROJECT_ID)"
]
},
{
@@ -549,7 +577,7 @@
"source": [
"#### Location of BigQuery training data.\n",
"\n",
"Now set the variable `IMPORT_FILE` to the location of the data table in BigQuery."
"Now, set the variable `IMPORT_FILE` to the location of the data table in BigQuery and `BQ_TABLE` with the table id."
]
},
{
@@ -591,10 +619,10 @@
},
"outputs": [],
"source": [
"dataset = aip.TabularDataset.create(\n",
"dataset = aiplatform.TabularDataset.create(\n",
" display_name=\"NOAA historical weather data\" + \"_\" + TIMESTAMP,\n",
" bq_source=[IMPORT_FILE],\n",
" labels={\"user_metadata\": BUCKET_NAME[5:]},\n",
" labels={\"user_metadata\": BUCKET_URI[5:]},\n",
")\n",
"\n",
"label_column = \"mean_temp\"\n",
@@ -610,7 +638,7 @@
"source": [
"### Copy the dataset to Cloud Storage\n",
"\n",
"Next, you make a copy of the BigQuery dataset, as a CSV file, to Cloud Storage using the BigQuery extract command.\n",
"Next, you make a copy of the BigQuery table as a CSV file, to Cloud Storage using the BigQuery extract command.\n",
"\n",
"Learn more about [BigQuery command line interface](https://cloud.google.com/bigquery/docs/reference/bq-cli-reference)."
]
@@ -626,9 +654,9 @@
"comps = BQ_TABLE.split(\".\")\n",
"BQ_PROJECT_DATASET_TABLE = comps[0] + \":\" + comps[1] + \".\" + comps[2]\n",
"\n",
"! bq --location=us extract --destination_format CSV $BQ_PROJECT_DATASET_TABLE $BUCKET_NAME/mydata*.csv\n",
"! bq --location=us extract --destination_format CSV $BQ_PROJECT_DATASET_TABLE $BUCKET_URI/mydata*.csv\n",
"\n",
"IMPORT_FILES = ! gsutil ls $BUCKET_NAME/mydata*.csv\n",
"IMPORT_FILES = ! gsutil ls $BUCKET_URI/mydata*.csv\n",
"\n",
"print(IMPORT_FILES)\n",
"\n",
@@ -664,15 +692,12 @@
},
"outputs": [],
"source": [
"if \"IMPORT_FILES\" in globals():\n",
" gcs_source = IMPORT_FILES\n",
"else:\n",
" gcs_source = [IMPORT_FILE]\n",
"gcs_source = IMPORT_FILES\n",
"\n",
"dataset = aip.TabularDataset.create(\n",
"dataset = aiplatform.TabularDataset.create(\n",
" display_name=\"NOAA historical weather data\" + \"_\" + TIMESTAMP,\n",
" gcs_source=gcs_source,\n",
" labels={\"user_metadata\": BUCKET_NAME[5:]},\n",
" labels={\"user_metadata\": BUCKET_URI[5:]},\n",
")\n",
"\n",
"\n",
@@ -694,6 +719,30 @@
"Learn more about [Creating BigQuery views](https://cloud.google.com/bigquery/docs/views)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "7dc142433e50"
},
"outputs": [],
"source": [
"# Set dataset name and view name in BigQuery\n",
"BQ_MY_DATASET = \"[your-dataset-name]\"\n",
"BQ_MY_TABLE = \"[your-view-name]\"\n",
"\n",
"# Otherwise, use the default names\n",
"if (\n",
" BQ_MY_DATASET == \"\"\n",
" or BQ_MY_DATASET is None\n",
" or BQ_MY_DATASET == \"[your-dataset-name]\"\n",
"):\n",
" BQ_MY_DATASET = \"mlops_dataset_\" + TIMESTAMP\n",
"\n",
"if BQ_MY_TABLE == \"\" or BQ_MY_TABLE is None or BQ_MY_TABLE == \"[your-view-name]\":\n",
" BQ_MY_TABLE = \"mlops_view_\" + TIMESTAMP"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -702,8 +751,7 @@
},
"outputs": [],
"source": [
"BQ_MY_DATASET = 'mydataset'\n",
"BQ_MY_TABLE = 'myview'\n",
"# Create the resources\n",
"! bq --location=US mk -d \\\n",
"$PROJECT_ID:$BQ_MY_DATASET\n",
"\n",
@@ -744,8 +792,8 @@
},
"outputs": [],
"source": [
"# Download a table.\n",
"table = bigquery.TableReference.from_string(\"bigquery-public-data.samples.gsod\")\n",
"# Download the table.\n",
"table = bigquery.TableReference.from_string(BQ_TABLE)\n",
"\n",
"rows = bqclient.list_rows(\n",
" table,\n",
@@ -1031,22 +1079,6 @@
"TABLE_ID = \"gsod\"\n",
"\n",
"\n",
"def create_bigquery_dataset(dataset_id):\n",
" dataset = bigquery.Dataset(\n",
" bigquery.dataset.DatasetReference(PROJECT_ID, dataset_id)\n",
" )\n",
" dataset.location = \"us\"\n",
"\n",
" try:\n",
" dataset = bqclient.create_dataset(dataset) # API request\n",
" return True\n",
" except Exception as err:\n",
" print(err)\n",
" if err.code != 409: # http_client.CONFLICT\n",
" raise\n",
" return False\n",
"\n",
"\n",
"def load_data_into_bigquery(url, dataset_id, table_id):\n",
" create_bigquery_dataset(dataset_id)\n",
" dataset = bqclient.dataset(dataset_id)\n",
@@ -1079,13 +1111,11 @@
"source": [
"### Read BigQuery table into XGboost DMatrix\n",
"\n",
"Currently, there is no direct data feeding connector between BigQuery and the open source XGBoost.\n",
"Currently, there is no direct data feeding connector between BigQuery and the open source XGBoost. The BigQuery ML service has a built-in XGBoost training module.\n",
"\n",
"The BigQuery ML service has XGBoost training builtin.\n",
"Alernatively, you extract the data either as a pandas dataframe or as CSV files. The extracted data is then given as an input to a `DMatrix` object when training the model.\n",
"\n",
"Alernatively, you extract the data either as a pandas dataframe or as CSV files. The extracted data is then inputted to a `DMatrix` object when training the model.\n",
"\n",
"Learn more about [Getting started with builtin XGBoost](https://cloud.google.com/ai-platform/training/docs/algorithms/xgboost-start)"
"Learn more about [Getting started with built-in XGBoost](https://cloud.google.com/ai-platform/training/docs/algorithms/xgboost-start)."
]
},
{
@@ -1096,7 +1126,7 @@
"source": [
"### Read pandas table into XGboost DMatrix\n",
"\n",
"Next, you load the pandas dataframe into a `DMatrix` object. XGBoost does not support non-numeric inputs. Any column that is categorical will need to be one-hot encoded prior to loading the dataframe."
"Next, you load the pandas dataframe into a `DMatrix` object. XGBoost does not support non-numeric inputs. Any column that is categorical need to be one-hot encoded prior to loading the dataframe."
]
},
{
@@ -1109,7 +1139,7 @@
"source": [
"dataframe[\"station_number\"] = pd.to_numeric(dataframe[\"station_number\"])\n",
"labels = dataframe[\"mean_temp\"]\n",
"data = dataframe.drop(4)\n",
"data = dataframe.drop([\"mean_temp\"], axis=1)\n",
"\n",
"dtrain = xgb.DMatrix(data, label=labels)"
]
@@ -1122,7 +1152,7 @@
"source": [
"### Read CSV files into XGboost DMatrix\n",
"\n",
"Currently, there is no Cloud Storage support in XGBoost. If you use CSV files for input, you will need to download them locally."
"Currently, there is no Cloud Storage support in XGBoost. If you use CSV files for input, you need to download them locally."
]
},
{
@@ -1144,87 +1174,42 @@
"id": "cleanup:mbsdk"
},
"source": [
"# Cleaning up\n",
"# Clean up\n",
"\n",
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
"- Vertex AI Dataset resource\n",
"- Cloud Storage Bucket\n",
"- BigQuery Dataset\n",
"\n",
"Set `delete_storage` to _True_ to delete the storage resources used in this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cleanup:mbsdk"
"id": "47ad926d84e8"
},
"outputs": [],
"source": [
"delete_all = True\n",
"import os\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"# Delete the dataset using the Vertex dataset object\n",
"dataset.delete()\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"# Delete the temporary BigQuery dataset\n",
"! bq rm -r -f $PROJECT_ID:$DATASET_ID\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"delete_storage = False\n",
"if delete_storage or os.getenv(\"IS_TESTING\"):\n",
" # Delete the created GCS bucket\n",
" ! gsutil rm -r $BUCKET_URI\n",
" # Delete the created BigQuery datasets\n",
" ! bq rm -r -f $PROJECT_ID:$BQ_MY_DATASET"
]
}
],
@@ -39,8 +39,14 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_dataflow.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_dataflow.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\\\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_dataflow.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -59,17 +65,6 @@
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 1 : data management: get started with Dataflow."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset you use only the fields year, month and day to predict the value of mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -131,6 +126,34 @@
"Alternately for AutoML tabular model training, you can reconfigure the otherwise default preprocessing."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset you use only the fields year, month and day to predict the value of mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9e483012a752"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"- Cloud Storage\n",
"- BigQuery\n",
"- Dataflow\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing), [Cloud Storage pricing](https://cloud.google.com/storage/pricing), [BigQuery pricing](https://cloud.google.com/bigquery/pricing), and [Dataflow pricing](https://cloud.google.com/dataflow/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -139,7 +162,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the following packages to execute this notebook."
]
},
{
@@ -150,20 +173,26 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install -U tensorflow==2.5 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-transform==1.2 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
"! pip3 install --upgrade apache-beam[gcp] $USER_FLAG -q"
]
},
{
@@ -195,6 +224,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -271,7 +326,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -298,6 +356,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -326,7 +445,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -337,8 +457,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -358,7 +479,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -378,7 +499,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -401,7 +522,7 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
"import google.cloud.aiplatform as aiplatform"
]
},
{
@@ -555,7 +676,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, location=REGION)"
"aiplatform.init(project=PROJECT_ID, location=REGION)"
]
},
{
@@ -676,6 +797,31 @@
"dataframe[\"station_number\"] = pd.to_numeric(dataframe[\"station_number\"])"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bqml_create_dataset"
},
"source": [
"### Create BQ dataset resource\n",
"\n",
"First, you create an empty dataset resource in your project."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bqml_create_dataset"
},
"outputs": [],
"source": [
"BQ_MY_DATASET = 'samples'\n",
"BQ_MY_TABLE = 'gsod'\n",
"! bq --location=US mk -d \\\n",
"$PROJECT_ID:$BQ_MY_DATASET"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -979,7 +1125,7 @@
},
"outputs": [],
"source": [
"SCHEMA_LOCATION = BUCKET_NAME + \"/schema.txt\"\n",
"SCHEMA_LOCATION = BUCKET_URI + \"/schema.txt\"\n",
"\n",
"# When running Apache Beam directly (file is directly accessed)\n",
"tfdv.write_schema_text(output_path=SCHEMA_LOCATION, schema=schema)\n",
@@ -1124,7 +1270,7 @@
" )\n",
"\n",
"\n",
"EXPORTED_DATA_PREFIX = os.path.join(BUCKET_NAME, \"exported_data\")\n",
"EXPORTED_DATA_PREFIX = os.path.join(BUCKET_URI, \"exported_data\")\n",
"\n",
"QUERY_STRING = \"SELECT {},{} FROM {} LIMIT 500\".format(\n",
" \"CAST(station_number as STRING) AS station_number,year,month,day\",\n",
@@ -1137,7 +1283,7 @@
" \"runner\": RUNNER,\n",
" \"raw_data_query\": QUERY_STRING,\n",
" \"exported_data_prefix\": EXPORTED_DATA_PREFIX,\n",
" \"temp_location\": os.path.join(BUCKET_NAME, \"temp\"),\n",
" \"temp_location\": os.path.join(BUCKET_URI, \"temp\"),\n",
" \"project\": PROJECT_ID,\n",
" \"region\": REGION,\n",
" \"setup_file\": \"./setup.py\",\n",
@@ -1162,17 +1308,7 @@
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
"Otherwise, you can delete the individual resources you created in this tutorial."
]
},
{
@@ -1183,61 +1319,11 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"delete_storage = True\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if delete_storage or os.getenv(\"IS_TESTING\"):\n",
" if \"BUCKET_URI\" in globals():\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -29,20 +29,26 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 1 : data management: get started with Vertex datasets\n",
"# E2E ML on GCP: MLOps stage 1 : data management: get started with Vertex AI datasets\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
"<img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td> \n",
"</table>\n",
"<br/><br/><br/>"
]
@@ -133,6 +139,33 @@
" - Create a tf.data.Dataset from the TFRecords."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "533dd6fe83c8"
},
"source": [
"### Datasets\n",
"\n",
"This tutorial uses a variety of public datasets to demonstrate using a `Vertex AI` managed dataset."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9e483012a752"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"- Cloud Storage\n",
"- BigQuery\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing), [Cloud Storage pricing](https://cloud.google.com/storage/pricing) and [BigQuery pricing](https://cloud.google.com/bigquery/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -141,7 +174,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the packages required for executing this notebook."
]
},
{
@@ -152,20 +185,27 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install -U tensorflow $USER_FLAG -q\n",
"! pip3 install -U tensorflow-data-validation $USER_FLAG -q\n",
"! pip3 install -U tensorflow-transform $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
"! pip3 install --upgrade db-dtypes $USER_FLAG -q! pip3 install --upgrade future $USER_FLAG -q"
]
},
{
@@ -197,6 +237,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cb082379ed5b"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). \n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -223,7 +289,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_project_id"
"id": "nWlzLu5ELxWd"
},
"outputs": [],
"source": [
@@ -238,7 +304,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_gcloud_project_id"
"id": "c021ca495967"
},
"outputs": [],
"source": [
@@ -273,7 +339,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -300,6 +369,66 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "927085b84a07"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"**Click Create service account**.\n",
"\n",
"In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex\" into the filter box, and select **Vertex Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "89788a802687"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -328,7 +457,7 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
@@ -339,8 +468,8 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
]
},
{
@@ -360,7 +489,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -380,7 +509,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -392,7 +521,11 @@
"### Set up variables\n",
"\n",
"Next, set up some variables used throughout the tutorial.\n",
"### Import libraries and define constants"
"### Import libraries and define constants\n",
"\n",
"Import the BigQuery package, TensorFlow Data Validation (TFDV) package and TensorFlow Data Validation package into your Python environment. \n",
"\n",
"Import TensorFlow Transform (TFT) package and pandas into your Python environment."
]
},
{
@@ -403,97 +536,13 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_bq"
},
"source": [
"#### Import BigQuery\n",
"\n",
"Import the BigQuery package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_bq"
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip\n",
"import pandas as pd\n",
"import tensorflow_data_validation as tfdv\n",
"import tensorflow_transform as tft\n",
"from google.cloud import bigquery"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_tfdv"
},
"source": [
"#### Import TensorFlow Data Validation\n",
"\n",
"Import the TensorFlow Data Validation (TFDV) package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_tfdv"
},
"outputs": [],
"source": [
"import tensorflow_data_validation as tfdv"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_tft"
},
"source": [
"#### Import TensorFlow Transform\n",
"\n",
"Import the TensorFlow Transform (TFT) package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_tft"
},
"outputs": [],
"source": [
"import tensorflow_transform as tft"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_pandas"
},
"source": [
"#### Import pandas\n",
"\n",
"Import the pandas package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_pandas"
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -513,7 +562,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, location=REGION)"
"aip.init(project=PROJECT_ID, location=REGION, staging_bucket=BUCKET_URI)"
]
},
{
@@ -567,26 +616,13 @@
"Learn more about [All dataset documentation](https://cloud.google.com/vertex-ai/docs/datasets/datasets)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:flowers,csv,icn"
},
"outputs": [],
"source": [
"IMPORT_FILE = (\n",
" \"gs://cloud-samples-data/vision/automl_classification/flowers/all_data_v2.csv\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_dataset:image,icn"
},
"source": [
"### Create the Dataset\n",
"### Create an Image Dataset\n",
"\n",
"Next, create the `Dataset` resource using the `create` method for the `ImageDataset` class, which takes the following parameters:\n",
"\n",
@@ -601,6 +637,19 @@
"Learn more about [ImageDataset](https://cloud.google.com/vertex-ai/docs/datasets/prepare-image)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:flowers,csv,icn"
},
"outputs": [],
"source": [
"IMPORT_FILE = (\n",
" \"gs://cloud-samples-data/vision/automl_classification/flowers/all_data_v2.csv\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -618,24 +667,13 @@
"print(dataset.resource_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:hmdb,csv,vcn"
},
"outputs": [],
"source": [
"IMPORT_FILE = \"gs://automl-video-demo-data/hmdb_split1_5classes_train_inf.csv\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_dataset:video,vcn"
},
"source": [
"### Create the Dataset\n",
"### Create a Video Dataset\n",
"\n",
"Next, create the `Dataset` resource using the `create` method for the `VideoDataset` class, which takes the following parameters:\n",
"\n",
@@ -649,6 +687,17 @@
"Learn more about [VideoDataset](https://cloud.google.com/vertex-ai/docs/datasets/prepare-video)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:hmdb,csv,vcn"
},
"outputs": [],
"source": [
"IMPORT_FILE = \"gs://automl-video-demo-data/hmdb_split1_5classes_train_inf.csv\""
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -666,24 +715,13 @@
"print(dataset.resource_name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:happydb,csv,tcn"
},
"outputs": [],
"source": [
"IMPORT_FILE = \"gs://cloud-ml-data/NL-classification/happiness.csv\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_dataset:text,tcn"
},
"source": [
"### Create the Dataset\n",
"### Create a Text Dataset\n",
"\n",
"Next, create the `Dataset` resource using the `create` method for the `TextDataset` class, which takes the following parameters:\n",
"\n",
@@ -698,6 +736,17 @@
"Learn more about [TextDataset](https://cloud.google.com/vertex-ai/docs/datasets/prepare-text)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:happydb,csv,tcn"
},
"outputs": [],
"source": [
"IMPORT_FILE = \"gs://cloud-ml-data/NL-classification/happiness.csv\""
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -715,6 +764,24 @@
"print(dataset.resource_name)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_dataset:tabular,bq,lrg,v2"
},
"source": [
"### Create a Tabular Dataset\n",
"\n",
"#### CSV input data\n",
"\n",
"Next, create the `Dataset` resource using the `create` method for the `TabularDataset` class for CSV input data, which takes the following parameters:\n",
"\n",
"- `display_name`: The human readable name for the `Dataset` resource.\n",
"- `gcs_source`: A list of one or more dataset index files to import the data items into the `Dataset` resource.\n",
"\n",
"Learn more about [TabularDataset from CSV files](https://cloud.google.com/vertex-ai/docs/datasets/create-dataset-api#aiplatform_create_dataset_tabular_gcs_sample-python)"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -723,27 +790,50 @@
},
"outputs": [],
"source": [
"IMPORT_FILE = \"bq://bigquery-public-data.samples.gsod\"\n",
"BQ_TABLE = \"bigquery-public-data.samples.gsod\""
"IMPORT_FILE = \"gs://cloud-samples-data/tables/iris_1000.csv\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_dataset:tabular,bq,lrg,v2"
},
"outputs": [],
"source": [
"dataset = aip.TabularDataset.create(\n",
" display_name=\"example\" + \"_\" + TIMESTAMP, gcs_source=[IMPORT_FILE]\n",
")\n",
"\n",
"print(dataset.resource_name)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_dataset:tabular,bq,lrg,v2"
"id": "854dd1e0195c"
},
"source": [
"### Create the Dataset\n",
"#### BigQuery input data\n",
"\n",
"#### CSV input data\n",
"\n",
"Next, create the `Dataset` resource using the `create` method for the `TabularDataset` class, which takes the following parameters:\n",
"Next, create the `Dataset` resource using the `create` method for the `TabularDataset` class for BigQuery table input, which takes the following parameters:\n",
"\n",
"- `display_name`: The human readable name for the `Dataset` resource.\n",
"- `gcs_source`: A list of one or more dataset index files to import the data items into the `Dataset` resource.\n",
"- `labels`: User defined metadata. In this example, you store the location of the Cloud Storage bucket containing the user defined data.\n",
"- `bq_source`: A list of one or more BigQuery tables to import the data items into the `Dataset` resource.\n",
"\n",
"Learn more about [TabularDataset from CSV files](https://cloud.google.com/vertex-ai/docs/datasets/create-dataset-api#aiplatform_create_dataset_tabular_gcs_sample-python)"
"Learn more about [TabularDataset from BigQuery table](https://cloud.google.com/vertex-ai/docs/datasets/create-dataset-api#aiplatform_create_dataset_tabular_bigquery_sample-pythonn)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "86343c146300"
},
"outputs": [],
"source": [
"IMPORT_FILE = \"bq://bigquery-public-data.samples.gsod\"\n",
"BQ_TABLE = \"bigquery-public-data.samples.gsod\""
]
},
{
@@ -761,15 +851,63 @@
"print(dataset.resource_name)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "82e9fe20ce71"
},
"source": [
"#### Dataframe input data\n",
"\n",
"Next, create the `Dataset` resource using the `create_from_dataframe` method for the `TabularDataset` class for pandas dataframe input, which takes the following parameters:\n",
"\n",
"- `display_name`: The human readable name for the `Dataset` resource.\n",
"- `df_source`: The pandas dataframe to import the data items into the `Dataset` resource.\n",
"- `staging_path`: The BigQuery table to store the imported data."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:covid,csv,forecast"
"id": "3805f945ffdd"
},
"outputs": [],
"source": [
"IMPORT_FILE = \"gs://cloud-samples-data/ai-platform/covid/bigquery-public-covid-nyt-us-counties-train.csv\""
"# Download the table.\n",
"table = bigquery.TableReference.from_string(BQ_TABLE)\n",
"\n",
"rows = bqclient.list_rows(\n",
" table,\n",
" max_results=10000,\n",
" selected_fields=[\n",
" bigquery.SchemaField(\"station_number\", \"STRING\"),\n",
" bigquery.SchemaField(\"year\", \"INTEGER\"),\n",
" bigquery.SchemaField(\"month\", \"INTEGER\"),\n",
" bigquery.SchemaField(\"day\", \"INTEGER\"),\n",
" bigquery.SchemaField(\"mean_temp\", \"FLOAT\"),\n",
" ],\n",
")\n",
"\n",
"dataframe = rows.to_dataframe()\n",
"print(dataframe.head())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_dataset:tabular,bq,lrg,v2"
},
"outputs": [],
"source": [
"dataset = aip.TabularDataset.create_from_dataframe(\n",
" display_name=\"example\" + \"_\" + TIMESTAMP,\n",
" df_source=dataframe,\n",
" staging_path=f\"bq://{PROJECT_ID}.samples.gsod\",\n",
")\n",
"\n",
"print(dataset.resource_name)"
]
},
{
@@ -778,7 +916,7 @@
"id": "create_dataset:tabular,forecast,v2"
},
"source": [
"### Create the Dataset\n",
"### Create a Time Series Dataset\n",
"\n",
"Next, create the `Dataset` resource using the `create` method for the `TimeSeriesDataset` class, which takes the following parameters:\n",
"\n",
@@ -789,6 +927,17 @@
"Learn more about [TimeSeriesDataset](https://cloud.google.com/vertex-ai/docs/datasets/prepare-tabular)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:covid,csv,forecast"
},
"outputs": [],
"source": [
"IMPORT_FILE = \"gs://cloud-samples-data/ai-platform/covid/bigquery-public-covid-nyt-us-counties-train.csv\""
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -1149,9 +1298,9 @@
"comps = BQ_TABLE.split(\".\")\n",
"BQ_PROJECT_DATASET_TABLE = comps[0] + \":\" + comps[1] + \".\" + comps[2]\n",
"\n",
"! bq --location=us extract --destination_format CSV $BQ_PROJECT_DATASET_TABLE $BUCKET_NAME/mydata*.csv\n",
"! bq --location=us extract --destination_format CSV $BQ_PROJECT_DATASET_TABLE $BUCKET_URI/mydata*.csv\n",
"\n",
"IMPORT_FILES = ! gsutil ls $BUCKET_NAME/mydata*.csv\n",
"IMPORT_FILES = ! gsutil ls $BUCKET_URI/mydata*.csv\n",
"\n",
"print(IMPORT_FILES)\n",
"\n",
@@ -1209,6 +1358,38 @@
"To create a dataframe from multiple CSV sources, you read each CSV file and concatenate the dataframes together."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bcd2e4e0703b"
},
"source": [
"If you are running this notebook on Colab, run the following cell to install packages fsspec and gcsfs."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "927bd3f92268"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Workbench AI Notebook, then don't execute this code\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\"):\n",
" if \"google.colab\" in sys.modules:\n",
" ! pip3 install fsspec\n",
" ! pip3 install gcsfs"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -1269,7 +1450,7 @@
},
"outputs": [],
"source": [
"EXPORTED_DIR = f\"{BUCKET_NAME}/exported\"\n",
"EXPORTED_DIR = f\"{BUCKET_URI}/exported\"\n",
"exported_files = dataset.export_data(output_dir=EXPORTED_DIR)\n",
"\n",
"! gsutil ls $EXPORTED_DIR"
@@ -1498,7 +1679,7 @@
" data = f.readlines()\n",
"\n",
"# The path to the TFRecord cached file.\n",
"GCS_TFRECORD_URI = BUCKET_NAME + \"/flowers.tfrecord\"\n",
"GCS_TFRECORD_URI = BUCKET_URI + \"/flowers.tfrecord\"\n",
"\n",
"# Create the TFRecord cached file\n",
"with tf.io.TFRecordWriter(GCS_TFRECORD_URI) as writer:\n",
@@ -1532,14 +1713,7 @@
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
"- Bucket"
]
},
{
@@ -1550,61 +1724,16 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"delete_bucket = False\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"# Delete the dataset using the Vertex dataset object\n",
"datasets = aip.TabularDataset.list(filter=f'display_name=\"example_{TIMESTAMP}\"')\n",
"for dataset in datasets:\n",
" dataset.delete()\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"# Delete the bucket\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
File diff suppressed because it is too large Load Diff
@@ -39,8 +39,14 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/mlops_data_management.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/mlops_data_management.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\\\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage1/mlops_data_management.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -59,17 +65,6 @@
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 1 : data management."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:bq,chicago,lbn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Chicago Taxi](https://www.kaggle.com/chicago/chicago-taxi-trips-bq). The version of the dataset you will use in this tutorial is stored in a public BigQuery table. The trained model predicts whether someone would leave a tip for a taxi fare."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -114,6 +109,34 @@
" - Preprocess the data with `Dataflow`"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:bq,chicago,lbn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Chicago Taxi](https://www.kaggle.com/chicago/chicago-taxi-trips-bq). The version of the dataset used in this tutorial is stored in a public BigQuery table. The trained model predicts whether someone leaves a tip for a taxi fare."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9e483012a752"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"- Cloud Storage\n",
"- BigQuery\n",
"- Dataflow\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing), [Cloud Storage pricing](https://cloud.google.com/storage/pricing), [BigQuery pricing](https://cloud.google.com/bigquery/pricing), and [Dataflow pricing](https://cloud.google.com/dataflow/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -133,20 +156,34 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"ONCE_ONLY = True\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
" ! pip3 install -U tensorflow==2.5 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG -q\n",
" ! pip3 install --upgrade apache-beam[gcp]==2.33.0 $USER_FLAG -q\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG -q\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG -q\n",
" ! pip3 install --upgrade kfp $USER_FLAG -q\n",
" ! pip3 install future $USER_FLAG -q"
]
},
{
@@ -178,6 +215,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -254,7 +317,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -281,6 +347,66 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -309,7 +435,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -320,8 +447,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -341,7 +469,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -361,7 +489,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -516,7 +644,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -538,7 +666,7 @@
},
"outputs": [],
"source": [
"bqclient = bigquery.Client()"
"bqclient = bigquery.Client(project=PROJECT_ID)"
]
},
{
@@ -661,6 +789,11 @@
"LIMIT = 300000\n",
"YEAR = 2020\n",
"\n",
"# First, create the dataset entry\n",
"dataset = bigquery.Dataset(f\"{PROJECT_ID}.{BQ_DATASET}\")\n",
"dataset.location = \"US\"\n",
"dataset = bqclient.create_dataset(dataset, timeout=30)\n",
"\n",
"query = f\"\"\"\n",
"CREATE OR REPLACE TABLE `{BQ_TABLE_COPY}`\n",
"AS (\n",
@@ -757,7 +890,7 @@
"dataset = aip.TabularDataset.create(\n",
" display_name=\"Chicago Taxi\" + \"_\" + TIMESTAMP,\n",
" bq_source=[IMPORT_FILE],\n",
" labels={\"user_metadata\": BUCKET_NAME[5:]},\n",
" labels={\"user_metadata\": BUCKET_NAME},\n",
")\n",
"\n",
"label_column = \"tip_bin\"\n",
@@ -949,9 +1082,9 @@
},
"outputs": [],
"source": [
"STATISTICS_SCHEMA = BUCKET_NAME + \"/statistics.jsonl\"\n",
"STATISTICS_SCHEMA = BUCKET_URI + \"/statistics.jsonl\"\n",
"\n",
"tfdv.write_stats_text(stats, BUCKET_NAME + \"/statistics.jsonl\")\n",
"tfdv.write_stats_text(stats, BUCKET_URI + \"/statistics.jsonl\")\n",
"\n",
"with tf.io.gfile.GFile(\n",
" \"gs://\" + dataset.labels[\"user_metadata\"] + \"/metadata.jsonl\", \"r\"\n",
@@ -964,7 +1097,7 @@
") as f:\n",
" json.dump(metadata, f)\n",
"\n",
"!gsutil cat $BUCKET_NAME/metadata.jsonl"
"! gsutil cat $BUCKET_URI/metadata.jsonl"
]
},
{
@@ -1011,7 +1144,7 @@
},
"outputs": [],
"source": [
"SCHEMA_LOCATION = BUCKET_NAME + \"/schema.txt\"\n",
"SCHEMA_LOCATION = BUCKET_URI + \"/schema.txt\"\n",
"\n",
"# When running Apache Beam directly (file is directly accessed)\n",
"tfdv.write_schema_text(output_path=SCHEMA_LOCATION, schema=schema)\n",
@@ -1049,7 +1182,7 @@
") as f:\n",
" json.dump(metadata, f)\n",
"\n",
"!gsutil cat $BUCKET_NAME/metadata.jsonl"
"! gsutil cat $BUCKET_URI/metadata.jsonl"
]
},
{
@@ -1101,7 +1234,7 @@
"import setuptools\n",
"\n",
"REQUIRED_PACKAGES = [\n",
" \"google-cloud-aiplatform==1.4.2\",\n",
" \"google-cloud-aiplatform\",\n",
" \"tensorflow-transform==1.2.0\",\n",
" \"tensorflow-data-validation==1.2.0\",\n",
"]\n",
@@ -1372,10 +1505,10 @@
" )\n",
"\n",
"\n",
"EXPORTED_JSONL_PREFIX = os.path.join(BUCKET_NAME, \"exported_data/jsonl\")\n",
"EXPORTED_TFREC_PREFIX = os.path.join(BUCKET_NAME, \"exported_data/tfrec\")\n",
"TRANSFORMED_DATA_PREFIX = os.path.join(BUCKET_NAME, \"transformed_data\")\n",
"TRANSFORM_ARTIFACTS_DIR = os.path.join(BUCKET_NAME, \"transformed_artifacts\")\n",
"EXPORTED_JSONL_PREFIX = os.path.join(BUCKET_URI, \"exported_data/jsonl\")\n",
"EXPORTED_TFREC_PREFIX = os.path.join(BUCKET_URI, \"exported_data/tfrec\")\n",
"TRANSFORMED_DATA_PREFIX = os.path.join(BUCKET_URI, \"transformed_data\")\n",
"TRANSFORM_ARTIFACTS_DIR = os.path.join(BUCKET_URI, \"transformed_artifacts\")\n",
"\n",
"QUERY_STRING = \"SELECT * FROM {} LIMIT 300000\".format(BQ_TABLE)\n",
"JOB_NAME = \"chicago\" + TIMESTAMP\n",
@@ -1388,7 +1521,7 @@
" \"transform_artifact_dir\": TRANSFORM_ARTIFACTS_DIR,\n",
" \"exported_jsonl_prefix\": EXPORTED_JSONL_PREFIX,\n",
" \"exported_tfrec_prefix\": EXPORTED_TFREC_PREFIX,\n",
" \"temp_location\": os.path.join(BUCKET_NAME, \"temp\"),\n",
" \"temp_location\": os.path.join(BUCKET_URI, \"temp\"),\n",
" \"project\": PROJECT_ID,\n",
" \"region\": REGION,\n",
" \"setup_file\": \"./setup.py\",\n",
@@ -1459,7 +1592,7 @@
") as f:\n",
" json.dump(metadata, f)\n",
"\n",
"!gsutil cat $BUCKET_NAME/metadata.jsonl"
"! gsutil cat $BUCKET_URI/metadata.jsonl"
]
},
{
@@ -1473,17 +1606,9 @@
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"Otherwise, you can delete the individual resources you created in this tutorial.\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
"*Note:* stage2/mlops_experimentation is dependent on the resources created by this stage1 notebook."
]
},
{
@@ -1504,8 +1629,8 @@
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
" if \"BUCKET_URI\" in globals():\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

+198 -93
View File
@@ -25,85 +25,154 @@ The second stage in MLOps is experimenting in developing one or more baseline mo
- Use the What-if-Tool (WIT) to explore how the trained model would make predictions in different scenarios.
<img src='stage2.png'>
<img src='stage2v3.png'>
<br/>
<br/>
<br/>
<img src='stage2.2v1.png'>
## Notebooks
### Get Started
[Get Started with Vertex Experiments and Vertex ML Metadata](get_started_vertex_experiments.ipynb)
[Get started with Vertex AI Training for Pytorch](get_started_vertex_training_pytorch.ipynb)
```
The steps performed include:
- Use Python logging to log training configuration/results locally.
- Use Google Cloud Logging to log training configuration/results in cloud storage.
- Create a Vertex AI `Experiment` resource.
- Instantiate an experiment run.
- Log parameters for the run.
- Log metrics for the run.
- Display the logged experiment run.
```
[Get Started with Vertex TensorBoard](get_started_vertex_tensorboard.ipynb)
```
The steps performed include:
- Create a TensorBoard callback when training a model.
- Using Tensorboard with locally trained model.
- Using Vertex AI TensorBoard with Vertex AI Training.
```
[Get Started with Custom Training Packages (Tensorflow)](get_started_vertex_training.ipynb)
```
The steps performed include:
- Training using a single Python script.
- Training using a Python package.
- Training using a custom training image.
- Laying out a training package.
```
[Get Started with Custom Training Packages (Scikit-Learn)](get_started_vertex_training_sklearn.ipynb)
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get Started with Custom Training Packages (XGBoost)](get_started_vertex_training_xgboost.ipynb)
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get Started with Custom Training Packages (Pytorch)](get_started_vertex_training_pytorch.ipynb)
```
The steps performed include:
- Single node training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get Started with Custom Training Packages (R)](get_started_vertex_training_r.ipynb)
[Get started with prebuilt TFHub models](get_started_with_tfhub_models.ipynb)
```
The steps performed include:
- Download a TensorFlow Hub prebuilt model.
- Add the task component as a classifier for the CIFAR-10 dataset.
- Fine tune locally the model with transfer learning training.
- Construct a custom training script:
- Get training data from TensorFlow Datasets
- Get model architecture from TensorFlow Hub
- Train then model
- Save model artifacts and upload as Vertex AI Model resource.
```
[Get started with Vertex AI TensorBoard](get_started_vertex_tensorboard.ipynb)
```
The steps performed include:
- Create a TensorBoard callback when training a model.
- Using Tensorboard with locally trained model.
- Using Vertex AI TensorBoard with Vertex AI Training.
```
[Get started with TabNet builtin algorithm for training tabular models](get_started_with_tabnet.ipynb)
```
The steps performed include:
- Get the training data.
- Configure training parameters for the `Vertex AI TabNet` container.
- Train the model using `Vertex AI Training` using CSV data.
- Upload the model as a `Vertex AI Model` resource.
- Deploy the `Vertex AI Model` resource to a `Vertex AI Endpoint` resource.
- Make a prediction with the deployed model.
- Hyperparameter tuning the `Vertex AI TabNet` model.
- Train the model using `Vertex AI Training` using BigQuery table.
```
[Get started with Vertex AI Vizier](get_started_vertex_vizier.ipynb)
```
The steps performed include:
- Hyperparameter tuning with Random algorithm.
- Hyperparameter tuning with Vizier (Bayesian) algorithm.
```
[Automl image classfication training with customer managed encryption keys (CMEK)](get_started_with_cmek_training.ipynb)
```
The steps performed include:
- Creating a customer managed encryption key.
- Creating an image dataset with CMEK encryption.
- Train an AutoML model with CMEK encryption.
```
[Get started with Vertex AI distributed training](get_started_vertex_distributed_training.ipynb)
```
The steps performed include:
- `MirroredStrategy`: Train on a single VM with multiple GPUs.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with automatic setup of replicas.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with fine grain control of replicas.
- `ReductionServer`: Train on multiple VMS and sync updates across VMS with `Vertex AI Reduction Server`.
- `TPUTraining`: Train with multiple Cloud TPUs.
```
[Get started with Vertex AI Training for scikit-learn](get_started_vertex_training_sklearn.ipynb)
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Experiments](get_started_vertex_experiments.ipynb)
```
The steps performed include:
- Local (notebook) Training
- Create an experiment
- Create a first run in the experiment
- Log parameters and metrics
- Create artifact lineage
- Visualize the experiment results
- Execute a second run
- Compare the two runs in the experiment
- Cloud (`Vertex AI`) Training
- Within the training script:
- Create an experiment
- Log parameters and metrics
- Create artifact lineage
- Create a `Vertex AI Training` custom job
- Execute the custom job
- Visualize the experiment results
```
[Get started with Vertex AI Hyperparameter Tuning for XGBoost](get_started_vertex_hpt_xgboost.ipynb)
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Feature Store](get_started_vertex_feature_store.ipynb)
```
The steps performed include:
- Creating a Vertex AI `Featurestore` resource.
- Creating `EntityType` resources for the `Featurestore` resource.
- Creating `Feature` resources for each `EntityType` resource.
- Import feature values (entity data items) into `Featurestore` resource.
- From a Cloud Storage location.
- From a pandas DataFrame.
- Perform online serving from a `Featurestore` resource.
- Perform batch serving from a `Featurestore` resource.
```
[Get started with Vertex AI Training for R](get_started_vertex_training_r.ipynb)
```
The steps performed include:
- Locally train an R model in a notebook using %%R magic commands
- Create a deployment image with trained R model and serving functions.
- Test the deployment image locally.
@@ -115,63 +184,100 @@ The steps performed include:
- Train a R model using `Vertex AI Trainingh` service with the R-to-Python training package.
```
[Get Started with Distributed Training](get_started_vertex_distributed_training.ipynb)
[Get started with logging](get_started_with_logging.ipynb)
```
The steps performed include:
- `MirroredStrategy`: Train on a single VM with multiple GPUs.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with automatic setup of replicas.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with fine grain control of replicas.
- `ReductionServer`: Train on multiple VMS and sync updates across VMS with `Vertex AI Reduction Server`.
- `TPUTraining`: Train with multiple Cloud TPUs.
- Use Python logging to log training configuration/results locally.
- Use Google Cloud Logging to log training configuration/results in cloud storage.
```
[Get Started with Vizier Hyperparameter Tuning](get_started_vertex_vizier.ipynb)
[Get started with Vertex AI Training for R using R Kernel](get_started_vertex_training_r_using_r_kernel.ipynb)
```
The steps performed include:
- Create a custom R training script
- Create a custom R serving script
- Create a custom R deployment (serving) container.
- Train the model using `Vertex AI` custom training.
- Create an `Endpoint` resouce.
- Deploy the `Model` resource (trained R model) to the `Endpoint` resource.
- Make an online prediction.
- Hyperparameter tuning with Random algorithm.
- Hyperparameter tuning with Vizier (Bayesian) algorithm.
```
[Get Started with AutoML Training](get_started_automl_training.ipynb)
[Get started with BigQuery ML training](get_started_bqml_training.ipynb)
```
The steps performed include:
- Create a local BigQuery table in your project
- Train a BQML model
- Evaluate the BQML model
- Export the BQML model as a cloud model
- Upload the exported model as a `Vertex AI Model` resource
- Hyperparameter tune a BQML model with `Vertex AI Vizier`
- Automatically register a BQML model to `Vertex AI Model Registry`
- Train an image model.
- Export the image model as an edge model.
- Train a tabular model.
- Export the tabular model as a cloud model.
- Train a text model.
```
[Get Started with BQML Training](get_started_bqml_training.ipynb)
[Get started with AutoML training](get_started_automl_training.ipynb)
```
The steps performed include:
- Create a local BQ table in your project.
- Train a BQML model.
- Evaluate the BQML model.
- Export the BQML model as a cloud model.
- Upload the exported model as a Vertex AI Model resource.
- Hyperparameter tune a BQML model with Vertex AI Vizier.
- Train an image model
- Export the image model as an edge model
- Train a tabular model
- Export the tabular model as a cloud model
- Train a text model
- Train a video model
```
[Get Started with Vertex Feature Store](get_started_vertex_feature_store.ipynb)
[Get started with Vertex AI Training for XGBoost](get_started_vertex_training_xgboost.ipynb)
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
- Creating a Vertex AI `Featurestore` resource.
- Creating `EntityType` resources for the `Featurestore` resource.
- Creating `Feature` resources for each `EntityType` resource.
- Import feature values (entity data items) into `Featurestore` resource.
- Perform online serving from a `Featurestore` resource.
- Perform batch serving from a `Featurestore` resource.
```
[Get started with Vertex AI Training](get_started_vertex_training.ipynb)
```
The steps performed include:
- Training using a single Python script.
- Training using a Python package.
- Training using a custom training image.
- Laying out a training package.
```
[Get started with Vertex AI Training for LightGBM](get_started_vertex_training_lightgbm.ipynb)
```
The steps performed include:
- Training using a Python package.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Construct a FastAPI prediction server.
- Construct a Dockerfile deployment image.
- Test the deployment image locally.
- Create a `Vertex AI Model` resource.
```
[Get started Vision API test preprocessing and AutoML text model generation](get_started_with_visionapi_and_automl.ipynb)
```
The steps performed include:
- Preprocess training files using `Vision AI` APIs to extract the text from PDF files.
- Create a custom import file that includes annotation data based on the sample `BigQuery` dataset.
- Create a `Vertex AI Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Vertex AI Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
```
### E2E Stage Example
@@ -180,7 +286,6 @@ The steps performed include:
```
The steps performed include:
- Review the `Dataset` resource created during stage 1.
- Train an AutoML tabular binary classifier model in the background.
- Build the experimental model architecture.
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -39,8 +39,14 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_automl_training.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_automl_training.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_automl_training.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -59,39 +65,6 @@
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with AutoML Training."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:flowers,icn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Flowers dataset](https://www.tensorflow.org/datasets/catalog/tf_flowers) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of flower an image is from a class of five flowers: daisy, dandelion, rose, sunflower, or tulip."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:gsod,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset you use only the fields year, month and day to predict the value of mean daily temperature (mean_temp)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:happydb,tcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Happy Moments dataset](https://www.kaggle.com/ritresearch/happydb) from [Kaggle Datasets](https://www.kaggle.com/ritresearch/happydb). The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -108,11 +81,12 @@
"\n",
"The steps performed include:\n",
"\n",
"- Train an image model.\n",
"- Export the image model as an edge model.\n",
"- Train a tabular model.\n",
"- Export the tabular model as a cloud model.\n",
"- Train a text model."
"- Train an image model\n",
"- Export the image model as an edge model\n",
"- Train a tabular model\n",
"- Export the tabular model as a cloud model\n",
"- Train a text model\n",
"- Train a video model"
]
},
{
@@ -125,9 +99,49 @@
"\n",
"When doing E2E MLOps on Google Cloud, the following are best practices for when to use AutoML:\n",
"\n",
"**You have a limited amount of training data**\n",
"* **You have a limited amount of training data**\n",
"\n",
"**You want to establish a baseline metric before experimenting with a custom model**"
"* **You want to establish a baseline metric before experimenting with a custom model**"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:flowers,icn"
},
"source": [
"### Datasets\n",
"\n",
"#### Image\n",
"\n",
"The image dataset used for this tutorial is the [Flowers dataset](https://www.tensorflow.org/datasets/catalog/tf_flowers) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). The version of the dataset in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of flower in a given image from a class of five flowers: daisy, dandelion, rose, sunflower, or tulip.\n",
"\n",
"#### Tabular\n",
"\n",
"The tabular dataset used for this tutorial is the GSOD dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset you use only the fields year, month and day to predict the value of mean daily temperature (mean_temp).\n",
"\n",
"#### Text\n",
"\n",
"The text dataset used for this tutorial is the [Happy Moments dataset](https://www.kaggle.com/ritresearch/happydb) from [Kaggle Datasets](https://www.kaggle.com/ritresearch/happydb). The version of the dataset you use in this tutorial is stored in a public Cloud Storage bucket.\n",
"\n",
"#### Video\n",
"\n",
"The video dataset used for this tutorial is the golf swing recognition portion of the [Human Motion dataset](https://todo) from [MIT](http://cbcl.mit.edu/publications/ps/Kuehne_etal_iccv11.pdf). The version of the dataset you use in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the start frame where a golf swing begins."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "fb3451ce8e47"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"- Cloud Storage\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage pricing](https://cloud.google.com/storage/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
@@ -138,7 +152,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the packages required for executing this notebook."
]
},
{
@@ -149,20 +163,23 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"# Install the packages\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-storage $USER_FLAG -q"
]
},
{
@@ -199,6 +216,32 @@
"metadata": {
"id": "project_id"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5aee4379e8e5"
},
"source": [
"#### Set your project ID\n",
"\n",
@@ -270,7 +313,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -297,6 +343,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3ffa6b6c7cdb"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2b72272258fc"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -320,7 +427,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -331,8 +439,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -352,7 +461,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -372,7 +481,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -395,7 +504,7 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
"import google.cloud.aiplatform as aiplatform"
]
},
{
@@ -417,7 +526,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aiplatform.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -448,7 +557,7 @@
"source": [
"## AutoML image models\n",
"\n",
"AutoML can train the following types of models:\n",
"AutoML can train the following types of image models:\n",
"\n",
"- classification\n",
"- objection detection\n",
@@ -504,10 +613,7 @@
},
"outputs": [],
"source": [
"if \"IMPORT_FILES\" in globals():\n",
" FILE = IMPORT_FILES[0]\n",
"else:\n",
" FILE = IMPORT_FILE\n",
"FILE = IMPORT_FILE\n",
"\n",
"count = ! gsutil cat $FILE | wc -l\n",
"print(\"Number of Examples\", int(count[0]))\n",
@@ -545,10 +651,10 @@
},
"outputs": [],
"source": [
"dataset = aip.ImageDataset.create(\n",
" display_name=\"Happy Moments\" + \"_\" + TIMESTAMP,\n",
"dataset = aiplatform.ImageDataset.create(\n",
" display_name=\"flowers_\" + TIMESTAMP,\n",
" gcs_source=[IMPORT_FILE],\n",
" import_schema_uri=aip.schema.dataset.ioformat.image.single_label_classification,\n",
" import_schema_uri=aiplatform.schema.dataset.ioformat.image.single_label_classification,\n",
")\n",
"\n",
"print(dataset.resource_name)"
@@ -593,8 +699,8 @@
},
"outputs": [],
"source": [
"dag = aip.AutoMLImageTrainingJob(\n",
" display_name=\"happydb_\" + TIMESTAMP,\n",
"dag = aiplatform.AutoMLImageTrainingJob(\n",
" display_name=\"flowers_\" + TIMESTAMP,\n",
" prediction_type=\"classification\",\n",
" multi_label=False,\n",
" model_type=\"MOBILE_TF_LOW_LATENCY_1\",\n",
@@ -612,14 +718,14 @@
"source": [
"#### Run the training pipeline\n",
"\n",
"Next, you run the DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"Next, you run the created DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"\n",
"- `dataset`: The `Dataset` resource to train the model.\n",
"- `model_display_name`: The human readable name for the trained model.\n",
"- `training_fraction_split`: The percentage of the dataset to use for training.\n",
"- `test_fraction_split`: The percentage of the dataset to use for test (holdout data).\n",
"- `validation_fraction_split`: The percentage of the dataset to use for validation.\n",
"- `budget_milli_node_hours`: (optional) Maximum training time specified in unit of millihours (1000 = hour).\n",
"- `budget_milli_node_hours`: (optional) Maximum training time specified in unit of milli node-hours (1000 = node-hour).\n",
"- `disable_early_stopping`: If `True`, training maybe completed before using the entire budget if the service believes it cannot further improve on the model objective measurements.\n",
"\n",
"The `run` method when completed returns the `Model` resource.\n",
@@ -637,7 +743,7 @@
"source": [
"model = dag.run(\n",
" dataset=dataset,\n",
" model_display_name=\"happydb_\" + TIMESTAMP,\n",
" model_display_name=\"flowers_\" + TIMESTAMP,\n",
" training_fraction_split=0.8,\n",
" validation_fraction_split=0.1,\n",
" test_fraction_split=0.1,\n",
@@ -653,9 +759,8 @@
},
"source": [
"## Review model evaluation scores\n",
"After your model has finished training, you can review the evaluation scores for it.\n",
"\n",
"First, you need to get a reference to the new model. As with datasets, you can either use the reference to the model variable you created when you deployed the model or you can list all of the models in your project."
"After your model training has finished, you can review the evaluation scores for it using the `list_model_evaluations()` method. This method will return an iterator for each evaluation slice."
]
},
{
@@ -666,18 +771,10 @@
},
"outputs": [],
"source": [
"# Get model resource ID\n",
"models = aip.Model.list(filter=\"display_name=happydb_\" + TIMESTAMP)\n",
"model_evaluations = model.list_model_evaluations()\n",
"\n",
"# Get a reference to the Model Service client\n",
"client_options = {\"api_endpoint\": f\"{REGION}-aiplatform.googleapis.com\"}\n",
"model_service_client = aip.gapic.ModelServiceClient(client_options=client_options)\n",
"\n",
"model_evaluations = model_service_client.list_model_evaluations(\n",
" parent=models[0].resource_name\n",
")\n",
"model_evaluation = list(model_evaluations)[0]\n",
"print(model_evaluation)"
"for model_evaluation in model_evaluations:\n",
" print(model_evaluation.to_dict())"
]
},
{
@@ -721,7 +818,7 @@
"source": [
"### Get test item\n",
"\n",
"You will use an arbitrary example out of the dataset as a test item. Don't be concerned that the example was likely used in training the model -- we just want to demonstrate how to make a prediction."
"You will use an arbitrary example out of the dataset as a test item. Don't be concerned that the example was likely used in training the model. You are just looking at how to make a prediction."
]
},
{
@@ -753,7 +850,7 @@
"\n",
"#### Request\n",
"\n",
"Since in this example your test item is in a Cloud Storage bucket, you open and read the contents of the image using `tf.io.gfile.Gfile()`. To pass the test data to the prediction service, you encode the bytes into base64 -- which makes the content safe from modification while transmitting binary data over the network.\n",
"Since your test item is in a public Cloud Storage bucket in this example, you copy it to your bucket and read the contents of the image using `Cloud Storage SDK`. To pass the test data to the prediction service, you encode the bytes into base64 which makes the content safe from modification while transmitting binary data over the network.\n",
"\n",
"The format of each instance is:\n",
"\n",
@@ -775,32 +872,66 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "predict_request:mbsdk,icn"
"id": "1c1d53e89beb"
},
"outputs": [],
"source": [
"import base64\n",
"\n",
"import tensorflow as tf\n",
"from google.cloud import storage\n",
"\n",
"with tf.io.gfile.GFile(test_item, \"rb\") as f:\n",
" content = f.read()\n",
"# Copy the test image to the Cloud storage bucket as \"test.jpg\"\n",
"test_image_local = \"{}/test.jpg\".format(BUCKET_URI)\n",
"! gsutil cp $test_item $test_image_local\n",
"\n",
"# Download the test image in bytes format\n",
"storage_client = storage.Client(project=PROJECT_ID)\n",
"bucket = storage_client.bucket(bucket_name=BUCKET_NAME)\n",
"test_content = bucket.get_blob(\"test.jpg\").download_as_bytes()\n",
"\n",
"# The format of each instance should conform to the deployed model's prediction input schema.\n",
"instances = [{\"content\": base64.b64encode(content).decode(\"utf-8\")}]\n",
"instances = [{\"content\": base64.b64encode(test_content).decode(\"utf-8\")}]\n",
"\n",
"prediction = endpoint.predict(instances=instances)\n",
"\n",
"print(prediction)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3b1b67898533"
},
"source": [
"#### Alternate method using [GFile](https://www.tensorflow.org/api_docs/python/tf/io/gfile/GFile)\n",
"\n",
"Alternatively, [GFile](https://www.tensorflow.org/api_docs/python/tf/io/gfile/GFile) method from tensorflow-io library can be used to read the data from Cloud storage directly. The following code snippet does the same :\n",
"\n",
"```\n",
"import base64\n",
"import tensorflow as tf\n",
"\n",
"# Read the test file using GFile\n",
"with tf.io.gfile.GFile(test_item, \"rb\") as f:\n",
" content = f.read()\n",
"\n",
"# The format of each instance should conform to the deployed model's prediction input schema.\n",
"instances = [{\"content\": base64.b64encode(content).decode(\"utf-8\")}]\n",
"\n",
"prediction = endpoint.predict(instances=instances)\n",
"\n",
"print(prediction)\n",
"```\n",
"Nevertheless, `tf.io.gfile.GFile` supports multiple file system implementations, including local files, Google Cloud Storage (using a gs:// prefix), and HDFS (using an hdfs:// prefix)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "undeploy_model:mbsdk"
},
"source": [
"## Undeploy the model\n",
"#### Undeploy the model\n",
"\n",
"When you are done doing predictions, you undeploy the model from the `Endpoint` resouce. This deprovisions all compute resources and ends billing for the deployed model."
]
@@ -846,7 +977,7 @@
"outputs": [],
"source": [
"response = model.export_model(\n",
" artifact_destination=BUCKET_NAME, export_format_id=\"tflite\", sync=True\n",
" artifact_destination=BUCKET_URI, export_format_id=\"tflite\", sync=True\n",
")\n",
"\n",
"model_package = response[\"artifactOutputUri\"]"
@@ -987,10 +1118,10 @@
},
"outputs": [],
"source": [
"dataset = aip.TabularDataset.create(\n",
" display_name=\"Happy Moments\" + \"_\" + TIMESTAMP,\n",
"dataset = aiplatform.TabularDataset.create(\n",
" display_name=\"gsod_\" + TIMESTAMP,\n",
" bq_source=[IMPORT_FILE],\n",
" labels={\"user_metadata\": BUCKET_NAME[5:]},\n",
" labels={\"user_metadata\": BUCKET_NAME},\n",
")\n",
"\n",
"label_column = \"mean_temp\"\n",
@@ -1046,9 +1177,7 @@
" - regression:\n",
" - `minimize-rmse`\n",
" - `minimize-mae`\n",
" - `minimize-rmsle`\n",
"\n",
"The instantiated object is the DAG (directed acyclic graph) for the training pipeline."
" - `minimize-rmsle`"
]
},
{
@@ -1059,8 +1188,8 @@
},
"outputs": [],
"source": [
"dag = aip.AutoMLTabularTrainingJob(\n",
" display_name=\"happydb_\" + TIMESTAMP,\n",
"dag = aiplatform.AutoMLTabularTrainingJob(\n",
" display_name=\"gsod_\" + TIMESTAMP,\n",
" optimization_prediction_type=\"regression\",\n",
" optimization_objective=\"minimize-rmse\",\n",
" column_transformations=TRANSFORMATIONS,\n",
@@ -1077,7 +1206,7 @@
"source": [
"#### Run the training pipeline\n",
"\n",
"Next, you run the DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"Next, you run the created DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"\n",
"- `dataset`: The `Dataset` resource to train the model.\n",
"- `model_display_name`: The human readable name for the trained model.\n",
@@ -1103,7 +1232,7 @@
"source": [
"model = dag.run(\n",
" dataset=dataset,\n",
" model_display_name=\"happydb_\" + TIMESTAMP,\n",
" model_display_name=\"gsod_\" + TIMESTAMP,\n",
" training_fraction_split=0.8,\n",
" validation_fraction_split=0.1,\n",
" test_fraction_split=0.1,\n",
@@ -1120,9 +1249,8 @@
},
"source": [
"## Review model evaluation scores\n",
"After your model has finished training, you can review the evaluation scores for it.\n",
"\n",
"First, you need to get a reference to the new model. As with datasets, you can either use the reference to the model variable you created when you deployed the model or you can list all of the models in your project."
"After your model training has finished, you can review the evaluation scores for it using the `list_model_evaluations()` method. This method will return an iterator for each evaluation slice."
]
},
{
@@ -1133,18 +1261,10 @@
},
"outputs": [],
"source": [
"# Get model resource ID\n",
"models = aip.Model.list(filter=\"display_name=happydb_\" + TIMESTAMP)\n",
"model_evaluations = model.list_model_evaluations()\n",
"\n",
"# Get a reference to the Model Service client\n",
"client_options = {\"api_endpoint\": f\"{REGION}-aiplatform.googleapis.com\"}\n",
"model_service_client = aip.gapic.ModelServiceClient(client_options=client_options)\n",
"\n",
"model_evaluations = model_service_client.list_model_evaluations(\n",
" parent=models[0].resource_name\n",
")\n",
"model_evaluation = list(model_evaluations)[0]\n",
"print(model_evaluation)"
"for model_evaluation in model_evaluations:\n",
" print(model_evaluation.to_dict())"
]
},
{
@@ -1177,7 +1297,7 @@
"id": "undeploy_model:mbsdk"
},
"source": [
"## Undeploy the model\n",
"#### Undeploy the model\n",
"\n",
"When you are done doing predictions, you undeploy the model from the `Endpoint` resouce. This deprovisions all compute resources and ends billing for the deployed model."
]
@@ -1218,7 +1338,7 @@
"outputs": [],
"source": [
"response = model.export_model(\n",
" artifact_destination=BUCKET_NAME, export_format_id=\"tf-saved-model\", sync=True\n",
" artifact_destination=BUCKET_URI, export_format_id=\"tf-saved-model\", sync=True\n",
")\n",
"\n",
"model_package = response[\"artifactOutputUri\"]"
@@ -1350,10 +1470,7 @@
},
"outputs": [],
"source": [
"if \"IMPORT_FILES\" in globals():\n",
" FILE = IMPORT_FILES[0]\n",
"else:\n",
" FILE = IMPORT_FILE\n",
"FILE = IMPORT_FILE\n",
"\n",
"count = ! gsutil cat $FILE | wc -l\n",
"print(\"Number of Examples\", int(count[0]))\n",
@@ -1391,10 +1508,10 @@
},
"outputs": [],
"source": [
"dataset = aip.TextDataset.create(\n",
" display_name=\"Happy Moments\" + \"_\" + TIMESTAMP,\n",
"dataset = aiplatform.TextDataset.create(\n",
" display_name=\"happydb_\" + TIMESTAMP,\n",
" gcs_source=[IMPORT_FILE],\n",
" import_schema_uri=aip.schema.dataset.ioformat.text.single_label_classification,\n",
" import_schema_uri=aiplatform.schema.dataset.ioformat.text.single_label_classification,\n",
")\n",
"\n",
"print(dataset.resource_name)"
@@ -1420,9 +1537,7 @@
" - `sentiment`: A text sentiment analysis model.\n",
" - `extraction`: A text entity extraction model.\n",
"- `multi_label`: If a classification task, whether single (False) or multi-labeled (True).\n",
"- `sentiment_max`: If a sentiment analysis task, the maximum sentiment value.\n",
"\n",
"The instantiated object is the DAG (directed acyclic graph) for the training pipeline."
"- `sentiment_max`: If a sentiment analysis task, the maximum sentiment value.\n"
]
},
{
@@ -1433,7 +1548,7 @@
},
"outputs": [],
"source": [
"dag = aip.AutoMLTextTrainingJob(\n",
"dag = aiplatform.AutoMLTextTrainingJob(\n",
" display_name=\"happydb_\" + TIMESTAMP,\n",
" prediction_type=\"classification\",\n",
" multi_label=False,\n",
@@ -1450,7 +1565,7 @@
"source": [
"#### Run the training pipeline\n",
"\n",
"Next, you run the DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"Next, you run the created DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"\n",
"- `dataset`: The `Dataset` resource to train the model.\n",
"- `model_display_name`: The human readable name for the trained model.\n",
@@ -1487,9 +1602,8 @@
},
"source": [
"## Review model evaluation scores\n",
"After your model has finished training, you can review the evaluation scores for it.\n",
"\n",
"First, you need to get a reference to the new model. As with datasets, you can either use the reference to the model variable you created when you deployed the model or you can list all of the models in your project."
"After your model training has finished, you can review the evaluation scores for it using the `list_model_evaluations()` method. This method will return an iterator for each evaluation slice."
]
},
{
@@ -1500,18 +1614,10 @@
},
"outputs": [],
"source": [
"# Get model resource ID\n",
"models = aip.Model.list(filter=\"display_name=happydb_\" + TIMESTAMP)\n",
"model_evaluations = model.list_model_evaluations()\n",
"\n",
"# Get a reference to the Model Service client\n",
"client_options = {\"api_endpoint\": f\"{REGION}-aiplatform.googleapis.com\"}\n",
"model_service_client = aip.gapic.ModelServiceClient(client_options=client_options)\n",
"\n",
"model_evaluations = model_service_client.list_model_evaluations(\n",
" parent=models[0].resource_name\n",
")\n",
"model_evaluation = list(model_evaluations)[0]\n",
"print(model_evaluation)"
"for model_evaluation in model_evaluations:\n",
" print(model_evaluation.to_dict())"
]
},
{
@@ -1542,7 +1648,7 @@
"id": "undeploy_model:mbsdk"
},
"source": [
"## Undeploy the model\n",
"#### Undeploy the model\n",
"\n",
"When you are done doing predictions, you undeploy the model from the `Endpoint` resouce. This deprovisions all compute resources and ends billing for the deployed model."
]
@@ -1686,10 +1792,7 @@
},
"outputs": [],
"source": [
"if \"IMPORT_FILES\" in globals():\n",
" FILE = IMPORT_FILES[0]\n",
"else:\n",
" FILE = IMPORT_FILE\n",
"FILE = IMPORT_FILE\n",
"\n",
"count = ! gsutil cat $FILE | wc -l\n",
"print(\"Number of Examples\", int(count[0]))\n",
@@ -1726,10 +1829,10 @@
},
"outputs": [],
"source": [
"dataset = aip.VideoDataset.create(\n",
" display_name=\"Happy Moments\" + \"_\" + TIMESTAMP,\n",
"dataset = aiplatform.VideoDataset.create(\n",
" display_name=\"human_motion_\" + TIMESTAMP,\n",
" gcs_source=[IMPORT_FILE],\n",
" import_schema_uri=aip.schema.dataset.ioformat.video.classification,\n",
" import_schema_uri=aiplatform.schema.dataset.ioformat.video.classification,\n",
")\n",
"\n",
"print(dataset.resource_name)"
@@ -1753,9 +1856,7 @@
"- `prediction_type`: The type task to train the model for.\n",
" - `classification`: A video classification model.\n",
" - `object_tracking`: A video object tracking model.\n",
" - `action_recognition`: A video action recognition model.\n",
"\n",
"The instantiated object is the DAG (directed acyclic graph) for the training pipeline."
" - `action_recognition`: A video action recognition model."
]
},
{
@@ -1766,8 +1867,8 @@
},
"outputs": [],
"source": [
"dag = aip.AutoMLVideoTrainingJob(\n",
" display_name=\"happydb_\" + TIMESTAMP,\n",
"dag = aiplatform.AutoMLVideoTrainingJob(\n",
" display_name=\"human_motion_\" + TIMESTAMP,\n",
" prediction_type=\"classification\",\n",
")\n",
"\n",
@@ -1782,7 +1883,7 @@
"source": [
"#### Run the training pipeline\n",
"\n",
"Next, you run the DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"Next, you run the created DAG to start the training job by invoking the method `run`, with the following parameters:\n",
"\n",
"- `dataset`: The `Dataset` resource to train the model.\n",
"- `model_display_name`: The human readable name for the trained model.\n",
@@ -1804,7 +1905,7 @@
"source": [
"model = dag.run(\n",
" dataset=dataset,\n",
" model_display_name=\"happydb_\" + TIMESTAMP,\n",
" model_display_name=\"human_motion_\" + TIMESTAMP,\n",
" training_fraction_split=0.8,\n",
" test_fraction_split=0.2,\n",
")"
@@ -1817,9 +1918,8 @@
},
"source": [
"## Review model evaluation scores\n",
"After your model has finished training, you can review the evaluation scores for it.\n",
"\n",
"First, you need to get a reference to the new model. As with datasets, you can either use the reference to the model variable you created when you deployed the model or you can list all of the models in your project."
"After your model training has finished, you can review the evaluation scores for it using the `list_model_evaluations()` method. This method will return an iterator for each evaluation slice."
]
},
{
@@ -1830,18 +1930,10 @@
},
"outputs": [],
"source": [
"# Get model resource ID\n",
"models = aip.Model.list(filter=\"display_name=happydb_\" + TIMESTAMP)\n",
"model_evaluations = model.list_model_evaluations()\n",
"\n",
"# Get a reference to the Model Service client\n",
"client_options = {\"api_endpoint\": f\"{REGION}-aiplatform.googleapis.com\"}\n",
"model_service_client = aip.gapic.ModelServiceClient(client_options=client_options)\n",
"\n",
"model_evaluations = model_service_client.list_model_evaluations(\n",
" parent=models[0].resource_name\n",
")\n",
"model_evaluation = list(model_evaluations)[0]\n",
"print(model_evaluation)"
"for model_evaluation in model_evaluations:\n",
" print(model_evaluation.to_dict())"
]
},
{
@@ -1899,16 +1991,7 @@
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
"Otherwise, you can delete the individual resources you created in this tutorial.\n"
]
},
{
@@ -1919,66 +2002,11 @@
},
"outputs": [],
"source": [
"delete_dataset = True\n",
"delete_pipeline = True\n",
"delete_model = True\n",
"delete_endpoint = True\n",
"delete_batchjob = True\n",
"delete_customjob = True\n",
"delete_hptjob = True\n",
"delete_bucket = True\n",
"# Set this to true only if you'd like to delete your bucket\n",
"delete_bucket = False\n",
"\n",
"# Delete the dataset using the Vertex fully qualified identifier for the dataset\n",
"try:\n",
" if delete_dataset and \"dataset_id\" in globals():\n",
" clients[\"dataset\"].delete_dataset(name=dataset_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the training pipeline using the Vertex fully qualified identifier for the pipeline\n",
"try:\n",
" if delete_pipeline and \"pipeline_id\" in globals():\n",
" clients[\"pipeline\"].delete_training_pipeline(name=pipeline_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the model using the Vertex fully qualified identifier for the model\n",
"try:\n",
" if delete_model and \"model_to_deploy_id\" in globals():\n",
" clients[\"model\"].delete_model(name=model_to_deploy_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the endpoint using the Vertex fully qualified identifier for the endpoint\n",
"try:\n",
" if delete_endpoint and \"endpoint_id\" in globals():\n",
" clients[\"endpoint\"].delete_endpoint(name=endpoint_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the batch job using the Vertex fully qualified identifier for the batch job\n",
"try:\n",
" if delete_batchjob and \"batch_job_id\" in globals():\n",
" clients[\"job\"].delete_batch_prediction_job(name=batch_job_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the custom job using the Vertex fully qualified identifier for the custom job\n",
"try:\n",
" if delete_customjob and \"job_id\" in globals():\n",
" clients[\"job\"].delete_custom_job(name=job_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the hyperparameter tuning job using the Vertex fully qualified identifier for the hyperparameter tuning job\n",
"try:\n",
" if delete_hptjob and \"hpt_job_id\" in globals():\n",
" clients[\"job\"].delete_hyperparameter_tuning_job(name=hpt_job_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"if delete_bucket and \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -38,9 +38,15 @@
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_bqml_training.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_bqml_training.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_bqml_training.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -59,17 +65,6 @@
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with BigQuery ML Training."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:penguins,lcn,bq"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the Penguins dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). The version of the dataset predicts the species."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -84,16 +79,44 @@
"\n",
"- `BigQueryML Training`\n",
"- `Vertex AI Model resource`\n",
"- `Vertex AI Vizier.\n",
"- `Vertex AI Vizier`\n",
"\n",
"The steps performed include:\n",
"\n",
"- Create a local BQ table in your project.\n",
"- Train a BQML model.\n",
"- Evaluate the BQML model.\n",
"- Export the BQML model as a cloud model.\n",
"- Upload the exported model as a Vertex AI Model resource.\n",
"- Hyperparameter tune a BQML model with Vertex AI Vizier."
"- Create a local BigQuery table in your project\n",
"- Train a BQML model\n",
"- Evaluate the BQML model\n",
"- Export the BQML model as a cloud model\n",
"- Upload the exported model as a `Vertex AI Model` resource\n",
"- Hyperparameter tune a BQML model with `Vertex AI Vizier`\n",
"- Automatically register a BQML model to `Vertex AI Model Registry`"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:penguins,lcn,bq"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the Penguins dataset from [BigQuery public datasets](https://cloud.google.com/bigquery/public-data). This version of the dataset is used to predict the species of penguins from the available features like culmen-length, flipper-depth etc."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "81c777b8ad32"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"- Cloud Storage\n",
"- BigQuery\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing), [Cloud Storage pricing](https://cloud.google.com/storage/pricing) and [BigQuery pricing](https://cloud.google.com/bigquery/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
@@ -104,7 +127,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the following packages for executing this notebook."
]
},
{
@@ -115,20 +138,22 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\"/opt/deeplearning/metadata/env_version\")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"# Install the packages\n",
"! pip3 install --upgrade pyarrow \\\n",
" google-cloud-aiplatform \\\n",
" google-cloud-bigquery \\\n",
" google-cloud-bigquery-storage $USER_FLAG -q"
]
},
{
@@ -165,6 +190,32 @@
"metadata": {
"id": "project_id"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "56d591439df1"
},
"source": [
"#### Set your project ID\n",
"\n",
@@ -236,7 +287,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -263,6 +317,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f3bd8c0d0469"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "e0953a00668e"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -286,7 +401,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -297,8 +413,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -318,7 +435,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -338,7 +455,55 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "set_service_account"
},
"source": [
"#### Service Account\n",
"\n",
"You use a service account to create Vertex AI Pipeline jobs. If you do not want to use your project's Compute Engine service account, set `SERVICE_ACCOUNT` to another service account ID."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_service_account"
},
"outputs": [],
"source": [
"SERVICE_ACCOUNT = \"[your-service-account]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_service_account"
},
"outputs": [],
"source": [
"if (\n",
" SERVICE_ACCOUNT == \"\"\n",
" or SERVICE_ACCOUNT is None\n",
" or SERVICE_ACCOUNT == \"[your-service-account]\"\n",
"):\n",
" # Get your service account from gcloud\n",
" if not IS_COLAB:\n",
" shell_output = !gcloud auth list 2>/dev/null\n",
" SERVICE_ACCOUNT = shell_output[2].replace(\"*\", \"\").strip()\n",
"\n",
" if IS_COLAB:\n",
" shell_output = ! gcloud projects describe $PROJECT_ID\n",
" project_number = shell_output[-1].split(\":\")[1].strip().replace(\"'\", \"\")\n",
" SERVICE_ACCOUNT = f\"{project_number}-compute@developer.gserviceaccount.com\"\n",
"\n",
" print(\"Service Account:\", SERVICE_ACCOUNT)"
]
},
{
@@ -347,9 +512,6 @@
"id": "setup_vars"
},
"source": [
"### Set up variables\n",
"\n",
"Next, set up some variables used throughout the tutorial.\n",
"### Import libraries and define constants"
]
},
@@ -361,28 +523,7 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_bq"
},
"source": [
"#### Import BigQuery\n",
"\n",
"Import the BigQuery package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_bq"
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aiplatform\n",
"from google.cloud import bigquery"
]
},
@@ -392,7 +533,7 @@
"id": "init_aip:mbsdk"
},
"source": [
"### Initialize Vertex AI SDK for Python\n",
"### Initialize Vertex AI and BigQuery SDKs for Python\n",
"\n",
"Initialize the Vertex AI SDK for Python for your project and corresponding bucket."
]
@@ -405,7 +546,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aiplatform.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -414,8 +555,6 @@
"id": "init_bq"
},
"source": [
"### Create BigQuery client\n",
"\n",
"Create the BigQuery client."
]
},
@@ -427,7 +566,7 @@
},
"outputs": [],
"source": [
"bqclient = bigquery.Client()"
"bqclient = bigquery.Client(project=PROJECT_ID)"
]
},
{
@@ -436,17 +575,17 @@
"id": "accelerators:prediction,mbsdk"
},
"source": [
"#### Set hardware accelerators\n",
"### Set hardware accelerators\n",
"\n",
"You can set hardware accelerators for prediction.\n",
"\n",
"Set the variable `DEPLOY_GPU/DEPLOY_NGPU` to use a container image supporting a GPU and the number of GPUs allocated to the virtual machine (VM) instance. For example, to use a GPU container image with 4 Nvidia Telsa K80 GPUs allocated to each VM, you would specify:\n",
"\n",
" (aip.AcceleratorType.NVIDIA_TESLA_K80, 4)\n",
" (aiplatform.AcceleratorType.NVIDIA_TESLA_K80, 4)\n",
"\n",
"Otherwise specify `(None, None)` to use a container image to run on a CPU.\n",
"\n",
"Learn more [here](https://cloud.google.com/vertex-ai/docs/general/locations#accelerators) hardware accelerator support for your region"
"Learn more [here](https://cloud.google.com/vertex-ai/docs/general/locations#accelerators) hardware accelerator support for your region."
]
},
{
@@ -457,13 +596,15 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if os.getenv(\"IS_TESTING_DEPLOY_GPU\"):\n",
" DEPLOY_GPU, DEPLOY_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" int(os.getenv(\"IS_TESTING_DEPLOY_GPU\")),\n",
" )\n",
"else:\n",
" DEPLOY_GPU, DEPLOY_NGPU = (aip.gapic.AcceleratorType.NVIDIA_TESLA_K80, 1)"
" DEPLOY_GPU, DEPLOY_NGPU = (aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80, 1)"
]
},
{
@@ -472,7 +613,7 @@
"id": "container:prediction"
},
"source": [
"#### Set pre-built containers\n",
"### Set pre-built containers\n",
"\n",
"Set the pre-built Docker container image for prediction.\n",
"\n",
@@ -519,11 +660,11 @@
"id": "machine:prediction"
},
"source": [
"#### Set machine type\n",
"### Set machine type\n",
"\n",
"Next, set the machine type to use for prediction.\n",
"\n",
"- Set the variable `DEPLOY_COMPUTE` to configure the compute resources for the VM you will use for prediction.\n",
"- Set the variable `DEPLOY_COMPUTE` to configure the compute resources for the VM which is used for prediction.\n",
" - `machine type`\n",
" - `n1-standard`: 3.75GB of memory per vCPU.\n",
" - `n1-highmem`: 6.5GB of memory per vCPU\n",
@@ -557,7 +698,7 @@
"id": "bqml_intro"
},
"source": [
"## Bigquery ML introduction\n",
"## BigQuery ML introduction\n",
"\n",
"BigQuery ML (BQML) provides the capability to train ML tabular models, such as classification and regression, in BigQuery using SQL syntax.\n",
"\n",
@@ -582,9 +723,9 @@
"id": "bqml_create_dataset"
},
"source": [
"### Create BQ dataset/model resource\n",
"### Create BQ dataset resource\n",
"\n",
"First, you create a empty dataset/model resource in your project."
"First, you create an empty dataset resource in your project."
]
},
{
@@ -659,7 +800,7 @@
"id": "bqml_eval_model"
},
"source": [
"### Evaluate the BQML trained model\n",
"### Evaluate the trained BQML model\n",
"\n",
"Next, retrieve the model evaluation for the trained BQML model.\n",
"\n",
@@ -694,7 +835,7 @@
"source": [
"### Export the model from BQML\n",
"\n",
"The model you trained in BQML is a TensorFlow model. Next, you will export the TensorFlow model artifacts in TF.SavedModel format."
"The model you trained in BQML is a TensorFlow model. Next, you export the TensorFlow model artifacts in TF.SavedModel format."
]
},
{
@@ -705,10 +846,10 @@
},
"outputs": [],
"source": [
"param = f\"{PROJECT_ID}:{BQ_DATASET_NAME}.{MODEL_NAME} {BUCKET_NAME}/{MODEL_NAME}\"\n",
"param = f\"{PROJECT_ID}:{BQ_DATASET_NAME}.{MODEL_NAME} {BUCKET_URI}/{MODEL_NAME}\"\n",
"! bq extract -m $param\n",
"\n",
"MODEL_DIR = f\"{BUCKET_NAME}/{BQ_DATASET_NAME}\"\n",
"MODEL_DIR = f\"{BUCKET_URI}/{BQ_DATASET_NAME}\"\n",
"! gsutil ls $MODEL_DIR"
]
},
@@ -718,9 +859,25 @@
"id": "upload_bqml_model"
},
"source": [
"## Upload the BQML model to a Model resource\n",
"## Upload the BigQuery ML model to a Vertex AI Model resource\n",
"\n",
"Finally, now that you have the BQML model exported as a TF.SavedModel format, you upload the model artifacts to Vertex AI Model resource, in the same way as if you were uploading a custom trained model."
"Finally, now that you have the BigQuery ML model exported, you upload the model artifacts to Vertex AI Model resource, in the same way as if you were uploading a custom trained model.\n",
"\n",
"Below is a partial list of mapping BigQuery ML model types to their corresponding exported model format:\n",
"\n",
"'LINEAR_REG'<br/>\n",
"'LOGISTIC_REG' --> TensorFlow SavedFormat\n",
"\n",
"'AUTOML_CLASSIFIER'<br/>\n",
"'AUTOML_REGRESSOR' --> TensorFlow SavedFormat\n",
"\n",
"'BOOSTED_TREE_CLASSIFIER'<br/>\n",
"'BOOSTED_TREE_REGRESSOR' --> XGBoost format\n",
"\n",
"'DNN_CLASSIFIER'<br/>\n",
"'DNN_REGRESSOR'<br/>\n",
"'DNN_LINEAR_COMBINED_CLASSIFIER'<br/>\n",
"'DNN_LINEAR_COMBINED_REGRESSOR' --> TensorFlow Estimator"
]
},
{
@@ -731,7 +888,7 @@
},
"outputs": [],
"source": [
"model = aip.Model.upload(\n",
"model = aiplatform.Model.upload(\n",
" display_name=\"penguins_\" + TIMESTAMP,\n",
" artifact_uri=MODEL_DIR,\n",
" serving_container_image_uri=DEPLOY_IMAGE,\n",
@@ -752,7 +909,7 @@
"- `deployed_model_display_name`: A human readable name for the deployed model.\n",
"- `traffic_split`: Percent of traffic at the endpoint that goes to this model, which is specified as a dictionary of one or more key/value pairs.\n",
"If only one model, then specify as { \"0\": 100 }, where \"0\" refers to this model being uploaded and 100 means 100% of the traffic.\n",
"If there are existing models on the endpoint, for which the traffic will be split, then use model_id to specify as { \"0\": percent, model_id: percent, ... }, where model_id is the model id of an existing model to the deployed endpoint. The percents must add up to 100.\n",
"If there are existing models on the endpoint, for which the traffic needs to be split, then use model_id to specify as { \"0\": percent, model_id: percent, ... }, where model_id is the model id of an existing model to the deployed endpoint. The percents must add up to 100.\n",
"- `machine_type`: The type of machine to use for training.\n",
"- `accelerator_type`: The hardware accelerator type.\n",
"- `accelerator_count`: The number of accelerators to attach to a worker replica.\n",
@@ -801,7 +958,7 @@
"id": "undeploy_model:mbsdk"
},
"source": [
"## Undeploy the model\n",
"#### Undeploy the model\n",
"\n",
"When you are done doing predictions, you undeploy the model from the `Endpoint` resouce. This deprovisions all compute resources and ends billing for the deployed model."
]
@@ -823,9 +980,9 @@
"id": "model_delete:mbsdk"
},
"source": [
"#### Delete the model\n",
"#### Delete the `Vertex AI Model` resource\n",
"\n",
"The method 'delete()' will delete the model."
"The method 'delete()' deletes the model."
]
},
{
@@ -839,6 +996,32 @@
"model.delete()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "7890ae6f6410"
},
"source": [
"### Delete the `BigQuery ML` model\n",
"\n",
"Next, delete the `BigQuery ML` instance of the model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "f0b6163e70c0"
},
"outputs": [],
"source": [
"MODEL_QUERY = f\"\"\"\n",
"DROP MODEL `{BQ_DATASET_NAME}.{MODEL_NAME}`\n",
"\"\"\"\n",
"\n",
"job = bqclient.query(MODEL_QUERY)"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -847,7 +1030,7 @@
"source": [
"### Hyperparameter Tune and train a BQML model\n",
"\n",
"Next, you train a BQML tabular classification model with hyperparameter tuning using the Vertex AI Vizier service. The hyperparameter settings are specified in the `OPTIONS` statement as follows:\n",
"Next, you train a BQML tabular classification model with hyperparameter tuning using the `Vertex AI Vizier` service. The hyperparameter settings are specified in the `OPTIONS` statement as follows:\n",
"\n",
"- `HPARAM_TUNING_ALGORITHM`: The algorithm for selecting the next trial parameters.\n",
"- `num_trials`: The number of trials.\n",
@@ -902,7 +1085,7 @@
"source": [
"### Evaluate the BQML trained model\n",
"\n",
"Next, retrieve the model evaluation for the trained BQML model.\n",
"Next, retrieve the model evaluation results for the trained BQML model.\n",
"\n",
"Learn more about [The ML.EVALUATE function](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-evaluate)."
]
@@ -927,6 +1110,32 @@
"print(results)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3f3cee1236b1"
},
"source": [
"### Delete the `BigQuery ML` model\n",
"\n",
"Next, delete the `BigQuery ML` instance of the model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "957b7d841502"
},
"outputs": [],
"source": [
"MODEL_QUERY = f\"\"\"\n",
"DROP MODEL `{BQ_DATASET_NAME}.{MODEL_NAME}`\n",
"\"\"\"\n",
"\n",
"job = bqclient.query(MODEL_QUERY)"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -976,6 +1185,179 @@
"print(\"{} created in {}\".format(tblname, job.ended - job.started))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4def8aaf3398"
},
"source": [
"### Delete the `BigQuery ML` model\n",
"\n",
"Next, delete the `BigQuery ML` instance of the model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ff5b32618018"
},
"outputs": [],
"source": [
"MODEL_QUERY = f\"\"\"\n",
"DROP MODEL `{BQ_DATASET_NAME}.{MODEL_NAME}`\n",
"\"\"\"\n",
"\n",
"job = bqclient.query(MODEL_QUERY)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2b4498ca6fea"
},
"source": [
"## Model Registry\n",
"\n",
"Alternatively, you can implicitly upload your BigQuery ML model as a `Vertex AI Model` resource with exporting and importing the model artifacts. In this method, you add additional options when training the model that tells BigQuery ML to automatically upload and register the trained model as a `Model` resource.\n",
"\n",
"### Setting permissions to automatically register the model\n",
"\n",
"You need to set some additional IAM permissions for BigQuery ML to automatically upload and register the model after training. Depending on your service account, the setting of the permissions below may fail. In this case, we recommend executing the permissions in a Cloud Shell.\n",
"\n",
"Learn more about [Setting permissions for Model Registry](https://cloud.google.com/bigquery-ml/docs/managing-models-vertex)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "29229f72d13d"
},
"outputs": [],
"source": [
"! gcloud projects add-iam-policy-binding $PROJECT_ID \\\n",
" --member=serviceAccount:$SERVICE_ACCOUNT --role=roles/aiplatform.admin --condition=None"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "6c390ee7c11a"
},
"source": [
"### Training and registering the model\n",
"\n",
"Next, you train the model and automatically register the model to the `Vertex AI Model Registry`, by adding the following parameters as options:\n",
"\n",
"- `model_registry`: Set to \"vertex_ai\" to indicate automatic registation to `Vertex AI Model Registry`.\n",
"- `vertex_ai_model_id`: The human readable display name for the registered model.\n",
"- `vertex_ai_model_version_aliases`: Alternate names for the model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "57db464f4c42"
},
"outputs": [],
"source": [
"MODEL_NAME = \"penguins\"\n",
"MODEL_QUERY = f\"\"\"\n",
"CREATE OR REPLACE MODEL `{BQ_DATASET_NAME}.{MODEL_NAME}`\n",
"OPTIONS(\n",
" model_type='DNN_CLASSIFIER',\n",
" labels = ['species'],\n",
" model_registry=\"vertex_ai\",\n",
" vertex_ai_model_id=\"bqml_model_{TIMESTAMP}\", \n",
" vertex_ai_model_version_aliases=[\"1\"]\n",
" )\n",
"AS\n",
"SELECT *\n",
"FROM `{BQ_TABLE}`\n",
"\"\"\"\n",
"\n",
"job = bqclient.query(MODEL_QUERY)\n",
"print(job.errors, job.state)\n",
"\n",
"while job.running():\n",
" from time import sleep\n",
"\n",
" sleep(30)\n",
" print(\"Running ...\")\n",
"print(job.errors, job.state)\n",
"\n",
"tblname = job.ddl_target_table\n",
"tblname = \"{}.{}\".format(tblname.dataset_id, tblname.table_id)\n",
"print(\"{} created in {}\".format(tblname, job.ended - job.started))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5b4970272040"
},
"source": [
"### Find the model in the `Vertex Model Registry`\n",
"\n",
"Finally, you can use the `Vertex AI Model` list() method with a filter query to find the automatically registered model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "76c22674ba99"
},
"outputs": [],
"source": [
"models = aiplatform.Model.list(filter=\"display_name=bqml_model_\" + TIMESTAMP)\n",
"model = models[0]\n",
"\n",
"print(model.gca_resource)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "48e6ef5d5ffa"
},
"outputs": [],
"source": [
"models = aiplatform.Model.list()\n",
"for model in models:\n",
" if model.gca_resource.display_name.startswith(\"bqml\"):\n",
" print(model.gca_resource.display_name)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ef61354b1a5f"
},
"source": [
"### Delete the `BigQuery ML` model\n",
"\n",
"Next, delete the `BigQuery ML` instance of the model."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "f6004d1ce59d"
},
"outputs": [],
"source": [
"MODEL_QUERY = f\"\"\"\n",
"DROP MODEL `{BQ_DATASET_NAME}.{MODEL_NAME}`\n",
"\"\"\"\n",
"\n",
"job = bqclient.query(MODEL_QUERY)"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -987,17 +1369,9 @@
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"Otherwise, you can delete the individual resources you created in this tutorial.\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
"Set `delete_storage` to `True` to delete the Cloud Storage bucket used in this notebook."
]
},
{
@@ -1008,61 +1382,23 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"# Delete the endpoint using the Vertex endpoint object\n",
"endpoint.undeploy_all()\n",
"endpoint.delete()\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"# Delete the model using the Vertex model object\n",
"try:\n",
" model.delete()\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"# Delete the created BigQuery dataset\n",
"! bq rm -r -f $PROJECT_ID:$BQ_DATASET_NAME\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"delete_storage = False\n",
"if delete_storage or os.getenv(\"IS_TESTING\"):\n",
" # Delete the created GCS bucket\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -29,9 +29,14 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Distributed Training\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Distributed Training\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_distributed_training.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_distributed_training.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
@@ -39,8 +44,9 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_distributed_training.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_distributed_training.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
"Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -56,18 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Distributed Training."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Distributed Training. Please note: There are incompatibilities between Colab and Docker and the Docker section may not work until resolved by the platform."
]
},
{
@@ -126,59 +121,86 @@
{
"cell_type": "markdown",
"metadata": {
"id": "install_mlops"
"id": "dataset:custom,boston,lrg"
},
"source": [
"## Installations\n",
"### Dataset\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_mlops"
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG\n",
" ! pip3 install --upgrade torchvision $USER_FLAG\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG"
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "restart"
"id": "d10166df7141"
},
"source": [
"### Restart the kernel\n",
"### Costs\n",
" \n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"Once you've installed the additional packages, you need to restart the notebook kernel so it can find the packages."
"Vertex AI\n",
"Cloud Storage\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage pricing](https://cloud.google.com/storage/pricing), and use the [Pricing Calculator](https://cloud.google.com/products/calculator/),\n",
" to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "XkYpRvOQyVYb"
},
"source": [
"## Installation\n",
"\n",
"Install the packages required for executing this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "restart"
"id": "xs_Kt8RcyXTC"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install {USER_FLAG} --upgrade google-cloud-aiplatform -q"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "oQhwq1iozAxh"
},
"source": [
"### Restart the kernel\n",
"\n",
"After you install the additional packages, you need to restart the notebook kernel so it can find the packages."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "zo3YFZXLzCRJ"
},
"outputs": [],
"source": [
"# Automatically restart kernel after installs\n",
"import os\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
@@ -189,6 +211,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -261,11 +309,14 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "region"
"id": "qohAA9fJulvP"
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -283,7 +334,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
"id": "8NKwwe7aulvQ"
},
"outputs": [],
"source": [
@@ -292,6 +343,82 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "poKeKYG8ulvQ"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already\n",
"authenticated. Skip this step."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "MIpJGzF9ulvQ"
},
"source": [
"**If you are using Colab**, run the cell below and follow the instructions\n",
"when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"1. In the Cloud Console, go to the [**Create service account key**\n",
" page](https://console.cloud.google.com/apis/credentials/serviceaccountkey).\n",
"\n",
"2. Click **Create service account**.\n",
"\n",
"3. In the **Service account name** field, enter a name, and\n",
" click **Create**.\n",
"\n",
"4. In the **Grant this service account access to project** section, click the **Role** drop-down list. Type \"Vertex AI\"\n",
"into the filter box, and select\n",
" **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"5. Click *Create*. A JSON file that contains your key downloads to your\n",
"local environment.\n",
"\n",
"6. Enter the path to your service account key as the\n",
"`GOOGLE_APPLICATION_CREDENTIALS` variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Vh6KDXB5ulvQ"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -315,7 +442,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -326,8 +454,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -343,11 +472,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
"id": "Moosy2rOulvR"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -363,11 +492,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
"id": "56irx2CvulvS"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -408,11 +537,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "init_aip:mbsdk"
"id": "wbvYPSTDulvS"
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -441,7 +570,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "accelerators:training,prediction,ngpu,mbsdk"
"id": "PryARdnoulvT"
},
"outputs": [],
"source": [
@@ -483,14 +612,14 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "container:training,prediction"
"id": "LhhUFw2nulvT"
},
"outputs": [],
"source": [
"if os.getenv(\"IS_TESTING_TF\"):\n",
" TF = os.getenv(\"IS_TESTING_TF\")\n",
"else:\n",
" TF = \"2.1\".replace(\".\", \"-\")\n",
" TF = \"2.5\".replace(\".\", \"-\")\n",
"\n",
"if TF[0] == \"2\":\n",
" if TRAIN_GPU:\n",
@@ -551,7 +680,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "machine:training"
"id": "vytMaukeulvT"
},
"outputs": [],
"source": [
@@ -613,7 +742,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_custom_pp_training_job:mbsdk"
"id": "mhw34XoOulvU"
},
"outputs": [],
"source": [
@@ -621,7 +750,7 @@
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" python_package_gcs_uri=f\"{BUCKET_NAME}/trainer_boston.tar.gz\",\n",
" python_package_gcs_uri=f\"{BUCKET_URI}/trainer_boston.tar.gz\",\n",
" python_module_name=\"trainer.task\",\n",
" container_uri=TRAIN_IMAGE,\n",
" model_serving_container_image_uri=DEPLOY_IMAGE,\n",
@@ -662,7 +791,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "examine_training_package"
"id": "IAaZpZyyulvU"
},
"outputs": [],
"source": [
@@ -711,7 +840,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "taskpy_contents:mirrored,boston"
"id": "zKzddzl6ulvV"
},
"outputs": [],
"source": [
@@ -767,6 +896,13 @@
" strategy = tf.distribute.MultiWorkerMirroredStrategy()\n",
" logging.info(\"Multi-worker Strategy distributed training\")\n",
" logging.info('TF_CONFIG = {}'.format(os.environ.get('TF_CONFIG', 'Not found')))\n",
" # Single Machine, multiple TPU devices\n",
"elif args.distribute == 'tpu':\n",
" cluster_resolver = tf.distribute.cluster_resolver.TPUClusterResolver(tpu=\"local\")\n",
" tf.config.experimental_connect_to_cluster(cluster_resolver)\n",
" tf.tpu.experimental.initialize_tpu_system(cluster_resolver)\n",
" strategy = tf.distribute.TPUStrategy(cluster_resolver)\n",
" print(\"All devices: \", tf.config.list_logical_devices('TPU'))\n",
"\n",
"logging.info('num_replicas_in_sync = {}'.format(strategy.num_replicas_in_sync))\n",
"\n",
@@ -825,8 +961,11 @@
" else:\n",
" task_type, task_id = None, None\n",
"\n",
" if args.distribute==\"tpu\":\n",
" save_locally = tf.saved_model.SaveOptions(experimental_io_device='/job:localhost')\n",
" model.save(args.model_dir, options=save_locally)\n",
" # single, mirrored or primary for multiworker\n",
" if _is_chief(task_type, task_id):\n",
" elif _is_chief(task_type, task_id):\n",
" model.save(args.model_dir)\n",
" # non-primary workers for multi-workers\n",
" else:\n",
@@ -860,14 +999,14 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "tarball_training_script"
"id": "LFUHioqTulvV"
},
"outputs": [],
"source": [
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_boston.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_boston.tar.gz"
]
},
{
@@ -885,11 +1024,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "run_custom_pp_training_job:mirrored"
"id": "LnUX0UkvulvV"
},
"outputs": [],
"source": [
"MODEL_DIR = BUCKET_NAME\n",
"MODEL_DIR = BUCKET_URI\n",
"\n",
"CMDARGS = [\"--epochs=5\", \"--batch_size=16\", \"--distribute=mirrored\"]\n",
"\n",
@@ -920,7 +1059,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "delete_job"
"id": "iUWHFpPoulvW"
},
"outputs": [],
"source": [
@@ -942,7 +1081,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "model_delete:mbsdk"
"id": "-0gqCUTEulvW"
},
"outputs": [],
"source": [
@@ -1027,7 +1166,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "create_custom_pp_training_job:mbsdk"
"id": "aXvPN8P6ulvX"
},
"source": [
"### Create and run custom training job\n",
@@ -1053,7 +1192,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_custom_pp_training_job:mbsdk"
"id": "kYcFsVSEulvX"
},
"outputs": [],
"source": [
@@ -1061,7 +1200,7 @@
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" python_package_gcs_uri=f\"{BUCKET_NAME}/trainer_boston.tar.gz\",\n",
" python_package_gcs_uri=f\"{BUCKET_URI}/trainer_boston.tar.gz\",\n",
" python_module_name=\"trainer.task\",\n",
" container_uri=TRAIN_IMAGE,\n",
" model_serving_container_image_uri=DEPLOY_IMAGE,\n",
@@ -1084,11 +1223,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "run_custom_pp_training_job:multiworker"
"id": "GHRxPU32ulvX"
},
"outputs": [],
"source": [
"MODEL_DIR = BUCKET_NAME\n",
"MODEL_DIR = BUCKET_URI\n",
"\n",
"CMDARGS = [\"--epochs=5\", \"--batch_size=16\", \"--distribute=multiworker\"]\n",
"\n",
@@ -1111,7 +1250,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "delete_job"
"id": "92D_hbuVulvX"
},
"source": [
"### Delete a custom training job\n",
@@ -1123,7 +1262,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "delete_job"
"id": "CqrfWkB3ulvX"
},
"outputs": [],
"source": [
@@ -1175,14 +1314,13 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "write_docker_file:training,multiworker"
"id": "pGI2viDAulvY"
},
"outputs": [],
"source": [
"%%writefile custom/Dockerfile\n",
"\n",
"FROM gcr.io/deeplearning-platform-release/tf2-gpu.2-5\n",
"WORKDIR /root\n",
"\n",
"WORKDIR /\n",
"\n",
@@ -1208,7 +1346,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "name_container:training"
"id": "7P8cdlFtulvY"
},
"outputs": [],
"source": [
@@ -1228,11 +1366,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "build_container:training"
"id": "jmw5cakNulvY"
},
"outputs": [],
"source": [
"! docker build custom -t $TRAIN_IMAGE"
"if not IS_COLAB:\n",
" ! docker build custom -t $TRAIN_IMAGE\n",
"else:\n",
" # install docker daemon\n",
" ! apt-get -qq install docker.io"
]
},
{
@@ -1250,11 +1392,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "test_container:training"
"id": "jJGLjU-TulvZ"
},
"outputs": [],
"source": [
"! docker run $TRAIN_IMAGE --epochs=5 --model-dir=./"
"if not IS_COLAB:\n",
" ! docker run $TRAIN_IMAGE --epochs=5 --model-dir=./"
]
},
{
@@ -1272,11 +1415,42 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "register_container:training"
"id": "GAXGjae7ulvZ"
},
"outputs": [],
"source": [
"! docker push $TRAIN_IMAGE"
"if not IS_COLAB:\n",
" ! docker push $TRAIN_IMAGE"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f50e9c553fb7"
},
"source": [
"*Executes in Colab*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a7e8c98f1e56"
},
"outputs": [],
"source": [
"%%bash -s $IS_COLAB $TRAIN_IMAGE\n",
"if [ $1 == \"False\" ]; then\n",
" exit 0\n",
"fi\n",
"set -x\n",
"dockerd -b none --iptables=0 -l warn &\n",
"for i in $(seq 5); do [ ! -S \"/var/run/docker.sock\" ] && sleep 2 || break; done\n",
"docker build custom -t $2\n",
"docker run $2 --epochs=5 --model-dir=./\n",
"docker push $2\n",
"kill $(jobs -p)"
]
},
{
@@ -1296,13 +1470,13 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "worker_pool_primary"
"id": "CEAnXBzCulvZ"
},
"outputs": [],
"source": [
"PRIMARY_COMPUTE = \"n2-highcpu-64\"\n",
"\n",
"MODEL_DIR = BUCKET_NAME\n",
"MODEL_DIR = BUCKET_URI\n",
"\n",
"CMDARGS = [\n",
" \"--model-dir=\" + MODEL_DIR,\n",
@@ -1339,7 +1513,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "worker_pool_training"
"id": "6dchPSfNulvZ"
},
"outputs": [],
"source": [
@@ -1375,7 +1549,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "custom_job:worker_pool"
"id": "m2VgmqEOulva"
},
"outputs": [],
"source": [
@@ -1399,7 +1573,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "run_custom_job:multiworker"
"id": "hg8vnI_Wulva"
},
"outputs": [],
"source": [
@@ -1413,7 +1587,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "delete_job"
"id": "WT76Sc-culva"
},
"source": [
"### Delete a custom training job\n",
@@ -1425,7 +1599,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "delete_job"
"id": "I_IxVfuDulva"
},
"outputs": [],
"source": [
@@ -1474,7 +1648,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "custom_job:worker_pool"
"id": "L8Av8ATVulvb"
},
"source": [
"### Create CustomJob with worker pool specifications\n",
@@ -1490,7 +1664,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "custom_job:worker_pool"
"id": "TUWEP1Lmulvb"
},
"outputs": [],
"source": [
@@ -1502,7 +1676,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "run_custom_job:multiworker"
"id": "_95FH8jeulvb"
},
"source": [
"### Run the CustomJob\n",
@@ -1514,7 +1688,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "run_custom_job:multiworker"
"id": "IEbrY05Gulvb"
},
"outputs": [],
"source": [
@@ -1528,7 +1702,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "delete_job"
"id": "8R2Bnmwmulvb"
},
"source": [
"### Delete a custom training job\n",
@@ -1540,7 +1714,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "delete_job"
"id": "s1geVE3Lulvb"
},
"outputs": [],
"source": [
@@ -1583,14 +1757,14 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "docker_write:tpu"
"id": "nQVPtknpulvb"
},
"outputs": [],
"source": [
"%%writefile custom/Dockerfile\n",
"FROM python:3.8\n",
"\n",
"WORKDIR /root\n",
"WORKDIR /\n",
"\n",
"# Copies the trainer code to the docker image.\n",
"COPY trainer /trainer\n",
@@ -1622,11 +1796,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "docker_push:tpu"
"id": "J_d_zEXUulvc"
},
"outputs": [],
"source": [
"TRAIN_IMAGE = f\"gcr.io/\" + PROJECT_ID + \"/tpu-train:latest\"\n",
"TRAIN_IMAGE = \"gcr.io/\" + PROJECT_ID + \"/tpu-train:latest\"\n",
"\n",
"os.chdir(\"custom\")\n",
"! docker build --quiet --tag={TRAIN_IMAGE} .\n",
@@ -1653,7 +1827,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "worker_pool_tpu"
"id": "d514eU7lulvc"
},
"outputs": [],
"source": [
@@ -1701,7 +1875,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "custom_job:worker_pool"
"id": "RruSqNfrulvc"
},
"source": [
"### Create CustomJob with worker pool specifications\n",
@@ -1717,7 +1891,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "custom_job:worker_pool"
"id": "2QvSqbbHulvc"
},
"outputs": [],
"source": [
@@ -1729,7 +1903,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "run_custom_job:multiworker"
"id": "Iw4L3UIfulvd"
},
"source": [
"### Run the CustomJob\n",
@@ -1741,7 +1915,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "run_custom_job:multiworker"
"id": "zmqCNS78ulvd"
},
"outputs": [],
"source": [
@@ -1755,7 +1929,7 @@
{
"cell_type": "markdown",
"metadata": {
"id": "delete_job"
"id": "gWZoH9QKulvd"
},
"source": [
"### Delete a custom training job\n",
@@ -1767,7 +1941,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "delete_job"
"id": "Lt8BJ4iBulvd"
},
"outputs": [],
"source": [
@@ -1787,13 +1961,7 @@
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"\n",
"- Cloud Storage Bucket"
]
},
@@ -1801,70 +1969,15 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cleanup"
"id": "U98Wzc01ulvd"
},
"outputs": [],
"source": [
"delete_dataset = True\n",
"delete_pipeline = True\n",
"delete_model = True\n",
"delete_endpoint = True\n",
"delete_batchjob = True\n",
"delete_customjob = True\n",
"delete_hptjob = True\n",
"delete_bucket = True\n",
"# Set this to true only if you'd like to delete your bucket\n",
"delete_bucket = False\n",
"\n",
"# Delete the dataset using the Vertex fully qualified identifier for the dataset\n",
"try:\n",
" if delete_dataset and \"dataset_id\" in globals():\n",
" clients[\"dataset\"].delete_dataset(name=dataset_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the training pipeline using the Vertex fully qualified identifier for the pipeline\n",
"try:\n",
" if delete_pipeline and \"pipeline_id\" in globals():\n",
" clients[\"pipeline\"].delete_training_pipeline(name=pipeline_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the model using the Vertex fully qualified identifier for the model\n",
"try:\n",
" if delete_model and \"model_to_deploy_id\" in globals():\n",
" clients[\"model\"].delete_model(name=model_to_deploy_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the endpoint using the Vertex fully qualified identifier for the endpoint\n",
"try:\n",
" if delete_endpoint and \"endpoint_id\" in globals():\n",
" clients[\"endpoint\"].delete_endpoint(name=endpoint_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the batch job using the Vertex fully qualified identifier for the batch job\n",
"try:\n",
" if delete_batchjob and \"batch_job_id\" in globals():\n",
" clients[\"job\"].delete_batch_prediction_job(name=batch_job_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the custom job using the Vertex fully qualified identifier for the custom job\n",
"try:\n",
" if delete_customjob and \"job_id\" in globals():\n",
" clients[\"job\"].delete_custom_job(name=job_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# Delete the hyperparameter tuning job using the Vertex fully qualified identifier for the hyperparameter tuning job\n",
"try:\n",
" if delete_hptjob and \"hpt_job_id\" in globals():\n",
" clients[\"job\"].delete_hyperparameter_tuning_job(name=hpt_job_id)\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"if delete_bucket and \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
File diff suppressed because it is too large Load Diff
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Feature Store\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Feature Store\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -38,11 +38,20 @@
" View on GitHub\n",
" </a>\n",
" </td>\n",
" \n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_feature_store.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_feature_store.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" \n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_feature_store.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
" \n",
"</table>\n",
"<br/><br/><br/>"
]
@@ -59,19 +68,6 @@
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Feature Store."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:movies,lbn,avro"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the Movie Recommendations. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket, in Avro format.\n",
"\n",
"The dataset predicts whether a persons will watch a movie."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -80,7 +76,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `Vertex AI Feature Store` for when training and prediction with `Vertex AI`.\n",
"In this tutorial, you learn how to use `Vertex AI Feature Store` when training and predicting with `Vertex AI`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -92,10 +88,41 @@
" - Creating `EntityType` resources for the `Featurestore` resource.\n",
" - Creating `Feature` resources for each `EntityType` resource.\n",
"- Import feature values (entity data items) into `Featurestore` resource.\n",
" - From a Cloud Storage location.\n",
" - From a pandas DataFrame.\n",
"- Perform online serving from a `Featurestore` resource.\n",
"- Perform batch serving from a `Featurestore` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:movies,lbn,avro"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the `Movie Recommendations` dataset. The version of the dataset you use in this tutorial is stored in a public Cloud Storage bucket, in Avro format.\n",
"\n",
"This dataset is used to predict whether a person watches a movie or not."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "81c777b8ad32"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"- Cloud Storage\n",
"- BigQuery\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing), [Cloud Storage pricing](https://cloud.google.com/storage/pricing) and [BigQuery pricing](https://cloud.google.com/bigquery/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -104,7 +131,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the following packages for further running this notebook."
]
},
{
@@ -115,24 +142,21 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG\n",
" ! pip3 install --upgrade torchvision $USER_FLAG\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG\n",
" ! pip3 install --upgrade python-tabulate $USER_FLAG\n",
" ! pip3 install -U opencv-python-headless==4.5.2.52 $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"# Install the dependecies\n",
"! pip3 install --upgrade google-cloud-aiplatform google-cloud-bigquery pyarrow avro $USER_FLAG -q"
]
},
{
@@ -164,6 +188,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "project_id"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, Compute Engine, Cloud Storage and Cloud Logging APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,compute_component,storage_component,logging).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -240,7 +290,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -267,15 +320,72 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "29b110b44457"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex\" into the filter box, and select **Vertex Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "89788a802687"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "setup_vars"
},
"source": [
"### Set up variables\n",
"\n",
"Next, set up some variables used throughout the tutorial.\n",
"### Import libraries and define constants"
]
},
@@ -287,28 +397,7 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "import_bq"
},
"source": [
"#### Import BigQuery\n",
"\n",
"Import the BigQuery package into your Python environment."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_bq"
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aiplatform\n",
"from google.cloud import bigquery"
]
},
@@ -318,9 +407,7 @@
"id": "init_bq"
},
"source": [
"### Create BigQuery client\n",
"\n",
"Create the BigQuery client."
"Initialize Vertex AI and BigQuery clients."
]
},
{
@@ -331,7 +418,8 @@
},
"outputs": [],
"source": [
"bqclient = bigquery.Client()"
"aiplatform.init(project=PROJECT_ID)\n",
"bqclient = bigquery.Client(project=PROJECT_ID)"
]
},
{
@@ -348,11 +436,11 @@
"\n",
"Now it's time to do a live prediction. You get a transaction from the cash register, but all it has is the credit card number and this transaction. It does not have the enriched data the model needs. During serving, the credit card number is used as an index to Feature Store to get the enriched data needed for the model.\n",
"\n",
"Next problem. Let's say the enriched data the model was trained on was timestamp June 1. This transaction is June 15. Assume that the user has made other transactions between June 1 and 15, and the enriched data has been continuously updated in Feature Store. But the model was trained on June 1st data. FeatureStore knows the version number and serves the June 1 version to the model (not the current June 15); otherwise, if you used June 15 data you have training-serving skew.\n",
"On the other hand, let's say the enriched data the model was trained on was timestamped on June 1st. The current transaction is from June 15th. Assume that the user has made other transactions between June 1st and 15th, and the enriched data has been continuously updated in Feature Store. But the model was trained on June 1st data. FeatureStore knows the version number and serves the June 1st version to the model (not the current June 15th). Otherwise, if you used June 15th data, you would have training-serving skew.\n",
"\n",
"Next problem, data drift. Things change, suddenly one day everybody is buying toilet paper! There is a significant change in the distribution of the current stored enriched data from the distribution that the deployed model was trained on. FeatureStore can detect changes/thresholds in distribution changes and trigger a notification for retraining the model.\n",
"Another problem here is the data drift. Things change and suddenly one day, everybody is buying toilet paper! There is a significant change in the distribution of existing enriched data from the distribution that the deployed model was trained on. FeatureStore can detect changes/thresholds in distribution changes and trigger a notification for retraining the model.\n",
"\n",
"Learn more about [Vertex AI Feature Store API](https://cloud.google.com/vertex-ai/docs/featurestore)"
"Learn more about [Vertex AI Feature Store API](https://cloud.google.com/vertex-ai/docs/featurestore)."
]
},
{
@@ -367,9 +455,9 @@
"\n",
" Featurestore -> EntityType -> Feature\n",
"\n",
"- `Featurestore`: the place to store your features\n",
"- `Featurestore`: the place to store your features.\n",
"- `EntityType`: under a `Featurestore`, an `EntityType` describes an object to be modeled, real one or virtual one.\n",
"- `Feature`: under an `EntityType`, a `Feature` describes an attribute of the `EntityType`\n",
"- `Feature`: under an `EntityType`, a `Feature` describes an attribute of the `EntityType`.\n",
"\n",
"Learn more about [Vertex AI Feature Store data model](https://cloud.google.com/vertex-ai/docs/featurestore/concepts).\n",
"\n",
@@ -403,9 +491,9 @@
"outputs": [],
"source": [
"# Represents featurestore resource path.\n",
"FEATURESTORE_NAME = \"movies\"\n",
"FEATURESTORE_NAME = \"movies_\" + TIMESTAMP\n",
"\n",
"featurestore = aip.Featurestore.create(\n",
"featurestore = aiplatform.Featurestore.create(\n",
" featurestore_id=FEATURESTORE_NAME,\n",
" online_store_fixed_node_count=1,\n",
" project=PROJECT_ID,\n",
@@ -434,7 +522,7 @@
},
"outputs": [],
"source": [
"for featurestore in aip.Featurestore.list():\n",
"for featurestore in aiplatform.Featurestore.list():\n",
" print(featurestore)"
]
},
@@ -461,7 +549,7 @@
},
"outputs": [],
"source": [
"featurestore = featurestore = aip.Featurestore(\n",
"featurestore = featurestore = aiplatform.Featurestore(\n",
" featurestore_name=FEATURESTORE_NAME, project=PROJECT_ID, location=REGION\n",
")\n",
"print(featurestore)"
@@ -520,7 +608,7 @@
"outputs": [],
"source": [
"def create_features(featurestore_name, entity_name, features):\n",
" entity_type = aip.EntityType(\n",
" entity_type = aiplatform.EntityType(\n",
" entity_type_name=entity_name, featurestore_id=featurestore_name\n",
" )\n",
"\n",
@@ -571,7 +659,7 @@
},
"outputs": [],
"source": [
"for featurestore in aip.Featurestore.list():\n",
"for featurestore in aiplatform.Featurestore.list():\n",
" print(featurestore)"
]
},
@@ -583,7 +671,7 @@
"source": [
"### Search `Feature` resources using a filter\n",
"\n",
"You can narrow your search of `Feature` resources using the method `list_features()` and specifying a `filter` filter."
"You can narrow your search of `Feature` resources using the method `list_features()` and specifying a `filter` string."
]
},
{
@@ -635,17 +723,26 @@
},
"outputs": [],
"source": [
"features = aip.Feature.search(query=\"value_type=DOUBLE\")\n",
"features = aiplatform.Feature.search(query=\"value_type=DOUBLE\")\n",
"print(\"By data type\")\n",
"for feature in features:\n",
" print(features)\n",
"\n",
"aip.Feature.search(query=\"feature_id=title\")\n",
"aiplatform.Feature.search(query=\"feature_id=title\")\n",
"print(\"By Name\")\n",
"for feature in features:\n",
" print(features)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "277e9884cf37"
},
"source": [
"Define paths to the feature data."
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -675,15 +772,15 @@
"\n",
"### Data layout\n",
"\n",
"Each imported `EntityType` resource data must have an ID; also, each `EntityType` resource data item can optionally have a timestamp, sepecifying when the feature values were generated.\n",
"Each imported `EntityType` resource data must have an ID. Also, each `EntityType` resource data item can optionally have a timestamp, sepecifying when the feature values were generated.\n",
"\n",
"When importing, specify the following in your request:\n",
"\n",
"- Data source format: BigQuery Table/Avro/CSV\n",
"- Data source format: BigQuery Table/Avro/CSV/Pandas Dataframe\n",
"- Data source URL\n",
"- Destination: featurestore/entity types/features to be imported\n",
"\n",
"The feature values for the movies dataset are in Avro format. The Avro schemas are as follows:\n",
"The feature values for `Movie Recommendations` dataset are in Avro format. The Avro schemas are as follows:\n",
"\n",
"**Users entity**:\n",
"\n",
@@ -747,7 +844,7 @@
"}\n",
"```\n",
"\n",
"### Importing the feature values\n",
"### Importing the feature values from Cloud Storage\n",
"\n",
"You import the feature values for the `EntityType` resources using the `ingest_from_gcs()` method, with the following parameters:\n",
"\n",
@@ -755,7 +852,7 @@
"- `feature_ids`: A list of identifier names for `Feature` resources' data to add to the `EntityType` resource.\n",
"- `feature_time`: The field corresponding to the timestamp for the features being entered.\n",
"- `gcs_source_type`: The format of the imported data. Must be CSV or Avro.\n",
"- `gcs_source_uris=`: A list of one or more Cloud Storage locations of the imported data files."
"- `gcs_source_uris`: A list of one or more Cloud Storage locations of the imported data files."
]
},
{
@@ -787,6 +884,225 @@
"print(response)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "featurestore_delete_entities:movies"
},
"source": [
"#### Delete the entity types and corresponding features and feature values\n",
"\n",
"Now, in preparation to repeat the process of importing feature values but from a dataframe this time, you delete the existing entity types, and the corresponding content."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "featurestore_delete_entities:movies"
},
"outputs": [],
"source": [
"entity_type = featurestore.get_entity_type(\"users\")\n",
"entity_type.delete(force=True)\n",
"entity_type = featurestore.get_entity_type(\"movies\")\n",
"entity_type.delete(force=True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "featurestore_create:entity_type"
},
"source": [
"## Create entity types for your `Featurestore` resource\n",
"\n",
"Next, you create the `EntityType` resources again for your `Featurestore` resource using the `create_entity_type()` method, with the following parameters:\n",
"\n",
"- `entity_type_id`: The name of the `EntityType` resource.\n",
"- `description`: A description of the entity type."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "featurestore_create:entity_type"
},
"outputs": [],
"source": [
"for name, description in [(\"users\", \"Users descrip\"), (\"movies\", \"Movies descrip\")]:\n",
" entity_type = featurestore.create_entity_type(\n",
" entity_type_id=name, description=description\n",
" )\n",
" print(entity_type)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "featurestore_create:feature"
},
"source": [
"### Add `Feature` resources for your `EntityType` resources\n",
"\n",
"Further, you create the `Feature` resources again for each of the `EntityType` resources in your `Featurestore` resource using the `create_feature()` method, with the following parameters:\n",
"\n",
"- `feature_id`: The name of the `Feature` resource.\n",
"- `description`: A description of the feature.\n",
"- `value_type`: The data type for the feature."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "featurestore_create:feature,movies"
},
"outputs": [],
"source": [
"def create_features(featurestore_name, entity_name, features):\n",
" entity_type = aiplatform.EntityType(\n",
" entity_type_name=entity_name, featurestore_id=featurestore_name\n",
" )\n",
"\n",
" for feature in features:\n",
" feature = entity_type.create_feature(\n",
" feature_id=feature[0], description=feature[1], value_type=feature[2]\n",
" )\n",
" print(feature)\n",
"\n",
"\n",
"create_features(\n",
" FEATURESTORE_NAME,\n",
" \"users\",\n",
" [\n",
" (\"age\", \"Age descrip\", \"INT64\"),\n",
" (\"gender\", \"Gender descrip\", \"STRING\"),\n",
" (\"liked_genres\", \"Genres descrip\", \"STRING_ARRAY\"),\n",
" ],\n",
")\n",
"\n",
"create_features(\n",
" FEATURESTORE_NAME,\n",
" \"movies\",\n",
" [\n",
" (\"title\", \"Title descrip\", \"STRING\"),\n",
" (\"genres\", \"Genres descrip\", \"STRING\"),\n",
" (\"average_rating\", \"Ave descrip\", \"DOUBLE\"),\n",
" ],\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "8715a3f719c8"
},
"source": [
"Now, copy the `users` and `movies` data into avro files."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_file:movies,lbn,df"
},
"outputs": [],
"source": [
"GCS_USERS_AVRO_URI = FS_ENTITIES[\"users\"]\n",
"GCS_MOVIES_AVRO_URI = FS_ENTITIES[\"movies\"]\n",
"\n",
"USERS_AVRO_FN = \"users.avro\"\n",
"MOVIES_AVRO_FN = \"movies.avro\"\n",
"\n",
"! gsutil cp $GCS_USERS_AVRO_URI $USERS_AVRO_FN\n",
"! gsutil cp $GCS_MOVIES_AVRO_URI $MOVIES_AVRO_FN"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "load_df_from_avro"
},
"source": [
"#### Load Avro Files into pandas DataFrames"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "load_df_from_avro"
},
"outputs": [],
"source": [
"from avro.datafile import DataFileReader\n",
"from avro.io import DatumReader\n",
"\n",
"\n",
"class AvroReader:\n",
" def __init__(self, data_file):\n",
" self.avro_reader = DataFileReader(open(data_file, \"rb\"), DatumReader())\n",
"\n",
" def to_dataframe(self):\n",
" records = [record for record in self.avro_reader]\n",
" return pd.DataFrame.from_records(data=records)\n",
"\n",
"\n",
"import pandas as pd\n",
"\n",
"users_avro_reader = AvroReader(data_file=USERS_AVRO_FN)\n",
"users_source_df = users_avro_reader.to_dataframe()\n",
"print(users_source_df)\n",
"\n",
"movies_avro_reader = AvroReader(data_file=MOVIES_AVRO_FN)\n",
"movies_source_df = movies_avro_reader.to_dataframe()\n",
"print(movies_source_df)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "featurestore_import:movies,df"
},
"source": [
"### Importing the feature values from DataFrame\n",
"\n",
"You import the feature values for the `EntityType` resources using the `ingest_from_df()` method, with the following parameters:\n",
"\n",
"- `entity_id_field`: The identifier name for the parent `EntityType` resource.\n",
"- `feature_ids`: A list of identifier names for `Feature` resources' data to add to the `EntityType` resource.\n",
"- `feature_time`: The field corresponding to the timestamp for the features being entered.\n",
"- `df_source`: The DataFrame containing the imported feature values."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "featurestore_import:movies,df"
},
"outputs": [],
"source": [
"entity_type = featurestore.get_entity_type(\"users\")\n",
"entity_type.ingest_from_df(\n",
" feature_ids=[\"age\", \"gender\", \"liked_genres\"],\n",
" feature_time=\"update_time\",\n",
" df_source=users_source_df,\n",
" entity_id_field=\"user_id\",\n",
")\n",
"\n",
"entity_type = featurestore.get_entity_type(\"movies\")\n",
"entity_type.ingest_from_df(\n",
" feature_ids=[\"average_rating\", \"title\", \"genres\"],\n",
" feature_time=\"update_time\",\n",
" df_source=movies_source_df,\n",
" entity_id_field=\"movie_id\",\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -829,7 +1145,7 @@
"source": [
"## Batch Serving\n",
"\n",
"The Vertex AI Feature Store batch serving service is optimized for serving large batches of features in real-time with high-throughput, typically for training a model or batch prediction.\n",
"The Vertex AI Feature Store's batch serving service is optimized for serving large batches of features in real-time with high throughput, typically for training a model or batch prediction.\n",
"\n",
"One can batch serve to the following destinations:\n",
"\n",
@@ -881,7 +1197,7 @@
"\n",
"You batch serve entity data items to a BigQuery table using the `read_serve_to_bq()` method, with the following parameters:\n",
"\n",
"- `bq_destination_output_uri`: The destination BigQuery table to serve the features to.\n",
"- `bq_destination_output_uri`: The destination BigQuery table to receive the served features.\n",
"- `serving_feature_ids`: A dictionary of entity type and corresponding features to serve.\n",
"- `read_instances_uri`: A Cloud Storage location to read the entity data items from.\n",
"\n",
@@ -914,6 +1230,7 @@
"id": "delete_bq_dataset"
},
"source": [
"## Cleaning up\n",
"### Delete a BigQuery dataset\n",
"\n",
"Use the method `delete_dataset()` to delete a BigQuery dataset along with all its tables, by setting the parameter `delete_contents` to `True`."
File diff suppressed because it is too large Load Diff
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -29,9 +29,14 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Tensorboard\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI TensorBoard\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_tensorboard.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_tensorboard.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
@@ -39,8 +44,9 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_tensorboard.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/notebook_template.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -56,7 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Tensorboard."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI TensorBoard."
]
},
{
@@ -77,7 +83,7 @@
"The steps performed include:\n",
"\n",
"- Create a TensorBoard callback when training a model.\n",
"- Using Tensorboard with locally trained model.\n",
"- Using TensorBoard with locally trained model.\n",
"- Using Vertex AI TensorBoard with Vertex AI Training."
]
},
@@ -89,7 +95,7 @@
"source": [
"### Recommendations\n",
"\n",
"When doing E2E MLOps on Google Cloud, the following best practices for visualizing your training with TensorBoard.\n",
"When doing E2E MLOps on Google Cloud, the following are the best practices for visualizing your training with TensorBoard.\n",
"\n",
"#### Local TensorBoard\n",
"\n",
@@ -97,13 +103,86 @@
"\n",
"#### Cloud TensorBoard\n",
"\n",
"Use the Tensorboard.dev, when doing training on the cloud -- unless you have a privacy issue.\n",
"Use the tensorboard.dev, when doing training on the cloud -- unless you have a privacy issue.\n",
"\n",
"#### Experiments\n",
"\n",
"Use Vertex AI TensorBoard when you have a privacy issue or doing experiments to compare results for different experiment configurations."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "03bfd1274241"
},
"source": [
"### Dataset\n",
"\n",
"In this tutorial you use the MNIST dataset. The version of the dataset is built into the TF.Keras framework. The dataset predicts which digit an image is, between 0 .. 9."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "b132d4ef86d6"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "56cb7f08a9e8"
},
"source": [
"### Set up your local development environment\n",
"\n",
"**If you are using Colab or Vertex AI Workbench Notebooks**, your environment already meets\n",
"all the requirements to run this notebook. \n",
"\n",
"**Otherwise**, make sure your environment meets this notebook's requirements.\n",
"You need the following:\n",
"\n",
"* The Google Cloud SDK\n",
"* Git\n",
"* Python 3\n",
"* virtualenv\n",
"* Jupyter notebook running in a virtual environment with Python 3\n",
"\n",
"The Google Cloud guide to [Setting up a Python development\n",
"environment](https://cloud.google.com/python/setup) and the [Jupyter\n",
"installation guide](https://jupyter.org/install) provide detailed instructions\n",
"for meeting these requirements. The following steps provide a condensed set of\n",
"instructions:\n",
"\n",
"1. [Install and initialize the Cloud SDK.](https://cloud.google.com/sdk/docs/)\n",
"\n",
"1. [Install Python 3.](https://cloud.google.com/python/setup#installing_python)\n",
"\n",
"1. [Install\n",
" virtualenv](https://cloud.google.com/python/setup#installing_and_using_virtualenv)\n",
" and create a virtual environment that uses Python 3. Activate the virtual environment.\n",
"\n",
"1. To install Jupyter, run `pip3 install jupyter` on the\n",
"command-line in a terminal shell.\n",
"\n",
"1. To launch Jupyter, run `jupyter notebook` on the command-line in a terminal shell.\n",
"\n",
"1. Open this notebook in the Jupyter Notebook Dashboard.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -112,31 +191,32 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the following packages for executing this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_mlops"
"id": "020040f91150"
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install -U tensorflow==2.8 $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q"
]
},
{
@@ -168,6 +248,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2721ef0202d9"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). \n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -244,7 +350,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -271,6 +380,82 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2700e693f1b3"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already\n",
"authenticated. Skip this step."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "885395904904"
},
"source": [
"**If you are using Colab**, run the cell below and follow the instructions\n",
"when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"1. In the Cloud Console, go to the [**Create service account key**\n",
" page](https://console.cloud.google.com/apis/credentials/serviceaccountkey).\n",
"\n",
"2. Click **Create service account**.\n",
"\n",
"3. In the **Service account name** field, enter a name, and\n",
" click **Create**.\n",
"\n",
"4. In the **Grant this service account access to project** section, click the **Role** drop-down list. Type \"Vertex AI\"\n",
"into the filter box, and select\n",
" **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"5. Click *Create*. A JSON file that contains your key downloads to your\n",
"local environment.\n",
"\n",
"6. Enter the path to your service account key as the\n",
"`GOOGLE_APPLICATION_CREDENTIALS` variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "eff327d0552b"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -294,7 +479,7 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
@@ -305,8 +490,8 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
]
},
{
@@ -326,7 +511,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -346,7 +531,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -384,9 +569,16 @@
" or SERVICE_ACCOUNT is None\n",
" or SERVICE_ACCOUNT == \"[your-service-account]\"\n",
"):\n",
" # Get your GCP project id from gcloud\n",
" shell_output = !gcloud auth list 2>/dev/null\n",
" SERVICE_ACCOUNT = shell_output[2].strip()\n",
" # Get your service account from gcloud\n",
" if not IS_COLAB:\n",
" shell_output = !gcloud auth list 2>/dev/null\n",
" SERVICE_ACCOUNT = shell_output[2].replace(\"*\", \"\").strip()\n",
"\n",
" if IS_COLAB:\n",
" shell_output = ! gcloud projects describe $PROJECT_ID\n",
" project_number = shell_output[-1].split(\":\")[1].strip().replace(\"'\", \"\")\n",
" SERVICE_ACCOUNT = f\"{project_number}-compute@developer.gserviceaccount.com\"\n",
"\n",
" print(\"Service Account:\", SERVICE_ACCOUNT)"
]
},
@@ -410,7 +602,7 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
"import google.cloud.aiplatform as aiplatform"
]
},
{
@@ -454,7 +646,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aiplatform.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -484,13 +676,15 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if os.getenv(\"IS_TESTING_TRAIN_GPU\"):\n",
" TRAIN_GPU, TRAIN_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" int(os.getenv(\"IS_TESTING_TRAIN_GPU\")),\n",
" )\n",
"else:\n",
" TRAIN_GPU, TRAIN_NGPU = (aip.gapic.AcceleratorType.NVIDIA_TESLA_K80, 1)"
" TRAIN_GPU, TRAIN_NGPU = (aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80, 1)"
]
},
{
@@ -591,9 +785,9 @@
"source": [
"## Training with TensorBoard\n",
"\n",
"Tensorboard provides the means to visualize your training in-real time and to visualize the results (metrics).\n",
"TensorBoard provides the means to visualize your training in-real time and to visualize the results (metrics).\n",
"\n",
"You can use Tensorboard in conjunction with local training, cloud training and with `Vertex AI Training`, which is referred to as `Vertex AI TensorBoard`"
"You can use TensorBoard in conjunction with local training, cloud training and with `Vertex AI Training`, which is referred to as `Vertex AI TensorBoard`"
]
},
{
@@ -663,9 +857,9 @@
"\n",
"You can upload your TensorBoard logs and share with others using `tensorboard dev` command. Once uploaded, a URL is returned to open up the TensorBoard instance in a brower for visualizing.\n",
"\n",
"*Note:* Your TensorBoard instance is publicly visable.\n",
"*Note:* Your TensorBoard instance is publicly visible.\n",
"\n",
"*Note:* In this example, while running within a notebook, the command will freeze since it is waiting for an interactive yes/no input. You can kill the command with a Ctrl C or kernel interupt.\n",
"*Note:* This cell is for demonstration purposes and must be ran in a terminal shell. In this example, while running within a notebook, the command will freeze since it is waiting for an interactive yes/no input. You can kill the command with a Ctrl C or kernel interupt.\n",
"\n",
"Learn more about [What is TensorBoard.dev](https://tensorboard.dev/)."
]
@@ -678,7 +872,7 @@
},
"outputs": [],
"source": [
"! tensorboard dev upload --logdir {LOG_DIR} \\\n",
"! tensorboard dev upload --logdir logs \\\n",
" --name \"Simple experiment with MNIST\" \\\n",
" --description \"Training results\" \\\n",
" --one_shot"
@@ -706,7 +900,7 @@
"outputs": [],
"source": [
"TENSORBOARD_DISPLAY_NAME = \"example\"\n",
"tensorboard = aip.Tensorboard.create(display_name=TENSORBOARD_DISPLAY_NAME)\n",
"tensorboard = aiplatform.Tensorboard.create(display_name=TENSORBOARD_DISPLAY_NAME)\n",
"tensorboard_resource_name = tensorboard.gca_resource.name\n",
"print(\"TensorBoard resource name:\", tensorboard_resource_name)"
]
@@ -746,9 +940,9 @@
"\n",
"url = output[1].split(' ')[-1]\n",
"\n",
"print(url)\n",
"#print(url)\n",
"\n",
"from IPython.core.display import display, HTML\n",
"from IPython.display import display, HTML\n",
"display(HTML(\"<a href='\" + url + \"'>click here for TensorBoard instance</a>\"))"
]
},
@@ -953,7 +1147,7 @@
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_example.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_example.tar.gz"
]
},
{
@@ -985,7 +1179,7 @@
},
"outputs": [],
"source": [
"job = aip.CustomTrainingJob(\n",
"job = aiplatform.CustomTrainingJob(\n",
" display_name=\"example_\" + TIMESTAMP,\n",
" script_path=\"custom/trainer/task.py\",\n",
" container_uri=TRAIN_IMAGE,\n",
@@ -1021,7 +1215,7 @@
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_NAME, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"\n",
"EPOCHS = 20\n",
"STEPS = 100\n",
@@ -1143,14 +1337,8 @@
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
]
},
@@ -1162,61 +1350,14 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"# Delete the custom training job\n",
"job.delete()\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"# Set this to true only if you'd like to delete your bucket\n",
"delete_bucket = False\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Training\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -39,8 +39,14 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -56,18 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Training."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training."
]
},
{
@@ -119,6 +114,38 @@
"CustomJob"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c480fc50ec3c"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -127,7 +154,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the packages required for executing this notebook"
]
},
{
@@ -138,20 +165,20 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q"
]
},
{
@@ -173,8 +200,6 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
" # Automatically restart kernel after installs\n",
" import IPython\n",
@@ -183,6 +208,36 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "before_you_begin"
},
"source": [
"## Before you begin\n",
"\n",
"### GPU runtime\n",
"\n",
"*Make sure you're running this notebook in a GPU runtime if you have that option. In Colab, select* **Runtime > Change Runtime Type > GPU**\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"2. [Make sure that billing is enabled for your project.](https://cloud.google.com/billing/docs/how-to/modify-project)\n",
"\n",
"3. [Enable the following APIs: Vertex AI APIs, Compute Engine APIs, and Cloud Storage.](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,compute_component,storage-component.googleapis.com)\n",
"\n",
"4. If you are running this notebook locally, you need to install the [Cloud SDK]((https://cloud.google.com/sdk)).\n",
"\n",
"5. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$`."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -259,7 +314,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -286,6 +344,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "gcp_authenticate"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"**Click Create service account**.\n",
"\n",
"In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex\" into the filter box, and select **Vertex Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "gcp_authenticate"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -309,7 +428,8 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -320,8 +440,9 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -341,7 +462,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -361,7 +482,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -384,7 +505,7 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
"import google.cloud.aiplatform as aiplatform"
]
},
{
@@ -406,7 +527,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aiplatform.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -441,7 +562,7 @@
"source": [
"if os.getenv(\"IS_TESTING_TRAIN_GPU\"):\n",
" TRAIN_GPU, TRAIN_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" int(os.getenv(\"IS_TESTING_TRAIN_GPU\")),\n",
" )\n",
"else:\n",
@@ -449,7 +570,7 @@
"\n",
"if os.getenv(\"IS_TESTING_DEPLOY_GPU\"):\n",
" DEPLOY_GPU, DEPLOY_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" int(os.getenv(\"IS_TESTING_DEPLOY_GPU\")),\n",
" )\n",
"else:\n",
@@ -484,7 +605,7 @@
"if os.getenv(\"IS_TESTING_TF\"):\n",
" TF = os.getenv(\"IS_TESTING_TF\")\n",
"else:\n",
" TF = \"2.1\".replace(\".\", \"-\")\n",
" TF = \"2.5\".replace(\".\", \"-\")\n",
"\n",
"if TF[0] == \"2\":\n",
" if TRAIN_GPU:\n",
@@ -602,7 +723,7 @@
"DISPLAY_NAME = \"boston_\" + TIMESTAMP\n",
"REQUIREMENTS = [\"tensorflow==2.3\"]\n",
"\n",
"job = aip.CustomTrainingJob(\n",
"job = aiplatform.CustomTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" script_path=\"task.py\",\n",
" requirements=REQUIREMENTS,\n",
@@ -693,12 +814,12 @@
"outputs": [],
"source": [
"CMDARGS = [\n",
" \"--model-dir=\" + BUCKET_NAME,\n",
" \"--model-dir=\" + BUCKET_URI,\n",
"]\n",
"\n",
"job.run(args=CMDARGS, replica_count=1, machine_type=TRAIN_COMPUTE, sync=True)\n",
"\n",
"! gsutil cat {BUCKET_NAME}/test.txt"
"! gsutil cat {BUCKET_URI}/test.txt"
]
},
{
@@ -768,9 +889,9 @@
"source": [
"DISPLAY_NAME = \"boston_\" + TIMESTAMP\n",
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
"job = aiplatform.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" python_package_gcs_uri=f\"{BUCKET_NAME}/trainer_boston.tar.gz\",\n",
" python_package_gcs_uri=f\"{BUCKET_URI}/trainer_boston.tar.gz\",\n",
" python_module_name=\"trainer.task\",\n",
" container_uri=TRAIN_IMAGE,\n",
")"
@@ -900,7 +1021,7 @@
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_boston.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_boston.tar.gz"
]
},
{
@@ -922,11 +1043,11 @@
},
"outputs": [],
"source": [
"CMDARGS = [\"--model-dir=\" + BUCKET_NAME, \"--epochs=5\"]\n",
"CMDARGS = [\"--model-dir=\" + BUCKET_URI, \"--epochs=5\"]\n",
"\n",
"job.run(args=CMDARGS, replica_count=1, machine_type=TRAIN_COMPUTE, sync=True)\n",
"\n",
"! gsutil cat {BUCKET_NAME}/test.txt"
"! gsutil cat {BUCKET_URI}/test.txt"
]
},
{
@@ -1151,7 +1272,11 @@
},
"outputs": [],
"source": [
"! docker build custom -t $TRAIN_IMAGE"
"if not IS_COLAB:\n",
" ! docker build custom -t $TRAIN_IMAGE\n",
"else:\n",
" # install docker daemon\n",
" ! apt-get -qq install docker.io"
]
},
{
@@ -1173,7 +1298,8 @@
},
"outputs": [],
"source": [
"! docker run $TRAIN_IMAGE --epochs=5 --model-dir=./"
"if not IS_COLAB:\n",
" ! docker run $TRAIN_IMAGE --epochs=5 --model-dir=./"
]
},
{
@@ -1195,7 +1321,38 @@
},
"outputs": [],
"source": [
"! docker push $TRAIN_IMAGE"
"if not IS_COLAB:\n",
" ! docker push $TRAIN_IMAGE"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f50e9c553fb7"
},
"source": [
"*Executes in Colab*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a7e8c98f1e56"
},
"outputs": [],
"source": [
"%%bash -s $IS_COLAB $TRAIN_IMAGE\n",
"if [ $1 == \"False\" ]; then\n",
" exit 0\n",
"fi\n",
"set -x\n",
"dockerd -b none --iptables=0 -l warn &\n",
"for i in $(seq 5); do [ ! -S \"/var/run/docker.sock\" ] && sleep 2 || break; done\n",
"docker build custom -t $2\n",
"docker run $2 --epochs=5 --model-dir=./\n",
"docker push $2\n",
"kill $(jobs -p)"
]
},
{
@@ -1229,7 +1386,7 @@
},
"outputs": [],
"source": [
"job = aip.CustomContainerTrainingJob(\n",
"job = aiplatform.CustomContainerTrainingJob(\n",
" display_name=\"boston_\" + TIMESTAMP,\n",
" container_uri=TRAIN_IMAGE,\n",
" command=[\"python3\", \"trainer/task.py\"],\n",
@@ -1257,11 +1414,11 @@
},
"outputs": [],
"source": [
"CMDARGS = [\"--model-dir=\" + BUCKET_NAME, \"--epochs=5\"]\n",
"CMDARGS = [\"--model-dir=\" + BUCKET_URI, \"--epochs=5\"]\n",
"\n",
"job.run(args=CMDARGS, replica_count=1, machine_type=TRAIN_COMPUTE, sync=True)\n",
"\n",
"! gsutil cat {BUCKET_NAME}/test.txt"
"! gsutil cat {BUCKET_URI}/test.txt"
]
},
{
@@ -1466,7 +1623,7 @@
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_boston.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_boston.tar.gz"
]
},
{
@@ -1496,7 +1653,7 @@
"if os.getenv(\"IS_TESTING_TF\"):\n",
" TF = os.getenv(\"IS_TESTING_TF\")\n",
"else:\n",
" TF = \"2.1\".replace(\".\", \"-\")\n",
" TF = \"2.5\".replace(\".\", \"-\")\n",
"\n",
"if TF[0] == \"2\":\n",
" if TRAIN_GPU:\n",
@@ -1551,9 +1708,9 @@
"source": [
"DISPLAY_NAME = \"boston_\" + TIMESTAMP\n",
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
"job = aiplatform.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" python_package_gcs_uri=f\"{BUCKET_NAME}/trainer_boston.tar.gz\",\n",
" python_package_gcs_uri=f\"{BUCKET_URI}/trainer_boston.tar.gz\",\n",
" python_module_name=\"trainer.task\",\n",
" container_uri=TRAIN_IMAGE,\n",
" model_serving_container_image_uri=DEPLOY_IMAGE,\n",
@@ -1587,12 +1744,12 @@
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_NAME, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"\n",
"EPOCHS = 20\n",
"STEPS = 100\n",
"\n",
"DIRECT = True\n",
"DIRECT = False\n",
"if DIRECT:\n",
" CMDARGS = [\n",
" \"--model-dir=\" + MODEL_DIR,\n",
@@ -1758,17 +1915,7 @@
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
"Otherwise, you can delete the individual resources you created in this tutorial."
]
},
{
@@ -1779,61 +1926,24 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"delete_bucket = False\n",
"delete_model = True\n",
"delete_job = True\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
"if delete_model:\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
"if delete_job:\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -rf {BUCKET_URI}"
]
}
],
File diff suppressed because it is too large Load Diff
@@ -29,18 +29,24 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Training for Pytorch\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for Pytorch\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_pytorch.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_pytorch.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_pytorch.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/notebook_template.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -56,18 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Training for Pytorch."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:pytorch,cifar10,icn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [CIFAR10 dataset](https://pytorch.org/vision/stable/datasets.html#cifar) from [Pytorch Datasets](https://pytorch.org/vision/stable/datasets.html). The version of the dataset you will use is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, or truck."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for Pytorch."
]
},
{
@@ -82,8 +77,9 @@
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `Vertex AI Training`\n",
"- `Vertex AI Model` resource\n",
"* `Vertex AI Training`\n",
"* `Vertex AI Model` resource\n",
"\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -93,6 +89,86 @@
"- Create a `Vertex AI Model` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:pytorch,cifar10,icn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [CIFAR10 dataset](https://pytorch.org/vision/stable/datasets.html#cifar) from [Pytorch Datasets](https://pytorch.org/vision/stable/datasets.html). The version of the dataset is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, or truck."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "85ee859437ed"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5cd61a5dd9db"
},
"source": [
"### Set up your local development environment\n",
"\n",
"**If you are using Colab or Vertex AI Workbench Notebooks**, your environment already meets\n",
"all the requirements to run this notebook. You can skip this step."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "7e689ee0bc3c"
},
"source": [
"**Otherwise**, make sure your environment meets this notebook's requirements.\n",
"You need the following:\n",
"\n",
"* The Google Cloud SDK\n",
"* Git\n",
"* Python 3\n",
"* virtualenv\n",
"* Jupyter notebook running in a virtual environment with Python 3\n",
"\n",
"The Google Cloud guide to [Setting up a Python development\n",
"environment](https://cloud.google.com/python/setup) and the [Jupyter\n",
"installation guide](https://jupyter.org/install) provide detailed instructions\n",
"for meeting these requirements. The following steps provide a condensed set of\n",
"instructions:\n",
"\n",
"1. [Install and initialize the Cloud SDK.](https://cloud.google.com/sdk/docs/)\n",
"\n",
"1. [Install Python 3.](https://cloud.google.com/python/setup#installing_python)\n",
"\n",
"1. [Install\n",
" virtualenv](https://cloud.google.com/python/setup#installing_and_using_virtualenv)\n",
" and create a virtual environment that uses Python 3. Activate the virtual environment.\n",
"\n",
"1. To install Jupyter, run `pip3 install jupyter` on the\n",
"command-line in a terminal shell.\n",
"\n",
"1. To launch Jupyter, run `jupyter notebook` on the command-line in a terminal shell.\n",
"\n",
"1. Open this notebook in the Jupyter Notebook Dashboard."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -101,7 +177,7 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the following packages to execute this notebook."
]
},
{
@@ -112,22 +188,22 @@
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG\n",
" ! pip3 install --upgrade torchvision $USER_FLAG\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install --upgrade cloudml-hypertune $USER_FLAG -q\n",
"! pip3 install --upgrade torchvision $USER_FLAG -q"
]
},
{
@@ -159,6 +235,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -235,7 +337,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -262,6 +367,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -285,7 +451,7 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
@@ -296,8 +462,8 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
]
},
{
@@ -317,7 +483,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -337,7 +503,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -360,7 +526,7 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
"import google.cloud.aiplatform as aiplatform"
]
},
{
@@ -382,7 +548,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aiplatform.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -412,13 +578,15 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if os.getenv(\"IS_TESTING_TRAIN_GPU\"):\n",
" TRAIN_GPU, TRAIN_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
" int(os.getenv(\"IS_TESTING_TRAIN_GPU\")),\n",
" )\n",
"else:\n",
" TRAIN_GPU, TRAIN_NGPU = (aip.gapic.AcceleratorType.NVIDIA_TESLA_K80, 1)"
" TRAIN_GPU, TRAIN_NGPU = (aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80, 1)"
]
},
{
@@ -561,6 +729,7 @@
"# Add package information\n",
"! touch custom/README.md\n",
"\n",
"# Instructions for installing package into environment of the docker image\n",
"setup_cfg = \"[egg_info]\\n\\ntag_build =\\n\\ntag_date = 0\"\n",
"! echo \"$setup_cfg\" > custom/setup.cfg\n",
"\n",
@@ -891,7 +1060,7 @@
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_cifar10.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_cifar10.tar.gz"
]
},
{
@@ -902,7 +1071,7 @@
"source": [
"### Make Pytorch container for prediction\n",
"\n",
"Currently, Vertex AI does not have a prefined container for making predictions with a deployed Pytorch model. No problem, you can assemble your own custom container. Typically, one would base the container on the `Torch Server`. For demonstration purpose, you build a placeholder container (not complete) that includes the latest `Torch Server` image, and push it to the `Container Registry`."
"Currently, Vertex AI does not have a predefined container for making predictions with a deployed Pytorch model. No problem, you can assemble your own custom container. Typically, one would base the container on the `Torch Server`. For demonstration purpose, you build a placeholder container (not complete) that includes the latest `Torch Server` image, and push it to the `Container Registry`."
]
},
{
@@ -932,11 +1101,52 @@
"source": [
"APP_NAME = \"cifar10\"\n",
"DEPLOY_IMAGE = f\"gcr.io/{PROJECT_ID}/pytorch_predict_{APP_NAME}\"\n",
"print(DEPLOY_IMAGE)\n",
"\n",
"! docker build --tag=$DEPLOY_IMAGE ./\n",
"\n",
"! docker push $DEPLOY_IMAGE"
"print(DEPLOY_IMAGE)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "85739262f629"
},
"outputs": [],
"source": [
"if not IS_COLAB:\n",
" ! docker build --tag=$DEPLOY_IMAGE ./\n",
" ! docker push $DEPLOY_IMAGE\n",
"else:\n",
" # install docker daemon\n",
" ! apt-get -qq install docker.io"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f50e9c553fb7"
},
"source": [
"*Executes in Colab*"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "a7e8c98f1e56"
},
"outputs": [],
"source": [
"%%bash -s $IS_COLAB $DEPLOY_IMAGE\n",
"if [ $1 == \"False\" ]; then\n",
" exit 0\n",
"fi\n",
"set -x\n",
"dockerd -b none --iptables=0 -l warn &\n",
"for i in $(seq 5); do [ ! -S \"/var/run/docker.sock\" ] && sleep 2 || break; done\n",
"docker build --tag=$2 ./\n",
"docker push $2\n",
"kill $(jobs -p)"
]
},
{
@@ -974,9 +1184,9 @@
"source": [
"DISPLAY_NAME = \"cifar10_\" + TIMESTAMP\n",
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
"job = aiplatform.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" python_package_gcs_uri=f\"{BUCKET_NAME}/trainer_cifar10.tar.gz\",\n",
" python_package_gcs_uri=f\"{BUCKET_URI}/trainer_cifar10.tar.gz\",\n",
" python_module_name=\"trainer.task\",\n",
" container_uri=TRAIN_IMAGE,\n",
" model_serving_container_image_uri=DEPLOY_IMAGE,\n",
@@ -1009,7 +1219,7 @@
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_NAME, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"\n",
"DIRECT = False\n",
"if DIRECT:\n",
@@ -1121,7 +1331,7 @@
"source": [
"### Delete a custom training job\n",
"\n",
"After a training job is completed, you can delete the training job with the method `delete()`. Prior to completion, a training job can be canceled with the method `cancel()`."
"After a training job is completed, you can delete the training job with the method `delete()`. Prior to completion, a training job can be cancelled with the method `cancel()`."
]
},
{
@@ -1148,14 +1358,7 @@
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
]
},
@@ -1167,61 +1370,12 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"# Delete the model using the Vertex model object\n",
"model.delete()\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"delete_bucket = False\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Training for R\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for R\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -39,8 +39,14 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_r.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_r.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_r.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -56,18 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Training for R."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:r,iris,lcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the Iris dataset built into the R package. This dataset does not require any feature engineering. The trained model predicts the type of Iris flower species from a class of three species: setosa, virginica, or versicolor."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for R. Please note that this notebook should be ran only in R notebook image (e.g., R4.1)."
]
},
{
@@ -98,6 +93,39 @@
"- Train a R model using `Vertex AI Trainingh` service with the R-to-Python training package."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:r,iris,lcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the Iris dataset built into the R package. This dataset does not require any feature engineering. The trained model predicts the type of Iris flower species from a class of three species: setosa, virginica, or versicolor."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0c997d8d92ce"
},
"source": [
"### Costs \n",
"\n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -106,33 +134,32 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the packages required for executing this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_mlops"
"id": "1fd00fa70a2a"
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG\n",
" ! pip3 install --upgrade torchvision $USER_FLAG\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q\n",
"! pip3 install --upgrade rpy2 $USER_FLAG -q"
]
},
{
@@ -164,6 +191,39 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0e3cab0cc491"
},
"source": [
"## Before you begin"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "be929e7b4d76"
},
"source": [
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). \n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -240,7 +300,9 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type:\"string\"}\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -267,6 +329,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "3ffa6b6c7cdb"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "2b72272258fc"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -277,7 +400,7 @@
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you initialize the Vertex SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"When you initialize the Vertex AI SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
@@ -290,7 +413,7 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
@@ -301,8 +424,8 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
]
},
{
@@ -322,7 +445,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -342,7 +465,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -365,6 +488,8 @@
},
"outputs": [],
"source": [
"import traceback\n",
"\n",
"import google.cloud.aiplatform as aip"
]
},
@@ -387,7 +512,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -964,14 +1089,17 @@
},
"outputs": [],
"source": [
"INSTANCES = [\n",
" {\"sepal_width\": 1, \"sepal_length\": 2, \"petal_width\": 3, \"petal_length\": 1},\n",
" {\"sepal_width\": 4, \"sepal_length\": 2, \"petal_width\": 1, \"petal_length\": 1},\n",
"]\n",
"try:\n",
" INSTANCES = [\n",
" {\"sepal_width\": 1, \"sepal_length\": 2, \"petal_width\": 3, \"petal_length\": 1},\n",
" {\"sepal_width\": 4, \"sepal_length\": 2, \"petal_width\": 1, \"petal_length\": 1},\n",
" ]\n",
"\n",
"prediction = endpoint.predict(instances=INSTANCES)\n",
" prediction = endpoint.predict(instances=INSTANCES)\n",
"\n",
"print(prediction)"
" print(prediction)\n",
"except:\n",
" traceback.print_exc()"
]
},
{
@@ -1242,7 +1370,7 @@
},
"outputs": [],
"source": [
"CMDARGS = [\"--model-dir=\" + BUCKET_NAME]\n",
"CMDARGS = [\"--model-dir=\" + BUCKET_URI]\n",
"\n",
"job.run(args=CMDARGS, replica_count=1, machine_type=TRAIN_COMPUTE, sync=True)"
]
@@ -1282,14 +1410,9 @@
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Model (Already deleted in previous cells)\n",
"- Endpoint (Already deleted in previous cells)\n",
"- Custom Job (Already deleted in previous cells)\n",
"- Cloud Storage Bucket"
]
},
@@ -1301,61 +1424,10 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"delete_bucket = False\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -29,18 +29,24 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Training for Scikit-Learn\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for Scikit-Learn\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
"Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -56,18 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Training for Scikit-Learn."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,newsaggr,tcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [News Aggregation](https://archive.ics.uci.edu/ml/datasets/News+Aggregator) from [ICS Machine Learning Datasets](https://archive.ics.uci.edu/ml/datasets.php). The trained model predicts the news category of the news article."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for scikit-Learn."
]
},
{
@@ -93,41 +88,112 @@
"- Create a `Vertex AI Model` resource."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,newsaggr,tcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [News Aggregation](https://archive.ics.uci.edu/ml/datasets/News+Aggregator) from [ICS Machine Learning Datasets](https://archive.ics.uci.edu/ml/datasets.php). The trained model predicts the news category of the news article."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "b132d4ef86d6"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "94a148f11da5"
},
"source": [
"### Set up your local development environment\n",
"\n",
"**If you are using Colab or Vertex AI Workbench Notebooks**, your environment already meets\n",
"all the requirements to run this notebook. You can skip this step.\n",
"\n",
"**Otherwise**, make sure your environment meets this notebook's requirements.\n",
"You need the following:\n",
"\n",
"* The Google Cloud SDK\n",
"* Git\n",
"* Python 3\n",
"* virtualenv\n",
"* Jupyter notebook running in a virtual environment with Python 3\n",
"\n",
"The Google Cloud guide to [Setting up a Python development\n",
"environment](https://cloud.google.com/python/setup) and the [Jupyter\n",
"installation guide](https://jupyter.org/install) provide detailed instructions\n",
"for meeting these requirements. The following steps provide a condensed set of\n",
"instructions:\n",
"\n",
"1. [Install and initialize the Cloud SDK.](https://cloud.google.com/sdk/docs/)\n",
"\n",
"1. [Install Python 3.](https://cloud.google.com/python/setup#installing_python)\n",
"\n",
"1. [Install\n",
" virtualenv](https://cloud.google.com/python/setup#installing_and_using_virtualenv)\n",
" and create a virtual environment that uses Python 3. Activate the virtual environment.\n",
"\n",
"1. To install Jupyter, run `pip3 install jupyter` on the\n",
"command-line in a terminal shell.\n",
"\n",
"1. To launch Jupyter, run `jupyter notebook` on the command-line in a terminal shell.\n",
"\n",
"1. Open this notebook in the Jupyter Notebook Dashboard.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "install_mlops"
},
"source": [
"## Installations\n",
"## Installation\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the following packages for executing this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_mlops"
"id": "78168417490e"
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG\n",
" ! pip3 install --upgrade torchvision $USER_FLAG\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install {USER_FLAG} --upgrade google-cloud-aiplatform -q"
]
},
{
@@ -159,6 +225,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2721ef0202d9"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). \n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -235,7 +327,10 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -262,6 +357,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -285,7 +441,7 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
@@ -296,8 +452,8 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
]
},
{
@@ -317,7 +473,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -337,7 +493,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -382,7 +538,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -415,6 +571,8 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if os.getenv(\"IS_TESTING_TRAIN_GPU\"):\n",
" TRAIN_GPU, TRAIN_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
@@ -517,9 +675,9 @@
"id": "sklearn_intro"
},
"source": [
"## Introduction to Scikit-learn training\n",
"## Introduction to scikit-learn training\n",
"\n",
"Once you have trained a Scikit-learn model, you will want to save it at a Cloud Storage location, so it can subsequently be uploaded to a `Vertex AI Model` resource. The Scikit-learn package does not have support to save the model to a Cloud Storage location. Instead, you will do the following steps to save to a Cloud Storage location.\n",
"Once you have trained a scikit-learn model, you will want to save it at a Cloud Storage location, so it can subsequently be uploaded to a `Vertex AI Model` resource. The Scikit-learn package does not have support to save the model to a Cloud Storage location. Instead, you will do the following steps to save to a Cloud Storage location.\n",
"\n",
"1. Save the in-memory model to the local filesystem in pickle format (e.g., model.pkl).\n",
"2. Create a Cloud Storage storage client.\n",
@@ -783,7 +941,7 @@
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_newsaggr.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_newsaggr.tar.gz"
]
},
{
@@ -823,7 +981,7 @@
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" python_package_gcs_uri=f\"{BUCKET_NAME}/trainer_newsaggr.tar.gz\",\n",
" python_package_gcs_uri=f\"{BUCKET_URI}/trainer_newsaggr.tar.gz\",\n",
" python_module_name=\"trainer.task\",\n",
" container_uri=TRAIN_IMAGE,\n",
" model_serving_container_image_uri=DEPLOY_IMAGE,\n",
@@ -857,7 +1015,7 @@
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_NAME, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"DATASET_URL = \"https://archive.ics.uci.edu/ml/machine-learning-databases/00359/NewsAggregatorDataset.zip\"\n",
"\n",
"DIRECT = False\n",
@@ -1002,14 +1160,8 @@
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
]
},
@@ -1017,65 +1169,16 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cleanup:mbsdk"
"id": "b413063dfdcf"
},
"outputs": [],
"source": [
"delete_all = True\n",
"# Delete the model using the Vertex model object\n",
"model.delete()\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"delete_bucket = False\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -29,9 +29,15 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Training for XGBoost\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for XGBoost\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_xgboost.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" \n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_xgboost.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
@@ -39,8 +45,9 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_xgboost.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_xgboost.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -56,18 +63,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Training for XGBoost."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:iris,lcn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Iris dataset](https://www.tensorflow.org/datasets/catalog/iris) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). This dataset does not require any feature engineering. The version of the dataset you will use in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of Iris flower species from a class of three species: setosa, virginica, or versicolor."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for XGBoost."
]
},
{
@@ -96,59 +92,90 @@
{
"cell_type": "markdown",
"metadata": {
"id": "install_mlops"
"id": "dataset:iris,lcn"
},
"source": [
"## Installations\n",
"### Dataset\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_mlops"
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG\n",
" ! pip3 install --upgrade torchvision $USER_FLAG\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG"
"The dataset used for this tutorial is the [Iris dataset](https://www.tensorflow.org/datasets/catalog/iris) from [TensorFlow Datasets](https://www.tensorflow.org/datasets/catalog/overview). This dataset does not require any feature engineering. The version of the dataset in this tutorial is stored in a public Cloud Storage bucket. The trained model predicts the type of Iris flower species from a class of three species: setosa, virginica, or versicolor."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "restart"
"id": "4fc0ad661ebb"
},
"source": [
"### Restart the kernel\n",
"### Costs \n",
"\n",
"Once you've installed the additional packages, you need to restart the notebook kernel so it can find the packages."
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "install_mlops"
},
"source": [
"## Installations\n",
"\n",
"Install the following packages to execute this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "restart"
"id": "ncRJ_Dfdox9L"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "oQhwq1iozAxh"
},
"source": [
"### Restart the kernel\n",
"\n",
"After you install the additional packages, you need to restart the notebook kernel so it can find the packages."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "zo3YFZXLzCRJ"
},
"outputs": [],
"source": [
"# Automatically restart kernel after installs\n",
"import os\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
@@ -159,6 +186,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2721ef0202d9"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). \n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -231,11 +284,14 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "region"
"id": "sKBTnvJpox9P"
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type:\"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\" # @param {type: \"string\"}"
]
},
{
@@ -253,7 +309,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
"id": "JYtXOocrox9Q"
},
"outputs": [],
"source": [
@@ -262,6 +318,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "NNc5Bf_NpPTq"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -272,7 +389,7 @@
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you initialize the Vertex SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"When you initialize the Vertex AI SDK for Python, you specify a Cloud Storage staging bucket. The staging bucket is where all the data associated with your dataset and model resources are retained across sessions.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
@@ -285,7 +402,7 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
@@ -296,8 +413,8 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
]
},
{
@@ -313,11 +430,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
"id": "aO4sKJfFox9R"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -333,11 +450,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
"id": "yWnghzKFox9S"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -378,11 +495,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "init_aip:mbsdk"
"id": "JZg2sszQox9T"
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -411,10 +528,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "accelerators:training,cpu,prediction,cpu,mbsdk"
"id": "cQUrG4Mbox9T"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if os.getenv(\"IS_TESTING_TRAIN_GPU\"):\n",
" TRAIN_GPU, TRAIN_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
@@ -453,7 +572,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "container:training,prediction,xgboost"
"id": "XujRA5ueox9U"
},
"outputs": [],
"source": [
@@ -497,7 +616,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "machine:training"
"id": "UMPFgENkox9U"
},
"outputs": [],
"source": [
@@ -561,7 +680,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "examine_training_package:xgboost"
"id": "f4wS4eISox9V"
},
"outputs": [],
"source": [
@@ -616,7 +735,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "taskpy_contents:iris,xgboost"
"id": "WiSnFuDoox9W"
},
"outputs": [],
"source": [
@@ -731,14 +850,14 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "tarball_training_script"
"id": "dnmdycf6ox9X"
},
"outputs": [],
"source": [
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_iris.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_iris.tar.gz"
]
},
{
@@ -770,7 +889,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_custom_pp_training_job:mbsdk"
"id": "rVEMz1xqox9X"
},
"outputs": [],
"source": [
@@ -778,7 +897,7 @@
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
" python_package_gcs_uri=f\"{BUCKET_NAME}/trainer_iris.tar.gz\",\n",
" python_package_gcs_uri=f\"{BUCKET_URI}/trainer_iris.tar.gz\",\n",
" python_module_name=\"trainer.task\",\n",
" container_uri=TRAIN_IMAGE,\n",
" model_serving_container_image_uri=DEPLOY_IMAGE,\n",
@@ -809,11 +928,11 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "prepare_custom_cmdargs:iris,xgboost"
"id": "AoUfpBqVox9Y"
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_NAME, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"DATASET_DIR = \"gs://cloud-samples-data/ai-platform/iris\"\n",
"\n",
"ROUNDS = 20\n",
@@ -858,7 +977,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "run_custom_job:mbsdk"
"id": "JCruQq1aox9Y"
},
"outputs": [],
"source": [
@@ -899,7 +1018,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "list_job"
"id": "KBM_KLMSox9Y"
},
"outputs": [],
"source": [
@@ -922,7 +1041,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "custom_job_wait:mbsdk"
"id": "lHPMHbSyox9Z"
},
"outputs": [],
"source": [
@@ -944,7 +1063,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "delete_job"
"id": "tlYg7Sp-ox9Z"
},
"outputs": [],
"source": [
@@ -964,14 +1083,7 @@
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Custom Job (Custome Training job is remove in previous step)\n",
"- Cloud Storage Bucket"
]
},
@@ -979,65 +1091,14 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cleanup:mbsdk"
"id": "JyWy23gDox9a"
},
"outputs": [],
"source": [
"delete_all = True\n",
"delete_bucket = False\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
@@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex Vizier\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Vizier\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -39,10 +39,16 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_vizier.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" </a>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_vizier.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_vizier.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td> \n",
"</table>\n",
"<br/><br/><br/>"
]
@@ -56,18 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex Vizier."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset you will use in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Vizier."
]
},
{
@@ -128,6 +123,38 @@
"- multiple of objectives"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:custom,boston,lrg"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Boston Housing Prices dataset](https://www.cs.toronto.edu/~delve/data/boston/bostonDetail.html). The version of the dataset in this tutorial is built into TensorFlow. The trained model predicts the median price of a house in units of 1K USD."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "c480fc50ec3c"
},
"source": [
"### Costs \n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing) and [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -136,31 +163,31 @@
"source": [
"## Installations\n",
"\n",
"Install *one time* the packages for executing the MLOps notebooks."
"Install the packages required for executing this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_mlops"
"id": "1fd00fa70a2a"
},
"outputs": [],
"source": [
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG"
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q"
]
},
{
@@ -192,6 +219,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2721ef0202d9"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). \n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -268,7 +321,9 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type:\"string\"}\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -295,6 +350,67 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "gcp_authenticate"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"**Click Create service account**.\n",
"\n",
"In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex\" into the filter box, and select **Vertex Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "gcp_authenticate"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -318,7 +434,7 @@
},
"outputs": [],
"source": [
"BUCKET_NAME = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
]
},
{
@@ -329,8 +445,8 @@
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
]
},
{
@@ -350,7 +466,7 @@
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_NAME"
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
@@ -370,7 +486,7 @@
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_NAME"
"! gsutil ls -al $BUCKET_URI"
]
},
{
@@ -415,7 +531,7 @@
},
"outputs": [],
"source": [
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_NAME)"
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
@@ -808,7 +924,7 @@
"! rm -f custom.tar custom.tar.gz\n",
"! tar cvf custom.tar custom\n",
"! gzip custom.tar\n",
"! gsutil cp custom.tar.gz $BUCKET_NAME/trainer_boston.tar.gz"
"! gsutil cp custom.tar.gz $BUCKET_URI/trainer_boston.tar.gz"
]
},
{
@@ -916,7 +1032,7 @@
"outputs": [],
"source": [
"JOB_NAME = \"custom_job_\" + TIMESTAMP\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_NAME, JOB_NAME)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, JOB_NAME)\n",
"\n",
"if not TRAIN_NGPU or TRAIN_NGPU < 2:\n",
" TRAIN_STRATEGY = \"single\"\n",
@@ -948,7 +1064,7 @@
" \"disk_spec\": disk_spec,\n",
" \"python_package_spec\": {\n",
" \"executor_image_uri\": TRAIN_IMAGE,\n",
" \"package_uris\": [BUCKET_NAME + \"/trainer_boston.tar.gz\"],\n",
" \"package_uris\": [BUCKET_URI + \"/trainer_boston.tar.gz\"],\n",
" \"python_module\": \"trainer.task\",\n",
" \"args\": CMDARGS,\n",
" },\n",
@@ -1180,7 +1296,8 @@
"Use the class `CustomJob` to create a custom job, such as for hyperparameter tuning, with the following parameters:\n",
"\n",
"- `display_name`: A human readable name for the custom job.\n",
"- `worker_pool_specs`: The specification for the corresponding VM instances."
"- `worker_pool_specs`: The specification for the corresponding VM instances.\n",
"- `base_output_dir`: The Cloud Storage location for storing the model artifacts."
]
},
{
@@ -1192,7 +1309,9 @@
"outputs": [],
"source": [
"job = aip.CustomJob(\n",
" display_name=\"boston_\" + TIMESTAMP, worker_pool_specs=worker_pool_spec\n",
" display_name=\"boston_\" + TIMESTAMP,\n",
" worker_pool_specs=worker_pool_spec,\n",
" base_output_dir=MODEL_DIR,\n",
")"
]
},
@@ -1325,6 +1444,32 @@
"print(best)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "get_best_model"
},
"source": [
"### Get the Best Model\n",
"\n",
"If you used the method of having the service tell the tuning script where to save the model artifacts (`DIRECT = False`), then the model artifacts for the best model are saved at:\n",
"\n",
" MODEL_DIR/<best_trial_id>/model"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "get_best_model"
},
"outputs": [],
"source": [
"BEST_MODEL_DIR = MODEL_DIR + \"/\" + best[0] + \"/model\"\n",
"\n",
"! gsutil ls {BEST_MODEL_DIR}"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -1577,14 +1722,6 @@
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial:\n",
"\n",
"- Dataset\n",
"- Pipeline\n",
"- Model\n",
"- Endpoint\n",
"- AutoML Training Job\n",
"- Batch Job\n",
"- Custom Job\n",
"- Hyperparameter Tuning Job\n",
"- Cloud Storage Bucket"
]
},
@@ -1596,61 +1733,10 @@
},
"outputs": [],
"source": [
"delete_all = True\n",
"delete_bucket = False\n",
"\n",
"if delete_all:\n",
" # Delete the dataset using the Vertex dataset object\n",
" try:\n",
" if \"dataset\" in globals():\n",
" dataset.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the model using the Vertex model object\n",
" try:\n",
" if \"model\" in globals():\n",
" model.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the endpoint using the Vertex endpoint object\n",
" try:\n",
" if \"endpoint\" in globals():\n",
" endpoint.undeploy_all()\n",
" endpoint.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the AutoML or Pipeline training job\n",
" try:\n",
" if \"dag\" in globals():\n",
" dag.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the custom training job\n",
" try:\n",
" if \"job\" in globals():\n",
" job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the batch prediction job using the Vertex batch prediction object\n",
" try:\n",
" if \"batch_predict_job\" in globals():\n",
" batch_predict_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" # Delete the hyperparameter tuning job using the Vertex hyperparameter tuning object\n",
" try:\n",
" if \"hpt_job\" in globals():\n",
" hpt_job.delete()\n",
" except Exception as e:\n",
" print(e)\n",
"\n",
" if \"BUCKET_NAME\" in globals():\n",
" ! gsutil rm -r $BUCKET_NAME"
"if os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
]
}
],
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,710 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "copyright"
},
"outputs": [],
"source": [
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"#\n",
"# https://www.apache.org/licenses/LICENSE-2.0\n",
"#\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Logging\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_with_logging.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_with_logging.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_with_logging.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
"<br/><br/><br/>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "overview:mlops"
},
"source": [
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Logging."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "objective:mlops,stage2,get_started_vertex_experiments"
},
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use Python and Cloud logging awhen training with `Vertex AI`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `Cloud Logging`\n",
"\n",
"The steps performed include:\n",
"\n",
"- Use Python logging to log training configuration/results locally.\n",
"- Use Google Cloud Logging to log training configuration/results in cloud storage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "recommendation:mlops,stage2,logging"
},
"source": [
"### Recommendations\n",
"\n",
"When doing E2E MLOps on Google Cloud, the following are some of the best practices for logging data when experimenting or formally training a model.\n",
"\n",
"#### Python Logging\n",
"\n",
"Use Python's logging package when doing ad-hoc training locally.\n",
"\n",
"#### Cloud Logging\n",
"\n",
"Use `Google Cloud Logging` when doing training on the cloud.\n",
"\n",
"#### Experiments\n",
"\n",
"Use Vertex AI Experiments in conjunction with logging when performing experiments to compare results for different experiment configurations."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5341f31587c8"
},
"source": [
"### Dataset\n",
"\n",
"This tutorial does not use a dataset. References to example datasets is for demonstration purposes."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "41512a89f379"
},
"source": [
"### Costs\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"- Vertex AI\n",
"\n",
"Learn about [Vertex AI pricing](https://cloud.google.com/vertex-ai/pricing) and use the [Pricing Calculator](https://cloud.google.com/products/calculator/) to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "install_mlops"
},
"source": [
"## Installations\n",
"\n",
"Install the following packages for executing this notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "install_mlops"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-logging $USER_FLAG -q"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "restart"
},
"source": [
"### Restart the kernel\n",
"\n",
"Once you've installed the additional packages, you need to restart the notebook kernel so it can find the packages."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "restart"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
" # Automatically restart kernel after installs\n",
" import IPython\n",
"\n",
" app = IPython.Application.instance()\n",
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "project_id"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, Compute Engine, Cloud Storage and Cloud Logging APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,compute_component,storage_component,logging).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "5aee4379e8e5"
},
"source": [
"#### Set your project ID\n",
"\n",
"**If you don't know your project ID**, you may be able to get your project ID using `gcloud`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_project_id"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_project_id"
},
"outputs": [],
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n",
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_gcloud_project_id"
},
"outputs": [],
"source": [
"! gcloud config set project $PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "region"
},
"source": [
"#### Region\n",
"\n",
"You can also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
"\n",
"- Americas: `us-central1`\n",
"- Europe: `europe-west4`\n",
"- Asia Pacific: `asia-east1`\n",
"\n",
"You may not use a multi-regional bucket for training with Vertex AI. Not all regions provide support for all Vertex AI services.\n",
"\n",
"Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "region"
},
"outputs": [],
"source": [
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "f3bd8c0d0469"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "e0953a00668e"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "setup_vars"
},
"source": [
"### Set up variables\n",
"\n",
"Next, set up some variables used throughout the tutorial.\n",
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "import_aip:mbsdk"
},
"outputs": [],
"source": [
"import logging\n",
"\n",
"import google.cloud.aiplatform as aiplatform"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "init_aip:mbsdk,region"
},
"source": [
"### Initialize Vertex AI SDK for Python\n",
"\n",
"Initialize the Vertex AI SDK for Python for your project and corresponding bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "init_aip:mbsdk,region"
},
"outputs": [],
"source": [
"aiplatform.init(project=PROJECT_ID, location=REGION)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "python_logging"
},
"source": [
"## Python Logging\n",
"\n",
"The Python logging package is widely used for logging within Python scripts. Commonly used features:\n",
"\n",
"- Set logging levels.\n",
"- Send log output to console.\n",
"- Send log output to a file.\n",
"\n",
"### Logging Levels in Python Logging\n",
"\n",
"The logging levels in order (from least to highest) and each level inclusive of the previous level are :\n",
"\n",
"1. Informational\n",
"2. Warnings\n",
"3. Errors\n",
"4. Debugging\n",
"\n",
"By default, the logging level is set to error level.\n",
"\n",
"### Logging output to console\n",
"\n",
"By default, the Python logging package outputs to the console. Note, in the example the debug log message is not outputted since the default logging level is set to error."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "python_logging"
},
"outputs": [],
"source": [
"def logging_examples():\n",
" logging.info(\"Model training started...\")\n",
" logging.warning(\"Using older version of package ...\")\n",
" logging.error(\"Training was terminated ...\")\n",
" logging.debug(\"Hyperparameters were ...\")\n",
"\n",
"\n",
"logging_examples()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "python_logging_level"
},
"source": [
"### Setting logging level\n",
"\n",
"To set the logging level, you get the logging handler using `getLogger()`. You can have multiple logging handles. When `getLogger()` is called without any arguments, it gets the default handler named ROOT. With the handler, you set the logging level with the method `setLevel()`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "python_logging_level"
},
"outputs": [],
"source": [
"logging.getLogger().setLevel(logging.DEBUG)\n",
"\n",
"logging_examples()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "python_logging_remove"
},
"source": [
"### Clearing handlers\n",
"\n",
"At times, you may desire to reconfigure your logging. A common practice in this case is to first remove all existing logging handles for a fresh start."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "python_logging_remove"
},
"outputs": [],
"source": [
"for handler in logging.root.handlers[:]:\n",
" logging.root.removeHandler(handler)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "python_logging_file"
},
"source": [
"### Output to a local file\n",
"\n",
"You can preserve your logging output to a file that is local to where the Python script is running with the method `BasicConfig()`, that takes the following parameters:\n",
"\n",
"- `filename`: The file path to the local file to write the log output to.\n",
"- `level`: Sets the level of logging that is written to the logging file.\n",
"\n",
"*Note:* You cannot use a Cloud Storage bucket as the output file."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "python_logging_file"
},
"outputs": [],
"source": [
"logging.basicConfig(filename=\"mylog.log\", level=logging.DEBUG)\n",
"\n",
"logging_examples()\n",
"\n",
"! cat mylog.log"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cloud_logging"
},
"source": [
"## Logging with Google Cloud Logging\n",
"\n",
"You can preserve and retrieve your logging output to `Google Cloud Logging` service. Commonly used features:\n",
"\n",
"- Set logging levels.\n",
"- Send log output to storage.\n",
"- Retrieve log output from storage.\n",
"\n",
"### Logging Levels in Cloud Logging\n",
"\n",
"The logging levels in order (from least to highest) are, with each level inclusive of the previous level:\n",
"\n",
"1. Informational\n",
"2. Warnings\n",
"3. Errors\n",
"4. Debugging\n",
"\n",
"By default, the logging level is set to warning level.\n",
"\n",
"### Configurable and storing log data.\n",
"\n",
"To use the `Google Cloud Logging` service, you do the following steps:\n",
"\n",
"1. Create a client to the service.\n",
"2. Obtain a handler for the service.\n",
"3. Create a logger instance and set logging level.\n",
"4. Attach logger instance to the service.\n",
"\n",
"Learn more about [Logging client libraries](https://cloud.google.com/logging/docs/reference/libraries)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cloud_logging"
},
"outputs": [],
"source": [
"import google.cloud.logging\n",
"from google.cloud.logging.handlers import CloudLoggingHandler\n",
"\n",
"# Connect to the Cloud Logging service\n",
"cl_client = google.cloud.logging.Client(project=PROJECT_ID)\n",
"handler = CloudLoggingHandler(cl_client, name=\"mylog\")\n",
"\n",
"# Create a logger instance and logging level\n",
"cloud_logger = logging.getLogger(\"cloudLogger\")\n",
"cloud_logger.setLevel(logging.INFO)\n",
"\n",
"# Attach the logger instance to the service.\n",
"cloud_logger.addHandler(handler)\n",
"\n",
"# Log something\n",
"cloud_logger.error(\"bad news\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cloud_logging_write"
},
"source": [
"### Logging output\n",
"\n",
"Logging output at specific levels is identical to Python logging with respect to method and method names. The only difference is that you use your instance of the cloud logger in place of logging."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cloud_logging_write"
},
"outputs": [],
"source": [
"cloud_logger.info(\"Model training started...\")\n",
"cloud_logger.warning(\"Using older version of package ...\")\n",
"cloud_logger.error(\"Training was terminated ...\")\n",
"cloud_logger.debug(\"Hyperparameters were ...\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cloud_logging_list"
},
"source": [
"### Get logging entries\n",
"\n",
"To get the logged output, you:\n",
"\n",
"1. Retrieve the log handle to the service.\n",
"2. Using the handle, call the method `list_entries()`.\n",
"3. Iterate through the entries."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "cloud_logging_list"
},
"outputs": [],
"source": [
"logger = cl_client.logger(\"mylog\")\n",
"\n",
"for entry in logger.list_entries():\n",
" timestamp = entry.timestamp.isoformat()\n",
" print(\"* {}: {}: {}\".format(timestamp, entry.severity, entry.payload))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "cleanup:mbsdk"
},
"source": [
"# Cleaning up\n",
"\n",
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial."
]
}
],
"metadata": {
"colab": {
"name": "get_started_with_logging.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -39,8 +39,14 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/mlops_experimentation.ipynb\">\n",
" Open in Google Cloud Notebooks\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/mlops_experimentation.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/mlops_experimentation.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
@@ -59,17 +65,6 @@
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:bq,chicago,lbn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Chicago Taxi](https://www.kaggle.com/chicago/chicago-taxi-trips-bq). The version of the dataset you will use in this tutorial is stored in a public BigQuery table. The trained model predicts whether someone would leave a tip for a taxi fare."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -154,6 +149,39 @@
" - If greater then baseline, then upload model as the new baseline and save evaluation results with the model."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dataset:bq,chicago,lbn"
},
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [Chicago Taxi](https://www.kaggle.com/chicago/chicago-taxi-trips-bq). The version of the dataset in this tutorial is stored in a public BigQuery table. The trained model predicts whether someone leaves a tip for a taxi fare."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "costs"
},
"source": [
"### Costs\n",
"\n",
"This tutorial uses billable components of Google Cloud:\n",
"\n",
"* BigQuery\n",
"* Vision API\n",
"* Vertex AI\n",
"* Cloud Storage\n",
"\n",
"Learn about [Vertex AI\n",
"pricing](https://cloud.google.com/vertex-ai/pricing), [Vision API pricing](https://cloud.google.com/vision/pricing), [BigQuery pricing](https://cloud.google.com/bigquery/pricing), [Cloud Storage\n",
"pricing](https://cloud.google.com/storage/pricing), and use the [Pricing\n",
"Calculator](https://cloud.google.com/products/calculator/)\n",
"to generate a cost estimate based on your projected usage."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -173,22 +201,35 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"# The Vertex AI Workbench Notebook product has specific requirements\n",
"IS_WORKBENCH_NOTEBOOK = os.getenv(\"DL_ANACONDA_HOME\") and not os.getenv(\"VIRTUAL_ENV\")\n",
"IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(\n",
" \"/opt/deeplearning/metadata/env_version\"\n",
")\n",
"\n",
"# Vertex AI Notebook requires dependencies to be installed with '--user'\n",
"USER_FLAG = \"\"\n",
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG\n",
" ! pip3 install --upgrade kfp $USER_FLAG\n",
" ! pip3 install --upgrade torchvision $USER_FLAG\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG"
" ! pip3 install -U tensorflow==2.5 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG -q\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG -q\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG -q\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG -q\n",
" ! pip3 install --upgrade kfp $USER_FLAG -q\n",
" ! pip3 install --upgrade torchvision $USER_FLAG -q\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG -q"
]
},
{
@@ -220,6 +261,32 @@
" app.kernel.do_shutdown(True)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "2721ef0202d9"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com). \n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -296,7 +363,9 @@
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type:\"string\"}\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
@@ -323,6 +392,75 @@
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "648aa9824ac6"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already\n",
"authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions\n",
"when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"1. In the Cloud Console, go to the [**Create service account key**\n",
" page](https://console.cloud.google.com/apis/credentials/serviceaccountkey).\n",
"\n",
"2. Click **Create service account**.\n",
"\n",
"3. In the **Service account name** field, enter a name, and\n",
" click **Create**.\n",
"\n",
"4. In the **Grant this service account access to project** section, click the **Role** drop-down list. Type \"Vertex AI\"\n",
"into the filter box, and select\n",
" **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"5. Click *Create*. A JSON file that contains your key downloads to your\n",
"local environment.\n",
"\n",
"6. Enter the path to your service account key as the\n",
"`GOOGLE_APPLICATION_CREDENTIALS` variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -436,9 +574,16 @@
" or SERVICE_ACCOUNT is None\n",
" or SERVICE_ACCOUNT == \"[your-service-account]\"\n",
"):\n",
" # Get your GCP project id from gcloud\n",
" shell_output = !gcloud auth list 2>/dev/null\n",
" SERVICE_ACCOUNT = shell_output[2].replace(\"*\", \"\").strip()\n",
" # Get your service account from gcloud\n",
" if not IS_COLAB:\n",
" shell_output = !gcloud auth list 2>/dev/null\n",
" SERVICE_ACCOUNT = shell_output[2].replace(\"*\", \"\").strip()\n",
"\n",
" if IS_COLAB:\n",
" shell_output = ! gcloud projects describe $PROJECT_ID\n",
" project_number = shell_output[-1].split(\":\")[1].strip().replace(\"'\", \"\")\n",
" SERVICE_ACCOUNT = f\"{project_number}-compute@developer.gserviceaccount.com\"\n",
"\n",
" print(\"Service Account:\", SERVICE_ACCOUNT)"
]
},
@@ -583,6 +728,8 @@
},
"outputs": [],
"source": [
"import os\n",
"\n",
"if os.getenv(\"IS_TESTING_TRAIN_GPU\"):\n",
" TRAIN_GPU, TRAIN_NGPU = (\n",
" aip.gapic.AcceleratorType.NVIDIA_TESLA_K80,\n",
@@ -1218,7 +1365,7 @@
"setup_cfg = \"[egg_info]\\n\\ntag_build =\\n\\ntag_date = 0\"\n",
"! echo \"$setup_cfg\" > custom/setup.cfg\n",
"\n",
"setup_py = \"import setuptools\\n\\nsetuptools.setup(\\n\\n install_requires=[\\n\\n 'google-cloud-aiplatform',\\n\\n 'cloudml-hypertune',\\n\\n 'tensorflow_datasets==1.3.0',\\n\\n 'tensorflow_data_validation==1.2',\\n\\n ],\\n\\n packages=setuptools.find_packages())\"\n",
"setup_py = \"import setuptools\\n\\nsetuptools.setup(\\n\\n install_requires=[\\n\\n 'google-cloud-aiplatform',\\n\\n 'cloudml-hypertune',\\n\\n 'tensorflow_datasets==1.3.0',\\n\\n 'tensorflow==2.5',\\n\\n 'tensorflow_data_validation==1.2',\\n\\n ],\\n\\n packages=setuptools.find_packages())\"\n",
"! echo \"$setup_py\" > custom/setup.py\n",
"\n",
"pkg_info = \"Metadata-Version: 1.0\\n\\nName: Chicago Taxi tabular binary classifier\\n\\nVersion: 0.0.0\\n\\nSummary: Demostration training script\\n\\nHome-page: www.google.com\\n\\nAuthor: Google\\n\\nAuthor-email: cdpe@google.com\\n\\nLicense: Public\\n\\nDescription: Demo\\n\\nPlatform: Vertex AI\"\n",
@@ -3011,9 +3158,8 @@
},
"source": [
"## Review model evaluation scores\n",
"After your model has finished training, you can review the evaluation scores for it.\n",
"\n",
"First, you need to get a reference to the new model. As with datasets, you can either use the reference to the model variable you created when you deployed the model or you can list all of the models in your project."
"After your model training has finished, you can review the evaluation scores for it using the `list_model_evaluations()` method. This method will return an iterator for each evaluation slice."
]
},
{
@@ -3024,18 +3170,10 @@
},
"outputs": [],
"source": [
"# Get model resource ID\n",
"models = aip.Model.list(filter=\"display_name=chicago_\" + TIMESTAMP)\n",
"model_evaluations = model.list_model_evaluations()\n",
"\n",
"# Get a reference to the Model Service client\n",
"client_options = {\"api_endpoint\": f\"{REGION}-aiplatform.googleapis.com\"}\n",
"model_service_client = aip.gapic.ModelServiceClient(client_options=client_options)\n",
"\n",
"model_evaluations = model_service_client.list_model_evaluations(\n",
" parent=models[0].resource_name\n",
")\n",
"model_evaluation = list(model_evaluations)[0]\n",
"print(model_evaluation)"
"for model_evaluation in model_evaluations:\n",
" print(model_evaluation.to_dict())"
]
},
{
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Some files were not shown because too many files have changed in this diff Show More