Skip to content

Commit 4eb0c53

Browse files
chore(release): 0.3.2 (#96)
2 parents aee31e2 + 42ccfc9 commit 4eb0c53

29 files changed

+929
-167
lines changed

.github/dependabot.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Configuration: https://dependabot.com/docs/config-file/
2+
# Docs: https://docs.github.com/en/github/administering-a-repository/keeping-your-dependencies-updated-automatically
3+
4+
version: 2
5+
6+
updates:
7+
- package-ecosystem: "pip"
8+
target-branch: "develop"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
day: "monday"
13+
time: "09:00"
14+
allow:
15+
- dependency-type: "all"
16+
labels:
17+
- draft
18+
- dependencies
19+
- python
20+
- package-ecosystem: "github-actions"
21+
target-branch: "develop"
22+
directory: "/"
23+
schedule:
24+
interval: "weekly"
25+
day: "monday"
26+
time: "09:00"
27+
allow:
28+
- dependency-type: "all"
29+
labels:
30+
- draft
31+
- dependencies
32+
- github_actions

.github/workflows/ci.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
python-version: ['3.8', '3.9', '3.10']
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222
- name: Set up Python ${{ matrix.python-version }}
2323
uses: actions/setup-python@v4
2424
with:
@@ -28,7 +28,7 @@ jobs:
2828
run: make download-poetry
2929

3030
- name: Set up pip cache
31-
uses: actions/cache@v3.2.4
31+
uses: actions/cache@v3.3.2
3232
with:
3333
path: ~/.cache/pypoetry/virtualenvs
3434
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
@@ -57,17 +57,17 @@ jobs:
5757
python-version: ['3.8', '3.9', '3.10']
5858

5959
steps:
60-
- uses: actions/checkout@v2
60+
- uses: actions/checkout@v4
6161
- name: Set up Python ${{ matrix.python-version }}
62-
uses: actions/setup-python@v2
62+
uses: actions/setup-python@v4
6363
with:
6464
python-version: ${{ matrix.python-version }}
6565

6666
- name: Install poetry
6767
run: make download-poetry
6868

6969
- name: Set up pip cache
70-
uses: actions/cache@v3.2.4
70+
uses: actions/cache@v3.3.2
7171
with:
7272
path: ~/.cache/pypoetry/virtualenvs
7373
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
@@ -85,31 +85,31 @@ jobs:
8585
- name: Test root command
8686
run: |
8787
cd example
88-
poetry run vertex-deployer --version
88+
poetry run -C .. vertex-deployer --version
8989
9090
- name: Test config command
9191
run: |
9292
cd example
93-
poetry run vertex-deployer config --all
93+
poetry run -C .. vertex-deployer config --all
9494
9595
- name: Test list command
9696
run: |
9797
cd example
98-
poetry run vertex-deployer list --with-configs
98+
poetry run -C .. vertex-deployer list --with-configs
9999
100100
- name: Test check command
101101
run: |
102102
cd example
103-
poetry run vertex-deployer check --all
103+
poetry run -C .. vertex-deployer check --all
104104
105105
- name: Test deploy command
106106
# Cannot check more than compile action here, need GCP environment for upload, run, schedule
107107
run: |
108108
cd example
109-
poetry run vertex-deployer -log DEBUG deploy dummy_pipeline --compile --env-file example.env
109+
poetry run -C .. vertex-deployer -log DEBUG deploy dummy_pipeline --compile --env-file example.env
110110
111111
- name: Test create command
112112
run: |
113113
cd example
114-
poetry run vertex-deployer create test_pipeline --config-type py
114+
poetry run -C .. vertex-deployer create test_pipeline --config-type py
115115
[ -e example/vertex/pipelines/test_pipeline.py ] && echo 1 || echo 0

.github/workflows/deploy_docs.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Deploy MkDocs to GitHub Pages
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
python-version: "3.10"
9+
10+
jobs:
11+
Deploy-docs:
12+
name: Deploy docs
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python ${{ env.python-version }}
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: ${{ env.python-version }}
21+
22+
- name: Install poetry
23+
run: make download-poetry
24+
25+
- name: Set up pip cache
26+
uses: actions/[email protected]
27+
with:
28+
path: ~/.cache/pypoetry/virtualenvs
29+
key: venv-${{ env.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
30+
31+
- name: Set Poetry Path
32+
run: |
33+
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
34+
35+
36+
- name: Install requirements
37+
run: |
38+
poetry run pip install --upgrade pip
39+
poetry install --only docs
40+
41+
- name: Deploying MkDocs documentation
42+
run: |
43+
poetry run mkdocs build
44+
poetry run mkdocs gh-deploy --force

.github/workflows/release.yaml

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
contents: write
3232

3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535
with:
3636
fetch-depth: 0
3737

@@ -56,42 +56,3 @@ jobs:
5656
--repository-url https://europe-west1-python.pkg.dev/vertex-deployer-sandbox-3a8a/vertex-deployer \
5757
--verbose \
5858
dist/*
59-
60-
Deploy-docs:
61-
name: Deploy docs
62-
runs-on: ubuntu-latest
63-
concurrency: Deploy-docs
64-
needs: Release
65-
env:
66-
python-version: "3.10"
67-
steps:
68-
- uses: actions/checkout@v3
69-
70-
- name: Set up Python ${{ env.python-version }}
71-
uses: actions/setup-python@v4
72-
with:
73-
python-version: ${{ env.python-version }}
74-
75-
- name: Install poetry
76-
run: make download-poetry
77-
78-
- name: Set up pip cache
79-
uses: actions/[email protected]
80-
with:
81-
path: ~/.cache/pypoetry/virtualenvs
82-
key: venv-${{ env.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
83-
84-
- name: Set Poetry Path
85-
run: |
86-
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
87-
88-
89-
- name: Install requirements
90-
run: |
91-
poetry run pip install --upgrade pip
92-
poetry install --only docs
93-
94-
- name: Deploying MkDocs documentation
95-
run: |
96-
poetry run mkdocs build
97-
poetry run mkdocs gh-deploy --force

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,30 @@ poetry install
9494
cd example
9595
```
9696

97-
### From GCS (not available in PyPI yet)
97+
### From Artifact Registry (not available in PyPI yet)
9898

99-
Install a specific version:
99+
The package is available on a public Google Artifact Registry repo. You need to specify a
100+
[pip extra index url](https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-extra-index-url) to install it.
101+
102+
Install latest version:
100103
```bash
101-
export VERSION=0.1.0
102-
gsutil -m cp gs://vertex-pipelines-deployer/vertex_deployer-$VERSION.tar.gz .
103-
pip install ./vertex_deployer-$VERSION.tar.gz
104+
pip install --extra-index-url https://europe-west1-python.pkg.dev/vertex-deployer-sandbox-3a8a/vertex-deployer/simple vertex-deployer
104105
```
105106

106107
List available versions:
107108
```bash
108-
gsutil ls gs://vertex-pipelines-deployer
109+
pip index versions --extra-index-url https://europe-west1-python.pkg.dev/vertex-deployer-sandbox-3a8a/vertex-deployer/simple vertex-deployer
109110
```
110111

111112
### Add to requirements
112113

113114
It's better to get the .tar.gz archive from gcs, and version it.
114115

115-
Then add the following line to your `requirements.in` file:
116+
Then add the following lines to your `requirements.in` file:
116117
```bash
117-
file:my/path/to/vertex_deployer-$VERSION.tar.gz
118+
--extra-index-url https://europe-west1-python.pkg.dev/vertex-deployer-sandbox-3a8a/vertex-deployer/simple
119+
120+
vertex-deployer==0.3.1
118121
```
119122
<!-- --8<-- [end:installation] -->
120123

deployer/pipeline_checks.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
from pathlib import Path
33
from typing import Any, Dict, Generic, List, TypeVar
44

5+
import kfp.dsl
56
from loguru import logger
67
from pydantic import Field, ValidationError, computed_field, model_validator
78
from pydantic.functional_validators import ModelWrapValidatorHandler
89
from pydantic_core import PydanticCustomError
9-
from typing_extensions import Annotated
10+
from typing_extensions import Annotated, _AnnotatedAlias
11+
12+
try:
13+
from kfp.dsl import graph_component # since 2.1
14+
except ImportError:
15+
from kfp.components import graph_component # until 2.0.1
1016

1117
from deployer.constants import TEMP_LOCAL_PACKAGE_PATH
1218
from deployer.pipeline_deployer import VertexPipelineDeployer
1319
from deployer.utils.config import list_config_filepaths, load_config
1420
from deployer.utils.exceptions import BadConfigError
1521
from deployer.utils.logging import disable_logger
16-
from deployer.utils.models import CustomBaseModel, create_model_from_pipeline
22+
from deployer.utils.models import CustomBaseModel, create_model_from_func
1723
from deployer.utils.utils import import_pipeline_from_dir
1824

1925
PipelineConfigT = TypeVar("PipelineConfigT")
@@ -63,7 +69,7 @@ def populate_config_names(cls, data: Any) -> Any:
6369
return data
6470

6571
@computed_field
66-
def pipeline(self) -> Any:
72+
def pipeline(self) -> graph_component.GraphComponent:
6773
"""Import pipeline"""
6874
if getattr(self, "_pipeline", None) is None:
6975
with disable_logger("deployer.utils.utils"):
@@ -101,7 +107,9 @@ def compile_pipeline(self):
101107
def validate_configs(self):
102108
"""Validate configs against pipeline parameters definition"""
103109
logger.debug(f"Validating configs for pipeline {self.pipeline_name}")
104-
PipelineDynamicModel = create_model_from_pipeline(self.pipeline)
110+
PipelineDynamicModel = create_model_from_func(
111+
self.pipeline.pipeline_func, type_converter=_convert_artifact_type_to_str
112+
)
105113
ConfigsModel = ConfigsDynamicModel[PipelineDynamicModel]
106114
ConfigsModel.model_validate(
107115
{"configs": {x.name: {"config_path": x} for x in self.config_paths}}
@@ -127,3 +135,16 @@ def _init_remove_temp_directory(self, handler: ModelWrapValidatorHandler) -> Any
127135
shutil.rmtree(TEMP_LOCAL_PACKAGE_PATH)
128136

129137
return validated_self
138+
139+
140+
def _convert_artifact_type_to_str(annotation: type) -> type:
141+
"""Convert a kfp.dsl.Artifact type to a string.
142+
143+
This is mandatory for type checking, as kfp.dsl.Artifact types should be passed as strings
144+
to VertexAI. See https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform.PipelineJob
145+
for details.
146+
""" # noqa: E501
147+
if isinstance(annotation, _AnnotatedAlias):
148+
if issubclass(annotation.__origin__, kfp.dsl.Artifact):
149+
return str
150+
return annotation

deployer/pipeline_deployer.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,22 @@ def run(
187187
input_artifacts=input_artifacts,
188188
)
189189

190-
job.submit(
191-
experiment=experiment_name,
192-
service_account=self.service_account,
193-
)
190+
try:
191+
job.submit(
192+
experiment=experiment_name,
193+
service_account=self.service_account,
194+
)
195+
except RuntimeError as e: # HACK: This is a temporary fix
196+
if "could not be associated with Experiment" in str(e):
197+
logger.warning(
198+
f"Encountered an error while linking your job {job.job_id}"
199+
f" with experiment {experiment_name}."
200+
" This is likely due to a bug in the AI Platform Pipelines client."
201+
" You job should be running anyway. Try to link it manually."
202+
)
203+
else:
204+
raise e
205+
194206
return self
195207

196208
def compile_upload_run(

0 commit comments

Comments
 (0)