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 1 commit
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
22 changes: 0 additions & 22 deletions google/cloud/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions google/cloud/language.py

This file was deleted.

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",
)
66 changes: 54 additions & 12 deletions google/cloud/language_v1beta2/__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_v1beta2 import types
from google.cloud.language_v1beta2.gapic import enums
from google.cloud.language_v1beta2.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",
)
19 changes: 12 additions & 7 deletions setup.py
Expand Up @@ -29,8 +29,9 @@
# 'Development Status :: 5 - Production/Stable'
release_status = "Development Status :: 5 - Production/Stable"
dependencies = [
"google-api-core[grpc] >= 1.14.0, < 2.0.0dev",
'enum34;python_version<"3.4"',
"google-api-core[grpc] >= 1.22.2, < 2.0.0dev",
"proto-plus >= 1.4.0",
"libcst >= 0.2.5",
]
extras = {}

Expand All @@ -46,7 +47,9 @@
# Only include packages under the 'google' namespace. Do not include tests,
# benchmarks, etc.
packages = [
package for package in setuptools.find_packages() if package.startswith("google")
package
for package in setuptools.PEP420PackageFinder.find()
if package.startswith("google")
]

# Determine which namespaces are needed.
Expand All @@ -69,12 +72,10 @@
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Operating System :: OS Independent",
"Topic :: Internet",
],
Expand All @@ -83,7 +84,11 @@
namespace_packages=namespaces,
install_requires=dependencies,
extras_require=extras,
python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
python_requires=">=3.6",
scripts=[
"scripts/fixup_language_v1_keywords.py",
"scripts/fixup_language_v1beta2_keywords.py"
],
include_package_data=True,
zip_safe=False,
)
4 changes: 2 additions & 2 deletions synth.metadata
Expand Up @@ -3,8 +3,8 @@
{
"git": {
"name": ".",
"remote": "git@github.com:/googleapis/python-language.git",
"sha": "8be89edfeac45bce555aa8bf3d1279833c49d36f"
"remote": "https://github.com/googleapis/python-language.git",
"sha": "da77485629325df112f7873d6b8dfda87a856a74"
}
},
{
Expand Down
15 changes: 1 addition & 14 deletions synth.py
Expand Up @@ -38,23 +38,10 @@
# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, samples=True, microgenerator=True,)
templated_files = common.py_library(cov_level=99, samples=True, microgenerator=True,)

s.move(templated_files, excludes=['.coveragerc'])

s.replace("google/cloud/**/language_service_pb2.py",
'''__doc__ = """################################################################
#

Represents the input to API methods.''',
'''__doc__="""Represents the input to API methods.'''
)
s.replace(
f"google/cloud/**/gapic/language_service_client.py",
r"types\.EncodingType",
"enums.EncodingType",
)

# TODO(busunkim): Use latest sphinx after microgenerator transition
s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"')
software-dov marked this conversation as resolved.
Show resolved Hide resolved

Expand Down