Skip to content
Permalink
Browse files
feat(automl): undeprecate resource name helper methods, add 2.7 depre…
…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.
@@ -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
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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
@@ -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
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,
@@ -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,

0 comments on commit 763a961

Please sign in to comment.