-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
523 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from kfp.dsl import component, Artifact, Input, Output | ||
|
||
|
||
@component(base_image="python:3.10-slim-buster") | ||
def dummy_component( | ||
name: str, | ||
my_input_artifact: Input[Artifact], | ||
my_output_artifact: Output[Artifact], | ||
): | ||
"""This component is a dummy""" | ||
print(f"Hello, {name}!") | ||
|
||
my_output_artifact.metadata["name"] = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "John Doe" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import google.cloud.aiplatform as aip | ||
from aip import Artifact | ||
|
||
# You can retrieve an existing Metadata Artifact given a resource name or ID. | ||
# You can check aip documentation for more information: | ||
# https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform.Artifact | ||
artifact_name = "projects/123/locations/us-central1/metadataStores/default/artifacts/my-resource" | ||
# or | ||
artifact_name = "my-resource" | ||
|
||
my_artifact = Artifact(artifact_name=artifact_name, | ||
project="my_project", | ||
location="us-central1", | ||
) | ||
|
||
input_artifacts = {"my_input_artifact": my_artifact} | ||
parameter_values = {"name": "John Doe in python config"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
name = "John Doe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PROJECT_ID= | ||
GCP_REGION= | ||
|
||
TAG=latest | ||
|
||
# Google Artifact Registry | ||
GAR_LOCATION= # Google Artifact Registry repo location | ||
GAR_DOCKER_REPO_ID= | ||
GAR_PIPELINES_REPO_ID= | ||
GAR_VERTEX_BASE_IMAGE_NAME= | ||
|
||
# Vertex AI | ||
VERTEX_STAGING_BUCKET_NAME= # without gs:// | ||
VERTEX_SERVICE_ACCOUNT= # full service account email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM python:3.10-slim-buster | ||
|
||
ARG PROJECT_ID | ||
ARG GCP_REGION | ||
ARG GAR_LOCATION | ||
ARG GAR_PIPELINES_REPO_ID | ||
ARG VERTEX_STAGING_BUCKET_NAME | ||
ARG VERTEX_SERVICE_ACCOUNT | ||
|
||
ENV PROJECT_ID=${PROJECT_ID} | ||
ENV GCP_REGION=${GCP_REGION} | ||
ENV GAR_LOCATION=${GAR_LOCATION} | ||
ENV GAR_PIPELINES_REPO_ID=${GAR_PIPELINES_REPO_ID} | ||
ENV VERTEX_STAGING_BUCKET_NAME=${VERTEX_STAGING_BUCKET_NAME} | ||
ENV VERTEX_SERVICE_ACCOUNT=${VERTEX_SERVICE_ACCOUNT} | ||
|
||
WORKDIR /app | ||
|
||
COPY deployer-requirements.txt . | ||
RUN python3 -m pip install --upgrade pip | ||
RUN python3 -m pip install -r deployer-requirements.txt | ||
|
||
ENV PYTHONPATH "${PYTHONPATH}:." | ||
|
||
COPY ./vertex /app/vertex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
ENV_FILENAME=deployer.env | ||
source $ENV_FILENAME | ||
echo "Using '$ENV_FILENAME' env variables..." | ||
|
||
SUBSTITUTIONS="\ | ||
_GAR_LOCATION=${GAR_LOCATION},\ | ||
_GAR_DOCKER_REPO_ID=${GAR_DOCKER_REPO_ID},\ | ||
_GAR_VERTEX_BASE_IMAGE_NAME=${GAR_VERTEX_BASE_IMAGE_NAME},\ | ||
_TAG=${TAG} | ||
" | ||
|
||
gcloud builds submit \ | ||
--config {{ cloud_build_path }} \ | ||
--project=$PROJECT_ID \ | ||
--region $GCP_REGION \ | ||
--substitutions $SUBSTITUTIONS |
36 changes: 36 additions & 0 deletions
36
deployer/_templates/deployment/cloudbuild_local.yaml.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This config file is meant to be used from a local dev machine to submit a vertex base image build to Cloud Build. | ||
# This generic image will then be used in all the Vertex components of your pipeline. | ||
|
||
steps: | ||
# Build base image | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: [ | ||
'build', | ||
'-t', '${_GAR_IMAGE_PATH}', | ||
'-f', '{{ dockerfile_path }}', | ||
'--build-arg', 'PROJECT_ID=${PROJECT_ID}', | ||
'--build-arg', 'GCP_REGION=${_GCP_REGION}', | ||
'--build-arg', 'GAR_LOCATION=${_GAR_LOCATION}', | ||
'--build-arg', 'GAR_PIPELINES_REPO_ID=${_GAR_PIPELINES_REPO_ID}', | ||
'--build-arg', 'VERTEX_STAGING_BUCKET_NAME=${_VERTEX_STAGING_BUCKET_NAME}', | ||
'--build-arg', 'VERTEX_SERVICE_ACCOUNT=${_VERTEX_SERVICE_ACCOUNT}', | ||
'.', | ||
] | ||
id: build-base-image | ||
|
||
substitutions: | ||
_GAR_IMAGE_PATH: '${_GAR_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${_GAR_DOCKER_REPO_ID}/${_GAR_VERTEX_BASE_IMAGE_NAME}:${_TAG}' | ||
_GCP_REGION: '${GCP_REGION}' | ||
_GAR_PIPELINES_REPO_ID: '${GAR_PIPELINES_REPO_ID}' | ||
_VERTEX_STAGING_BUCKET_NAME: '${VERTEX_STAGING_BUCKET_NAME}' | ||
_VERTEX_SERVICE_ACCOUNT: '${VERTEX_SERVICE_ACCOUNT}' | ||
|
||
options: | ||
logging: CLOUD_LOGGING_ONLY | ||
dynamic_substitutions: true | ||
|
||
images: | ||
- '${_GAR_IMAGE_PATH}' | ||
|
||
tags: | ||
- vertex-${_GAR_DOCKER_REPO_ID}-base-image-local-${_TAG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import kfp.dsl | ||
|
||
from {{ component_module }} import dummy_component | ||
|
||
|
||
@kfp.dsl.pipeline(name="{{ pipeline_name }}") | ||
def {{ pipeline_name }}(name: str): | ||
"""This pipeline prints hello {name}""" | ||
dummy_component(name=name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# base | ||
# We consider that your initial requirements are defined in a requirements.txt file | ||
-r requirements.txt | ||
|
||
# deploy | ||
kfp | ||
google-cloud-aiplatform | ||
vertex-deployer={{ deployer_version }} |
Oops, something went wrong.