Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
feat(automl): undeprecate resource name helper methods, add 2.7 depre…
Browse files Browse the repository at this point in the history
…cation warning (via synth) (#10037)
  • Loading branch information
yoshi-automation authored and busunkim96 committed Jan 8, 2020
1 parent 75783ec commit 763a961
Show file tree
Hide file tree
Showing 7 changed files with 3,940 additions and 89 deletions.
11 changes: 11 additions & 0 deletions google/cloud/automl_v1/__init__.py
Expand Up @@ -16,13 +16,24 @@


from __future__ import absolute_import
import sys
import warnings

from google.cloud.automl_v1 import types
from google.cloud.automl_v1.gapic import auto_ml_client
from google.cloud.automl_v1.gapic import enums
from google.cloud.automl_v1.gapic import prediction_service_client


if sys.version_info[:2] == (2, 7):
message = (
"A future version of this library will drop support for Python 2.7."
"More details about Python 2 support for Google Cloud Client Libraries"
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
)
warnings.warn(message, DeprecationWarning)


class AutoMlClient(auto_ml_client.AutoMlClient):
__doc__ = auto_ml_client.AutoMlClient.__doc__
enums = enums
Expand Down
35 changes: 5 additions & 30 deletions google/cloud/automl_v1/gapic/auto_ml_client.py
Expand Up @@ -101,12 +101,7 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def annotation_spec_path(cls, project, location, dataset, annotation_spec):
"""DEPRECATED. Return a fully-qualified annotation_spec string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified annotation_spec string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}",
project=project,
Expand All @@ -117,12 +112,7 @@ def annotation_spec_path(cls, project, location, dataset, annotation_spec):

@classmethod
def dataset_path(cls, project, location, dataset):
"""DEPRECATED. Return a fully-qualified dataset string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified dataset string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/datasets/{dataset}",
project=project,
Expand All @@ -132,12 +122,7 @@ def dataset_path(cls, project, location, dataset):

@classmethod
def location_path(cls, project, location):
"""DEPRECATED. Return a fully-qualified location string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified location string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}",
project=project,
Expand All @@ -146,12 +131,7 @@ def location_path(cls, project, location):

@classmethod
def model_path(cls, project, location, model):
"""DEPRECATED. Return a fully-qualified model string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified model string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/models/{model}",
project=project,
Expand All @@ -161,12 +141,7 @@ def model_path(cls, project, location, model):

@classmethod
def model_evaluation_path(cls, project, location, model, model_evaluation):
"""DEPRECATED. Return a fully-qualified model_evaluation string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified model_evaluation string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation}",
project=project,
Expand Down
7 changes: 1 addition & 6 deletions google/cloud/automl_v1/gapic/prediction_service_client.py
Expand Up @@ -91,12 +91,7 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def model_path(cls, project, location, model):
"""DEPRECATED. Return a fully-qualified model string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified model string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/models/{model}",
project=project,
Expand Down
11 changes: 11 additions & 0 deletions google/cloud/automl_v1beta1/__init__.py
Expand Up @@ -16,6 +16,8 @@


from __future__ import absolute_import
import sys
import warnings

from google.cloud.automl_v1beta1 import types
from google.cloud.automl_v1beta1.gapic import auto_ml_client
Expand All @@ -33,6 +35,15 @@ class GcsClient(gcs_client.GcsClient):
__doc__ = gcs_client.GcsClient.__doc__


if sys.version_info[:2] == (2, 7):
message = (
"A future version of this library will drop support for Python 2.7."
"More details about Python 2 support for Google Cloud Client Libraries"
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
)
warnings.warn(message, DeprecationWarning)


class AutoMlClient(auto_ml_client.AutoMlClient):
__doc__ = auto_ml_client.AutoMlClient.__doc__
enums = enums
Expand Down
49 changes: 7 additions & 42 deletions google/cloud/automl_v1beta1/gapic/auto_ml_client.py
Expand Up @@ -103,12 +103,7 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def annotation_spec_path(cls, project, location, dataset, annotation_spec):
"""DEPRECATED. Return a fully-qualified annotation_spec string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified annotation_spec string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/datasets/{dataset}/annotationSpecs/{annotation_spec}",
project=project,
Expand All @@ -119,12 +114,7 @@ def annotation_spec_path(cls, project, location, dataset, annotation_spec):

@classmethod
def column_spec_path(cls, project, location, dataset, table_spec, column_spec):
"""DEPRECATED. Return a fully-qualified column_spec string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified column_spec string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/datasets/{dataset}/tableSpecs/{table_spec}/columnSpecs/{column_spec}",
project=project,
Expand All @@ -136,12 +126,7 @@ def column_spec_path(cls, project, location, dataset, table_spec, column_spec):

@classmethod
def dataset_path(cls, project, location, dataset):
"""DEPRECATED. Return a fully-qualified dataset string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified dataset string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/datasets/{dataset}",
project=project,
Expand All @@ -151,12 +136,7 @@ def dataset_path(cls, project, location, dataset):

@classmethod
def location_path(cls, project, location):
"""DEPRECATED. Return a fully-qualified location string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified location string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}",
project=project,
Expand All @@ -165,12 +145,7 @@ def location_path(cls, project, location):

@classmethod
def model_path(cls, project, location, model):
"""DEPRECATED. Return a fully-qualified model string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified model string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/models/{model}",
project=project,
Expand All @@ -180,12 +155,7 @@ def model_path(cls, project, location, model):

@classmethod
def model_evaluation_path(cls, project, location, model, model_evaluation):
"""DEPRECATED. Return a fully-qualified model_evaluation string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified model_evaluation string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/models/{model}/modelEvaluations/{model_evaluation}",
project=project,
Expand All @@ -196,12 +166,7 @@ def model_evaluation_path(cls, project, location, model, model_evaluation):

@classmethod
def table_spec_path(cls, project, location, dataset, table_spec):
"""DEPRECATED. Return a fully-qualified table_spec string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified table_spec string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/datasets/{dataset}/tableSpecs/{table_spec}",
project=project,
Expand Down
Expand Up @@ -95,12 +95,7 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def model_path(cls, project, location, model):
"""DEPRECATED. Return a fully-qualified model string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified model string."""
return google.api_core.path_template.expand(
"projects/{project}/locations/{location}/models/{model}",
project=project,
Expand Down

0 comments on commit 763a961

Please sign in to comment.