Skip to content

Commit

Permalink
chore(release): 0.5.0 (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
julesbertrand authored Apr 16, 2024
2 parents cf3f48f + 8e1faf8 commit 73589ad
Show file tree
Hide file tree
Showing 27 changed files with 523 additions and 163 deletions.
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
<!-- PROJECT SHIELDS -->
<div align="center">

[![Python Version](https://img.shields.io/badge/Python-3.8_3.9_3.10-blue?logo=python)](#supported-python-versions)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Linting: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-informational?logo=pre-commit&logoColor=white)](https://github.com/ornikar/vertex-eduscore/blob/develop/.pre-commit-config.yaml)
[![License](https://img.shields.io/github/license/artefactory/vertex-pipelines-deployer)](https://github.com/artefactory/vertex-pipelines-deployer/blob/main/LICENSE)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/vertex-deployer?logo=python)
![PyPI - Status](https://img.shields.io/pypi/v/vertex-deployer)
![PyPI - Downloads](https://img.shields.io/pypi/dm/vertex-deployer?color=blue)
![PyPI - License](https://img.shields.io/pypi/l/vertex-deployer)

[![CI](https://github.com/artefactory/vertex-pipelines-deployer/actions/workflows/ci.yaml/badge.svg?branch=main&event=push)](https://github.com/artefactory/vertex-pipelines-deployer/actions/workflows/ci.yaml)
[![Release](https://github.com/artefactory/vertex-pipelines-deployer/actions/workflows/release.yaml/badge.svg?branch=main&event=push)](https://github.com/artefactory/vertex-pipelines-deployer/actions/workflows/release.yaml)

[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-informational?logo=pre-commit&logoColor=white)](https://github.com/ornikar/vertex-eduscore/blob/develop/.pre-commit-config.yaml)
[![Linting: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat)](https://pycqa.github.io/isort/)

</div>


Expand Down Expand Up @@ -320,7 +322,6 @@ vertex-deployer deploy dummy_pipeline \
--upload \
--run \
--env-file example.env \
--local-package-path . \
--tags my-tag \
--config-filepath vertex/configs/dummy_pipeline/config_test.json \
--experiment-name my-experiment \
Expand Down Expand Up @@ -414,8 +415,7 @@ This will overwrite default values. It can be useful if you always use the same

```toml
[tool.vertex-deployer]
pipelines_root_path = "my/path/to/vertex/pipelines"
configs_root_path = "my/path/to/vertex/configs"
vertex_folder_path = "my/path/to/vertex"
log_level = "INFO"

[tool.vertex-deployer.deploy]
Expand All @@ -427,8 +427,7 @@ You can display all the configurable parameterss with default values by running:
$ vertex-deployer config --all
'*' means the value was set in config file

* pipelines_root_path=my/path/to/vertex/pipelines
* config_root_path=my/path/to/vertex/configs
* vertex_folder_path=my/path/to/vertex
* log_level=INFO
deploy
env_file=None
Expand All @@ -444,7 +443,6 @@ deploy
config_name=None
enable_caching=False
experiment_name=None
local_package_path=vertex/pipelines/compiled_pipelines
check
all=False
config_filepath=None
Expand Down
13 changes: 13 additions & 0 deletions deployer/_templates/components/dummy_component.py.jinja
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
3 changes: 3 additions & 0 deletions deployer/_templates/configs/json_config.json.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "John Doe"
}
17 changes: 17 additions & 0 deletions deployer/_templates/configs/python_config.py.jinja
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"}
1 change: 1 addition & 0 deletions deployer/_templates/configs/toml_config.toml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name = "John Doe"
14 changes: 14 additions & 0 deletions deployer/_templates/deployer.env.jinja
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
25 changes: 25 additions & 0 deletions deployer/_templates/deployment/Dockerfile.jinja
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
17 changes: 17 additions & 0 deletions deployer/_templates/deployment/build_base_image.sh.jinja
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 deployer/_templates/deployment/cloudbuild_local.yaml.jinja
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}
9 changes: 9 additions & 0 deletions deployer/_templates/pipelines/pipeline_minimal.py.jinja
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)
8 changes: 8 additions & 0 deletions deployer/_templates/requirements-vertex.txt.jinja
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 }}
Loading

0 comments on commit 73589ad

Please sign in to comment.