Skip to content

Commit 4755fc7

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add scheduled pipelines client create/get methods and unit tests.
PiperOrigin-RevId: 536465878
1 parent 64818bf commit 4755fc7

File tree

9 files changed

+947
-5
lines changed

9 files changed

+947
-5
lines changed

google/cloud/aiplatform/compat/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
services.model_garden_service_client = services.model_garden_service_client_v1beta1
4040
services.pipeline_service_client = services.pipeline_service_client_v1beta1
4141
services.prediction_service_client = services.prediction_service_client_v1beta1
42+
services.schedule_service_client = services.schedule_service_client_v1beta1
4243
services.specialist_pool_service_client = (
4344
services.specialist_pool_service_client_v1beta1
4445
)
@@ -114,6 +115,8 @@
114115
types.pipeline_state = types.pipeline_state_v1beta1
115116
types.prediction_service = types.prediction_service_v1beta1
116117
types.publisher_model = types.publisher_model_v1beta1
118+
types.schedule = types.schedule_v1beta1
119+
types.schedule_service = types.schedule_service_v1beta1
117120
types.specialist_pool = types.specialist_pool_v1beta1
118121
types.specialist_pool_service = types.specialist_pool_service_v1beta1
119122
types.study = types.study_v1beta1

google/cloud/aiplatform/compat/services/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
from google.cloud.aiplatform_v1beta1.services.prediction_service import (
5858
client as prediction_service_client_v1beta1,
5959
)
60+
from google.cloud.aiplatform_v1beta1.services.schedule_service import (
61+
client as schedule_service_client_v1beta1,
62+
)
6063
from google.cloud.aiplatform_v1beta1.services.specialist_pool_service import (
6164
client as specialist_pool_service_client_v1beta1,
6265
)
@@ -140,6 +143,7 @@
140143
model_service_client_v1beta1,
141144
pipeline_service_client_v1beta1,
142145
prediction_service_client_v1beta1,
146+
schedule_service_client_v1beta1,
143147
specialist_pool_service_client_v1beta1,
144148
metadata_service_client_v1beta1,
145149
tensorboard_service_client_v1beta1,

google/cloud/aiplatform/compat/types/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
pipeline_state as pipeline_state_v1beta1,
7676
prediction_service as prediction_service_v1beta1,
7777
publisher_model as publisher_model_v1beta1,
78+
schedule as schedule_v1beta1,
79+
schedule_service as schedule_service_v1beta1,
7880
specialist_pool as specialist_pool_v1beta1,
7981
specialist_pool_service as specialist_pool_service_v1beta1,
8082
study as study_v1beta1,
@@ -283,6 +285,8 @@
283285
pipeline_state_v1beta1,
284286
prediction_service_v1beta1,
285287
publisher_model_v1beta1,
288+
schedule_v1beta1,
289+
schedule_service_v1beta1,
286290
specialist_pool_v1beta1,
287291
specialist_pool_service_v1beta1,
288292
study_v1beta1,

google/cloud/aiplatform/pipeline_jobs.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import datetime
1919
import logging
20-
import time
2120
import re
2221
import tempfile
22+
import time
2323
from typing import Any, Callable, Dict, List, Optional, Union
2424

2525
from google.auth import credentials as auth_credentials
@@ -29,16 +29,16 @@
2929
from google.cloud.aiplatform import utils
3030
from google.cloud.aiplatform.constants import pipeline as pipeline_constants
3131
from google.cloud.aiplatform.metadata import artifact
32+
from google.cloud.aiplatform.metadata import constants as metadata_constants
3233
from google.cloud.aiplatform.metadata import context
3334
from google.cloud.aiplatform.metadata import execution
34-
from google.cloud.aiplatform.metadata import constants as metadata_constants
3535
from google.cloud.aiplatform.metadata import experiment_resources
3636
from google.cloud.aiplatform.metadata import utils as metadata_utils
3737
from google.cloud.aiplatform.utils import gcs_utils
38-
from google.cloud.aiplatform.utils import yaml_utils
3938
from google.cloud.aiplatform.utils import pipeline_utils
40-
from google.protobuf import json_format
39+
from google.cloud.aiplatform.utils import yaml_utils
4140
from google.protobuf import field_mask_pb2 as field_mask
41+
from google.protobuf import json_format
4242

4343
from google.cloud.aiplatform.compat.types import (
4444
pipeline_job as gca_pipeline_job,
@@ -96,7 +96,6 @@ class PipelineJob(
9696
),
9797
),
9898
):
99-
10099
client_class = utils.PipelineJobClientWithOverride
101100
_resource_noun = "pipelineJobs"
102101
_delete_method = "delete_pipeline_job"
@@ -443,6 +442,10 @@ def wait(self):
443442
def pipeline_spec(self):
444443
return self._gca_resource.pipeline_spec
445444

445+
@property
446+
def runtime_config(self) -> gca_pipeline_job.PipelineJob.RuntimeConfig:
447+
return self._gca_resource.runtime_config
448+
446449
@property
447450
def state(self) -> Optional[gca_pipeline_state.PipelineState]:
448451
"""Current pipeline state."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright 2023 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
from google.cloud.aiplatform.compat.types import (
19+
schedule_v1beta1 as gca_schedule,
20+
)
21+
from google.cloud.aiplatform.constants import pipeline as pipeline_constants
22+
23+
_SCHEDULE_COMPLETE_STATES = set(
24+
[
25+
gca_schedule.Schedule.State.PAUSED,
26+
gca_schedule.Schedule.State.COMPLETED,
27+
]
28+
)
29+
30+
_SCHEDULE_ERROR_STATES = set(
31+
[
32+
gca_schedule.Schedule.State.STATE_UNSPECIFIED,
33+
]
34+
)
35+
36+
# Pattern for valid names used as a Vertex resource name.
37+
_VALID_NAME_PATTERN = pipeline_constants._VALID_NAME_PATTERN
38+
39+
# Pattern for an Artifact Registry URL.
40+
_VALID_AR_URL = pipeline_constants._VALID_AR_URL
41+
42+
# Pattern for any JSON or YAML file over HTTPS.
43+
_VALID_HTTPS_URL = pipeline_constants._VALID_HTTPS_URL
44+
45+
# Fields to include in returned PipelineJobSchedule when enable_simple_view=True in PipelineJobSchedule.list()
46+
_PIPELINE_JOB_SCHEDULE_READ_MASK_FIELDS = [
47+
"name",
48+
"display_name",
49+
"start_time",
50+
"end_time",
51+
"max_run_count",
52+
"started_run_count",
53+
"state",
54+
"create_time",
55+
"update_time",
56+
"cron",
57+
"catch_up",
58+
]

0 commit comments

Comments
 (0)