Skip to content

Commit

Permalink
chore(release): 01.1 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
julesbertrand authored Oct 5, 2023
2 parents 0be9f10 + 9c973f0 commit 2497456
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ run-tests:
@poetry run pytest tests --cov=deployer --cov-report=term-missing -s -vv -W ignore:::pkg_resources


.PHONY: profile-cli
## Profile CLI using pyinstrument (https://pyinstrument.readthedocs.io/en/latest/index.html)
profile-cli:
@echo "Check that you have pyinstrument installed: poetry install -E profiling"
@poetry run pyinstrument -r html -o pyinstrument.html --from-path vertex-deployer --version
@open pyinstrument.html


#################################################################################
# Self Documenting Commands #
#################################################################################
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ cd example

Install a specific version:
```bash
export VERSION=0.0.1
wget https://storage.cloud.google.com/vertex-pipelines-deployer/vertex_deployer-$VERSION.tar.gz
export VERSION=0.1.0
gsutil -m cp gs://vertex-pipelines-deployer/vertex_deployer-$VERSION.tar.gz .
pip install ./vertex_deployer-$VERSION.tar.gz
```

Expand Down
7 changes: 5 additions & 2 deletions deployer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
PIPELINE_ROOT_PATH,
PYTHON_CONFIG_TEMPLATE,
)
from deployer.pipeline_checks import Pipelines
from deployer.pipeline_deployer import VertexPipelineDeployer
from deployer.utils.config import (
ConfigType,
list_config_filepaths,
Expand Down Expand Up @@ -190,6 +188,8 @@ def deploy( # noqa: C901

pipeline_func = import_pipeline_from_dir(PIPELINE_ROOT_PATH, pipeline_name.value)

from deployer.pipeline_deployer import VertexPipelineDeployer

deployer = VertexPipelineDeployer(
project_id=vertex_settings.PROJECT_ID,
region=vertex_settings.GCP_REGION,
Expand Down Expand Up @@ -283,6 +283,8 @@ def check(
**This command can be used to check pipelines in a Continuous Integration workflow.**
"""
from deployer.pipeline_checks import Pipelines

if len(PipelineName.__members__) == 0:
raise ValueError(
"No pipeline found. Please check that the pipeline root path is correct"
Expand Down Expand Up @@ -339,6 +341,7 @@ def list(
"No pipeline found. Please check that the pipeline root path is"
f" correct (current: '{PIPELINE_ROOT_PATH}')"
)
raise typer.Exit()

if with_configs:
pipelines_dict = {
Expand Down
24 changes: 13 additions & 11 deletions deployer/pipeline_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from typing import Any, Dict, Generic, List, TypeVar

from loguru import logger
from pydantic import Field, computed_field, model_validator
from pydantic import Field, ValidationError, computed_field, model_validator
from pydantic.functional_validators import ModelWrapValidatorHandler
from typing_extensions import Annotated

from deployer.constants import (
Expand Down Expand Up @@ -100,15 +101,16 @@ class Pipelines(CustomBaseModel):

pipelines: Dict[str, Pipeline]

@model_validator(mode="before")
@classmethod
def _init_temp_directory(cls, data: Any) -> Any:
"""Create temporary directory"""
@model_validator(mode="wrap")
def _init_remove_temp_directory(self, handler: ModelWrapValidatorHandler) -> Any:
"""Create and remove temporary directory"""
Path(TEMP_LOCAL_PACKAGE_PATH).mkdir(exist_ok=True)
return data

@model_validator(mode="after")
def _remove_temp_directory(self) -> None:
"""Remove temporary directory"""
shutil.rmtree(TEMP_LOCAL_PACKAGE_PATH)
return self
try:
validated_self = handler(self)
except ValidationError as e:
raise e
finally:
shutil.rmtree(TEMP_LOCAL_PACKAGE_PATH)

return validated_self
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rich = "^13.5.3"
loguru = "^0.7.2"
pydantic-settings = "^2.0.3"
pydantic = "^2.3.0"
pyinstrument = { version = "^4.5.3", optional = true }

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
Expand All @@ -30,6 +31,9 @@ nbstripout = "^0.6.1"
ruff = "^0.0.289"
pytest-cov = "^4.1.0"

[tool.poetry.extras]
profiling = ["pyinstrument"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Expand Down

0 comments on commit 2497456

Please sign in to comment.