Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mlops-139/140 pydantic docs for pipelines and jobs #43

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/tutorial/job.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ date: 2022-04-06
# WANNA Job

::: wanna.core.models.training_custom_job.BaseCustomJobModel
options:
members: false
:docstring:

## Hyper-parameter tuning

::: wanna.core.models.training_custom_job.HyperparameterTuning
:docstring:

A custom job can be simply converted to a hyper-parameter tuning job just by adding
one extra parameter called `hp_tuning`. This will start a series of jobs (instead of just one job)
Expand Down
1 change: 1 addition & 0 deletions docs/tutorial/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ You can now see that you have a self contained component and testable, ready to
## Pipeline

::: wanna.core.models.pipeline.PipelineModel
:docstring:

WANNA template creates two files that allow to put together the Kubeflow V2 pipeline that will then be deployed to GCP Vertex AI Pipelines.

Expand Down
21 changes: 21 additions & 0 deletions src/wanna/core/models/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@


class PipelineModel(BaseInstanceModel):
"""
- `name`- [str] Custom name for this instance
- `project_id' - [str] (optional) Overrides GCP Project ID from the `gcp_profile` segment
- `zone` - [str] (optional) Overrides zone from the `gcp_profile` segment
- `region` - [str] (optional) Overrides region from the `gcp_profile` segment
- `labels`- [Dict[str, str]] (optional) Custom labels to apply to this instance
- `service_account` - [str] (optional) Overrides service account from the `gcp_profile` segment
- `network` - [str] (optional) Overrides network from the `gcp_profile` segment
- `tags`- [Dict[str, str]] (optional) Tags to apply to this instance
- `metadata`- [str] (optional) Custom metadata to apply to this instance
- `pipeline_file` - [str] Path to a Kubeflow Python script
- `pipeline_function` - [str] (optional) Path to a cloud function
- `pipeline_params` - [str] (optional) Path to params.yaml file
- `docker_image_ref` - [List[str]] - List of names of docker images
- `schedule` - [str] (optional) - Scheduler using a cron syntax
- `tensorboard_ref` - [str] (optional) - Name of the Vertex AI Experiment
- `notification_channels_ref` - [List[str]] (optional) List of names of notificartins channel described
by a model: (name: str, type: Literal["email"], emails: List[EmailStr])
- `sla_hours` - [float] (optional) Time after which the running pipeline gets stopped
"""

name: str = Field(min_length=3, max_length=63, to_lower=True, regex="^[a-z][a-z0-9-]*[a-z0-9]$")
zone: str
pipeline_file: str
Expand Down
32 changes: 32 additions & 0 deletions src/wanna/core/models/training_custom_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ class DiscreteParameter(BaseModel, extra=Extra.forbid):


class HyperparameterTuning(BaseModel):
"""
- `metrics` - Dictionary of type [str, Literal["minimize", "maximize"]]
- `parameters` - List[HyperParamater] defined per var_name, type, min, max, scale
- `max_trial_count` - [int] defaults to 15
- `parallel_trial_count` - [int] defaults to 3
- `search_algorithm` - [str] (optional) Can be "grid" or "random"
- `encryption_spec` - [str] (optional) The Cloud KMS resource identifier. Has the form:
projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key
The key needs to be in the same region as where the compute resource is created
"""

metrics: Dict[str, Literal["minimize", "maximize"]]
parameters: List[HyperParamater]
max_trial_count: int = 15
Expand All @@ -95,6 +106,27 @@ class HyperparameterTuning(BaseModel):


class BaseCustomJobModel(BaseInstanceModel):
"""
- `name` - [str] Custom name for this instance
- `project_id' - [str] (optional) Overrides GCP Project ID from the `gcp_profile` segment
- `zone` - [str] (optional) Overrides zone from the `gcp_profile` segment
- `region` - [str] (optional) Overrides region from the `gcp_profile` segment
- `labels`- [Dict[str, str]] (optional) Custom labels to apply to this instance
- `service_account` - [str] (optional) Overrides service account from the `gcp_profile` segment
- `network` - [str] (optional) Overrides network from the `gcp_profile` segment
- `tags`- [Dict[str, str]] (optional) Tags to apply to this instance
- `metadata`- [str] (optional) Custom metadata to apply to this instance
- `enable_web_access` - [bool] Whether you want Vertex AI to enable interactive shell access
to training containers. Default is False
- `bucket` - [str] Overrides bucket from the `gcp_profile` segment
- `base_output_directory` - [str] (optional) Path to where outputs will be saved
- `tensorboard_ref` - [str] (optional) Name of the Vertex AI Experiment
- `timeout_seconds` - [int] Job timeout. Defaults to 60 * 60 * 24 s = 24 hours
- `encryption_spec`- [str] (optional) The Cloud KMS resource identifier. Has the form:
projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key
The key needs to be in the same region as where the compute resource is created
"""

region: str
enable_web_access: bool = False
bucket: str
Expand Down