Skip to content

Commit f16906d

Browse files
authored
Create operators for VertexAI Pipeline Job (#34915)
1 parent 86e27c7 commit f16906d

File tree

11 files changed

+1526
-56
lines changed

11 files changed

+1526
-56
lines changed

airflow/providers/google/cloud/hooks/vertex_ai/custom_job.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""This module contains a Google Cloud Vertex AI hook."""
1919
from __future__ import annotations
2020

21+
import warnings
2122
from typing import TYPE_CHECKING, Sequence
2223

2324
from google.api_core.client_options import ClientOptions
@@ -31,7 +32,7 @@
3132
)
3233
from google.cloud.aiplatform_v1 import JobServiceClient, PipelineServiceClient
3334

34-
from airflow.exceptions import AirflowException
35+
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
3536
from airflow.providers.google.common.consts import CLIENT_INFO
3637
from airflow.providers.google.common.hooks.base_google import GoogleBaseHook
3738

@@ -378,13 +379,19 @@ def cancel_pipeline_job(
378379
[google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to ``Code.CANCELLED``, and
379380
[PipelineJob.state][google.cloud.aiplatform.v1.PipelineJob.state] is set to ``CANCELLED``.
380381
382+
This method is deprecated, please use `PipelineJobHook.cancel_pipeline_job` method.
383+
381384
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
382385
:param region: Required. The ID of the Google Cloud region that the service belongs to.
383386
:param pipeline_job: The name of the PipelineJob to cancel.
384387
:param retry: Designation of what errors, if any, should be retried.
385388
:param timeout: The timeout for this request.
386389
:param metadata: Strings which should be sent along with the request as metadata.
387390
"""
391+
warnings.warn(
392+
"This method is deprecated, please use `PipelineJobHook.cancel_pipeline_job` method.",
393+
AirflowProviderDeprecationWarning,
394+
)
388395
client = self.get_pipeline_service_client(region)
389396
name = client.pipeline_job_path(project_id, region, pipeline_job)
390397

@@ -493,6 +500,8 @@ def create_pipeline_job(
493500
"""
494501
Creates a PipelineJob. A PipelineJob will run immediately when created.
495502
503+
This method is deprecated, please use `PipelineJobHook.create_pipeline_job` method.
504+
496505
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
497506
:param region: Required. The ID of the Google Cloud region that the service belongs to.
498507
:param pipeline_job: Required. The PipelineJob to create.
@@ -504,6 +513,10 @@ def create_pipeline_job(
504513
:param timeout: The timeout for this request.
505514
:param metadata: Strings which should be sent along with the request as metadata.
506515
"""
516+
warnings.warn(
517+
"This method is deprecated, please use `PipelineJobHook.create_pipeline_job` method.",
518+
AirflowProviderDeprecationWarning,
519+
)
507520
client = self.get_pipeline_service_client(region)
508521
parent = client.common_location_path(project_id, region)
509522

@@ -1752,13 +1765,19 @@ def delete_pipeline_job(
17521765
"""
17531766
Deletes a PipelineJob.
17541767
1768+
This method is deprecated, please use `PipelineJobHook.delete_pipeline_job` method.
1769+
17551770
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
17561771
:param region: Required. The ID of the Google Cloud region that the service belongs to.
17571772
:param pipeline_job: Required. The name of the PipelineJob resource to be deleted.
17581773
:param retry: Designation of what errors, if any, should be retried.
17591774
:param timeout: The timeout for this request.
17601775
:param metadata: Strings which should be sent along with the request as metadata.
17611776
"""
1777+
warnings.warn(
1778+
"This method is deprecated, please use `PipelineJobHook.delete_pipeline_job` method.",
1779+
AirflowProviderDeprecationWarning,
1780+
)
17621781
client = self.get_pipeline_service_client(region)
17631782
name = client.pipeline_job_path(project_id, region, pipeline_job)
17641783

@@ -1851,13 +1870,19 @@ def get_pipeline_job(
18511870
"""
18521871
Gets a PipelineJob.
18531872
1873+
This method is deprecated, please use `PipelineJobHook.get_pipeline_job` method.
1874+
18541875
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
18551876
:param region: Required. The ID of the Google Cloud region that the service belongs to.
18561877
:param pipeline_job: Required. The name of the PipelineJob resource.
18571878
:param retry: Designation of what errors, if any, should be retried.
18581879
:param timeout: The timeout for this request.
18591880
:param metadata: Strings which should be sent along with the request as metadata.
18601881
"""
1882+
warnings.warn(
1883+
"This method is deprecated, please use `PipelineJobHook.get_pipeline_job` method.",
1884+
AirflowProviderDeprecationWarning,
1885+
)
18611886
client = self.get_pipeline_service_client(region)
18621887
name = client.pipeline_job_path(project_id, region, pipeline_job)
18631888

@@ -1953,6 +1978,8 @@ def list_pipeline_jobs(
19531978
"""
19541979
Lists PipelineJobs in a Location.
19551980
1981+
This method is deprecated, please use `PipelineJobHook.list_pipeline_jobs` method.
1982+
19561983
:param project_id: Required. The ID of the Google Cloud project that the service belongs to.
19571984
:param region: Required. The ID of the Google Cloud region that the service belongs to.
19581985
:param filter: Optional. Lists the PipelineJobs that match the filter expression. The
@@ -2008,6 +2035,10 @@ def list_pipeline_jobs(
20082035
:param timeout: The timeout for this request.
20092036
:param metadata: Strings which should be sent along with the request as metadata.
20102037
"""
2038+
warnings.warn(
2039+
"This method is deprecated, please use `PipelineJobHook.list_pipeline_jobs` method.",
2040+
AirflowProviderDeprecationWarning,
2041+
)
20112042
client = self.get_pipeline_service_client(region)
20122043
parent = client.common_location_path(project_id, region)
20132044

0 commit comments

Comments
 (0)