mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Upload pipeline job example (#3719)
* Upload pipeline example which can combine other pipeline examples.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
from kfp.v2 import dsl
|
||||
|
||||
@dsl.component(base_image='python:3.8',packages_to_install=['google-cloud-aiplatform==1.36.0'])
|
||||
def pipelineJob(
|
||||
project_id: str,
|
||||
location: str,
|
||||
display_name: str,
|
||||
json_file: str,
|
||||
pipeline_root: str,
|
||||
):
|
||||
import os
|
||||
from google.cloud import aiplatform
|
||||
|
||||
aiplatform.init(
|
||||
project=project_id,
|
||||
location=location,
|
||||
)
|
||||
|
||||
job = aiplatform.PipelineJob(
|
||||
display_name=display_name,
|
||||
template_path=json_file,
|
||||
pipeline_root=pipeline_root,
|
||||
enable_caching=False,
|
||||
).run()
|
||||
|
||||
job.delete()
|
||||
|
||||
|
||||
@dsl.pipeline(name='pipelineJobs')
|
||||
def pipeline_run_jobs():
|
||||
# 1. create endpoint
|
||||
pipelineJob("990000000009", "us-west1", "Pipeline-create endpoint",
|
||||
"create_endpoint.json", "gs://pipeline-root-bucket/pipelines")
|
||||
|
||||
# 2. deploy model to endpoint
|
||||
pipelineJob("990000000009", "us-west1", "Pipeline-deploy model",
|
||||
"deploy_model.json", "gs://pipeline-root-bucket/pipelines")
|
||||
|
||||
if __name__ == "__main__":
|
||||
from kfp.v2 import compiler
|
||||
compiler.Compiler().compile(
|
||||
pipeline_func=pipeline_run_jobs,
|
||||
package_path='pipelineJobs.json')
|
||||
Reference in New Issue
Block a user