Skip to content

Commit

Permalink
Deprecate AutoMLTablesListTableSpecsOperator and AutoMLTablesListColu…
Browse files Browse the repository at this point in the history
…mnSpecsOperator
  • Loading branch information
e-galan committed May 23, 2024
1 parent 3b1ecbc commit e8fe9df
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 248 deletions.
62 changes: 33 additions & 29 deletions airflow/providers/google/cloud/operators/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from functools import cached_property
from typing import TYPE_CHECKING, Sequence, Tuple

from deprecated import deprecated
from google.api_core.gapic_v1.method import DEFAULT, _MethodDefault
from google.cloud.automl_v1beta1 import (
BatchPredictResult,
Expand All @@ -35,7 +34,7 @@
TableSpec,
)

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.providers.google.cloud.hooks.automl import CloudAutoMLHook
from airflow.providers.google.cloud.hooks.vertex_ai.prediction_service import PredictionServiceHook
from airflow.providers.google.cloud.links.translate import (
Expand Down Expand Up @@ -685,6 +684,13 @@ class AutoMLTablesListColumnSpecsOperator(GoogleCloudBaseOperator):
"""
Lists column specs in a table.
Class AutoMLTablesListColumnSpecsOperator has been deprecated and is no longer available.
AutoML platform does not support tabular datasets after its integration with Cloud
Translation and Vertex AI.
Please refer to https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and
"https://cloud.google.com/translate/docs/advanced/automl-upgrade for more info about
available alternatives.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:AutoMLTablesListColumnSpecsOperator`
Expand Down Expand Up @@ -759,6 +765,14 @@ def __init__(
self.retry = retry
self.gcp_conn_id = gcp_conn_id
self.impersonation_chain = impersonation_chain
raise AirflowException(
"Class AutoMLTablesListColumnSpecsOperator has been deprecated and is no longer available. "
"AutoML platform does not support tabular datasets after its integration with Cloud "
"Translation and Vertex AI."
"Please refer to https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
"https://cloud.google.com/translate/docs/advanced/automl-upgrade for more info about "
"available alternatives."
)

def execute(self, context: Context):
hook = CloudAutoMLHook(
Expand Down Expand Up @@ -791,14 +805,6 @@ def execute(self, context: Context):
return result


@deprecated(
reason=(
"Class `AutoMLTablesUpdateDatasetOperator` has been deprecated and no longer available. "
"Please use `UpdateDatasetOperator` instead"
),
category=AirflowProviderDeprecationWarning,
action="error",
)
class AutoMLTablesUpdateDatasetOperator(GoogleCloudBaseOperator):
"""
Updates a dataset.
Expand Down Expand Up @@ -864,6 +870,7 @@ def __init__(
self.retry = retry
self.gcp_conn_id = gcp_conn_id
self.impersonation_chain = impersonation_chain
_raise_exception_for_deprecated_operator(self.__class__.__name__, "UpdateDatasetOperator")

def execute(self, context: Context):
hook = CloudAutoMLHook(
Expand Down Expand Up @@ -1074,14 +1081,6 @@ def execute(self, context: Context):
self.log.info("Deletion is completed")


@deprecated(
reason=(
"Class `AutoMLDeployModelOperator` has been deprecated and no longer available. Please use "
"`DeployModelOperator` instead"
),
category=AirflowProviderDeprecationWarning,
action="error",
)
class AutoMLDeployModelOperator(GoogleCloudBaseOperator):
"""
Deploys a model; if a model is already deployed, deploying it with the same parameters has no effect.
Expand Down Expand Up @@ -1156,24 +1155,14 @@ def __init__(
self.retry = retry
self.gcp_conn_id = gcp_conn_id
self.impersonation_chain = impersonation_chain
_raise_exception_for_deprecated_operator(self.__class__.__name__, "DeployModelOperator")

def execute(self, context: Context):
hook = CloudAutoMLHook(
gcp_conn_id=self.gcp_conn_id,
impersonation_chain=self.impersonation_chain,
)
model = hook.get_model(
model_id=self.model_id,
location=self.location,
project_id=self.project_id,
retry=self.retry,
timeout=self.timeout,
metadata=self.metadata,
)
if not hasattr(model, "translation_model_metadata"):
_raise_exception_for_deprecated_operator(self.__class__.__name__, "DeployModelOperator")
self.log.info("Deploying model_id %s", self.model_id)

operation = hook.deploy_model(
model_id=self.model_id,
location=self.location,
Expand All @@ -1191,6 +1180,13 @@ class AutoMLTablesListTableSpecsOperator(GoogleCloudBaseOperator):
"""
Lists table specs in a dataset.
Class AutoMLTablesListTableSpecsOperator has been deprecated and is no longer available.
AutoML platform does not support tabular datasets after its integration with Cloud
Translation and Vertex AI.
Please refer to https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and
"https://cloud.google.com/translate/docs/advanced/automl-upgrade for more info about
available alternatives.
.. seealso::
For more information on how to use this operator, take a look at the guide:
:ref:`howto/operator:AutoMLTablesListTableSpecsOperator`
Expand Down Expand Up @@ -1256,6 +1252,14 @@ def __init__(
self.retry = retry
self.gcp_conn_id = gcp_conn_id
self.impersonation_chain = impersonation_chain
raise AirflowException(
"Class AutoMLTablesListTableSpecsOperator has been deprecated and is no longer available. "
"AutoML platform does not support tabular datasets after its integration with Cloud "
"Translation and Vertex AI."
"Please refer to https://cloud.google.com/vertex-ai/docs/start/migrating-to-vertex-ai and "
"https://cloud.google.com/translate/docs/advanced/automl-upgrade for more info about "
"available alternatives."
)

def execute(self, context: Context):
hook = CloudAutoMLHook(
Expand Down
2 changes: 2 additions & 0 deletions scripts/in_container/run_provider_yaml_files_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@

KNOWN_DEPRECATED_CLASSES = [
"airflow.providers.google.cloud.links.dataproc.DataprocLink",
"airflow.providers.google.cloud.operators.automl.AutoMLTablesListColumnSpecsOperator",
"airflow.providers.google.cloud.operators.automl.AutoMLTablesListTableSpecsOperator",
"airflow.providers.google.cloud.operators.automl.AutoMLTablesUpdateDatasetOperator",
"airflow.providers.google.cloud.operators.automl.AutoMLDeployModelOperator",
]
Expand Down
2 changes: 2 additions & 0 deletions tests/always/test_project_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ class TestGoogleProviderProjectStructure(ExampleCoverageTest, AssetsCoverageTest
".CloudDataTransferServiceS3ToGCSOperator",
"airflow.providers.google.cloud.operators.cloud_storage_transfer_service"
".CloudDataTransferServiceGCSToGCSOperator",
"airflow.providers.google.cloud.operators.automl.AutoMLTablesListColumnSpecsOperator",
"airflow.providers.google.cloud.operators.automl.AutoMLTablesListTableSpecsOperator",
"airflow.providers.google.cloud.operators.automl.AutoMLTablesUpdateDatasetOperator",
"airflow.providers.google.cloud.operators.automl.AutoMLDeployModelOperator",
"airflow.providers.google.cloud.operators.dataproc.DataprocSubmitHadoopJobOperator",
Expand Down
Loading

0 comments on commit e8fe9df

Please sign in to comment.