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

feat: Migrate API to use python micro-generator #41

Merged
merged 11 commits into from Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions .coveragerc
Expand Up @@ -23,16 +23,14 @@ omit =
[report]
fail_under = 100
show_missing = True
omit = google/cloud/language/__init__.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore abstract methods
raise NotImplementedError
omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
google/cloud/__init__.py
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.6/common.cfg
Expand Up @@ -13,6 +13,12 @@ env_vars: {
value: "py-3.6"
}

# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py36"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-language/.kokoro/test-samples.sh"
Expand Down
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.7/common.cfg
Expand Up @@ -13,6 +13,12 @@ env_vars: {
value: "py-3.7"
}

# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py37"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-language/.kokoro/test-samples.sh"
Expand Down
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.8/common.cfg
Expand Up @@ -13,6 +13,12 @@ env_vars: {
value: "py-3.8"
}

# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py38"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-language/.kokoro/test-samples.sh"
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -347,7 +347,7 @@
intersphinx_mapping = {
"python": ("http://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"grpc": ("https://grpc.io/grpc/python/", None),
}

Expand Down
6 changes: 0 additions & 6 deletions docs/gapic/v1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1/types.rst

This file was deleted.

6 changes: 0 additions & 6 deletions docs/gapic/v1beta2/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1beta2/types.rst

This file was deleted.

6 changes: 6 additions & 0 deletions docs/language_v1/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Language v1 API
=========================================

.. automodule:: google.cloud.language_v1.services.language_service
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/language_v1/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Language v1 API
======================================

.. automodule:: google.cloud.language_v1.types
:members:
6 changes: 6 additions & 0 deletions docs/language_v1beta2/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Language v1beta2 API
==============================================

.. automodule:: google.cloud.language_v1beta2.services.language_service
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/language_v1beta2/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Language v1beta2 API
===========================================

.. automodule:: google.cloud.language_v1beta2.types
:members:
78 changes: 78 additions & 0 deletions google/cloud/language/__init__.py
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from google.cloud.language_v1.services.language_service.async_client import (
LanguageServiceAsyncClient,
)
from google.cloud.language_v1.services.language_service.client import (
LanguageServiceClient,
)
from google.cloud.language_v1.types.language_service import AnalyzeEntitiesRequest
from google.cloud.language_v1.types.language_service import AnalyzeEntitiesResponse
from google.cloud.language_v1.types.language_service import (
AnalyzeEntitySentimentRequest,
)
from google.cloud.language_v1.types.language_service import (
AnalyzeEntitySentimentResponse,
)
from google.cloud.language_v1.types.language_service import AnalyzeSentimentRequest
from google.cloud.language_v1.types.language_service import AnalyzeSentimentResponse
from google.cloud.language_v1.types.language_service import AnalyzeSyntaxRequest
from google.cloud.language_v1.types.language_service import AnalyzeSyntaxResponse
from google.cloud.language_v1.types.language_service import AnnotateTextRequest
from google.cloud.language_v1.types.language_service import AnnotateTextResponse
from google.cloud.language_v1.types.language_service import ClassificationCategory
from google.cloud.language_v1.types.language_service import ClassifyTextRequest
from google.cloud.language_v1.types.language_service import ClassifyTextResponse
from google.cloud.language_v1.types.language_service import DependencyEdge
from google.cloud.language_v1.types.language_service import Document
from google.cloud.language_v1.types.language_service import EncodingType
from google.cloud.language_v1.types.language_service import Entity
from google.cloud.language_v1.types.language_service import EntityMention
from google.cloud.language_v1.types.language_service import PartOfSpeech
from google.cloud.language_v1.types.language_service import Sentence
from google.cloud.language_v1.types.language_service import Sentiment
from google.cloud.language_v1.types.language_service import TextSpan
from google.cloud.language_v1.types.language_service import Token

__all__ = (
"AnalyzeEntitiesRequest",
"AnalyzeEntitiesResponse",
"AnalyzeEntitySentimentRequest",
"AnalyzeEntitySentimentResponse",
"AnalyzeSentimentRequest",
"AnalyzeSentimentResponse",
"AnalyzeSyntaxRequest",
"AnalyzeSyntaxResponse",
"AnnotateTextRequest",
"AnnotateTextResponse",
"ClassificationCategory",
"ClassifyTextRequest",
"ClassifyTextResponse",
"DependencyEdge",
"Document",
"EncodingType",
"Entity",
"EntityMention",
"LanguageServiceAsyncClient",
"LanguageServiceClient",
"PartOfSpeech",
"Sentence",
"Sentiment",
"TextSpan",
"Token",
)
2 changes: 2 additions & 0 deletions google/cloud/language/py.typed
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-language package uses inline types.
66 changes: 54 additions & 12 deletions google/cloud/language_v1/__init__.py
@@ -1,4 +1,6 @@
# Copyright 2017, Google LLC All rights reserved.
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,17 +13,57 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from __future__ import absolute_import

from google.cloud.language_v1 import types
from google.cloud.language_v1.gapic import enums
from google.cloud.language_v1.gapic import language_service_client


class LanguageServiceClient(language_service_client.LanguageServiceClient):
__doc__ = language_service_client.LanguageServiceClient.__doc__
enums = enums
from .services.language_service import LanguageServiceClient
from .types.language_service import AnalyzeEntitiesRequest
from .types.language_service import AnalyzeEntitiesResponse
from .types.language_service import AnalyzeEntitySentimentRequest
from .types.language_service import AnalyzeEntitySentimentResponse
from .types.language_service import AnalyzeSentimentRequest
from .types.language_service import AnalyzeSentimentResponse
from .types.language_service import AnalyzeSyntaxRequest
from .types.language_service import AnalyzeSyntaxResponse
from .types.language_service import AnnotateTextRequest
from .types.language_service import AnnotateTextResponse
from .types.language_service import ClassificationCategory
from .types.language_service import ClassifyTextRequest
from .types.language_service import ClassifyTextResponse
from .types.language_service import DependencyEdge
from .types.language_service import Document
from .types.language_service import EncodingType
from .types.language_service import Entity
from .types.language_service import EntityMention
from .types.language_service import PartOfSpeech
from .types.language_service import Sentence
from .types.language_service import Sentiment
from .types.language_service import TextSpan
from .types.language_service import Token


__all__ = ("enums", "types", "LanguageServiceClient")
__all__ = (
"AnalyzeEntitiesRequest",
"AnalyzeEntitiesResponse",
"AnalyzeEntitySentimentRequest",
"AnalyzeEntitySentimentResponse",
"AnalyzeSentimentRequest",
"AnalyzeSentimentResponse",
"AnalyzeSyntaxRequest",
"AnalyzeSyntaxResponse",
"AnnotateTextRequest",
"AnnotateTextResponse",
"ClassificationCategory",
"ClassifyTextRequest",
"ClassifyTextResponse",
"DependencyEdge",
"Document",
"EncodingType",
"Entity",
"EntityMention",
"PartOfSpeech",
"Sentence",
"Sentiment",
"TextSpan",
"Token",
"LanguageServiceClient",
)
2 changes: 2 additions & 0 deletions google/cloud/language_v1/py.typed
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-language package uses inline types.
@@ -1,4 +1,6 @@
# Copyright 2016 Google LLC
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,3 +13,4 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
@@ -1,4 +1,6 @@
# Copyright 2016 Google LLC
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -11,12 +13,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

try:
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
from .client import LanguageServiceClient
from .async_client import LanguageServiceAsyncClient

__path__ = pkgutil.extend_path(__path__, __name__)
__all__ = (
"LanguageServiceClient",
"LanguageServiceAsyncClient",
)