diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
index 2567653..7d98291 100644
--- a/.github/.OwlBot.lock.yaml
+++ b/.github/.OwlBot.lock.yaml
@@ -1,3 +1,3 @@
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
- digest: sha256:87eee22d276554e4e52863ec9b1cb6a7245815dfae20439712bf644348215a5a
+ digest: sha256:58f73ba196b5414782605236dd0712a73541b44ff2ff4d3a36ec41092dd6fa5b
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index ae570eb..3678a0a 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -4,8 +4,9 @@
# For syntax help see:
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
-# The @googleapis/api-bigquery is the default owner for changes in this repo
-* @googleapis/api-bigquery @googleapis/yoshi-python
-# The python-samples-reviewers team is the default owner for samples changes
-/samples/ @googleapis/python-samples-owners
+# @googleapis/yoshi-python and @googleapis/api-bigquery are the default owners for changes in this repo
+* @googleapis/yoshi-python @googleapis/api-bigquery
+
+# @googleapis/python-samples-owners and @googleapis/api-bigquery are the default owners for samples changes
+/samples/ @googleapis/python-samples-owners @googleapis/api-bigquery
diff --git a/.kokoro/samples/lint/common.cfg b/.kokoro/samples/lint/common.cfg
index 0dbb18f..57bfe98 100644
--- a/.kokoro/samples/lint/common.cfg
+++ b/.kokoro/samples/lint/common.cfg
@@ -31,4 +31,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
-build_file: "python-data-qna/.kokoro/trampoline.sh"
\ No newline at end of file
+build_file: "python-data-qna/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.10/common.cfg b/.kokoro/samples/python3.10/common.cfg
new file mode 100644
index 0000000..e6b00d3
--- /dev/null
+++ b/.kokoro/samples/python3.10/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Specify which tests to run
+env_vars: {
+ key: "RUN_TESTS_SESSION"
+ value: "py-3.10"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-310"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-data-qna/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-data-qna/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.10/continuous.cfg b/.kokoro/samples/python3.10/continuous.cfg
new file mode 100644
index 0000000..a1c8d97
--- /dev/null
+++ b/.kokoro/samples/python3.10/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.10/periodic-head.cfg b/.kokoro/samples/python3.10/periodic-head.cfg
new file mode 100644
index 0000000..18f7796
--- /dev/null
+++ b/.kokoro/samples/python3.10/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-data-qna/.kokoro/test-samples-against-head.sh"
+}
diff --git a/.kokoro/samples/python3.10/periodic.cfg b/.kokoro/samples/python3.10/periodic.cfg
new file mode 100644
index 0000000..71cd1e5
--- /dev/null
+++ b/.kokoro/samples/python3.10/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "False"
+}
diff --git a/.kokoro/samples/python3.10/presubmit.cfg b/.kokoro/samples/python3.10/presubmit.cfg
new file mode 100644
index 0000000..a1c8d97
--- /dev/null
+++ b/.kokoro/samples/python3.10/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.6/common.cfg b/.kokoro/samples/python3.6/common.cfg
index 1127ecb..8c83c5c 100644
--- a/.kokoro/samples/python3.6/common.cfg
+++ b/.kokoro/samples/python3.6/common.cfg
@@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
-build_file: "python-data-qna/.kokoro/trampoline.sh"
\ No newline at end of file
+build_file: "python-data-qna/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.6/periodic.cfg b/.kokoro/samples/python3.6/periodic.cfg
index 50fec96..71cd1e5 100644
--- a/.kokoro/samples/python3.6/periodic.cfg
+++ b/.kokoro/samples/python3.6/periodic.cfg
@@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
-}
\ No newline at end of file
+}
diff --git a/.kokoro/samples/python3.7/common.cfg b/.kokoro/samples/python3.7/common.cfg
index 2405634..5fbf175 100644
--- a/.kokoro/samples/python3.7/common.cfg
+++ b/.kokoro/samples/python3.7/common.cfg
@@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
-build_file: "python-data-qna/.kokoro/trampoline.sh"
\ No newline at end of file
+build_file: "python-data-qna/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.7/periodic.cfg b/.kokoro/samples/python3.7/periodic.cfg
index 50fec96..71cd1e5 100644
--- a/.kokoro/samples/python3.7/periodic.cfg
+++ b/.kokoro/samples/python3.7/periodic.cfg
@@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
-}
\ No newline at end of file
+}
diff --git a/.kokoro/samples/python3.8/common.cfg b/.kokoro/samples/python3.8/common.cfg
index 20e9c3c..b07f385 100644
--- a/.kokoro/samples/python3.8/common.cfg
+++ b/.kokoro/samples/python3.8/common.cfg
@@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
-build_file: "python-data-qna/.kokoro/trampoline.sh"
\ No newline at end of file
+build_file: "python-data-qna/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.8/periodic.cfg b/.kokoro/samples/python3.8/periodic.cfg
index 50fec96..71cd1e5 100644
--- a/.kokoro/samples/python3.8/periodic.cfg
+++ b/.kokoro/samples/python3.8/periodic.cfg
@@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
-}
\ No newline at end of file
+}
diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg
index 3a8b69f..8711f9b 100644
--- a/.kokoro/samples/python3.9/common.cfg
+++ b/.kokoro/samples/python3.9/common.cfg
@@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
# Use the trampoline script to run in docker.
-build_file: "python-data-qna/.kokoro/trampoline.sh"
\ No newline at end of file
+build_file: "python-data-qna/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg
index 50fec96..71cd1e5 100644
--- a/.kokoro/samples/python3.9/periodic.cfg
+++ b/.kokoro/samples/python3.9/periodic.cfg
@@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
-}
\ No newline at end of file
+}
diff --git a/.kokoro/test-samples-against-head.sh b/.kokoro/test-samples-against-head.sh
index 0eda5e2..ba3a707 100755
--- a/.kokoro/test-samples-against-head.sh
+++ b/.kokoro/test-samples-against-head.sh
@@ -23,6 +23,4 @@ set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar
-cd github/python-data-qna
-
exec .kokoro/test-samples-impl.sh
diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh
index cbda541..11c042d 100755
--- a/.kokoro/test-samples.sh
+++ b/.kokoro/test-samples.sh
@@ -24,8 +24,6 @@ set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar
-cd github/python-data-qna
-
# Run periodic samples tests at latest release
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
# preserving the test runner implementation.
diff --git a/.repo-metadata.json b/.repo-metadata.json
index 748f413..461c60a 100644
--- a/.repo-metadata.json
+++ b/.repo-metadata.json
@@ -1,13 +1,15 @@
{
- "name": "dataqna",
- "name_pretty": "Data QnA",
- "product_documentation": "https://cloud.google.com/bigquery/docs/dataqna",
- "client_documentation": "https://googleapis.dev/python/dataqna/latest",
- "issue_tracker": "",
- "release_level": "alpha",
- "language": "python",
- "library_type": "GAPIC_AUTO",
- "repo": "googleapis/python-data-qna",
- "distribution_name": "google-cloud-data-qna",
- "api_id": "dataqna.googleapis.com"
+ "name": "dataqna",
+ "name_pretty": "Data QnA",
+ "product_documentation": "https://cloud.google.com/bigquery/docs/dataqna",
+ "client_documentation": "https://googleapis.dev/python/dataqna/latest",
+ "issue_tracker": "",
+ "release_level": "alpha",
+ "language": "python",
+ "library_type": "GAPIC_AUTO",
+ "repo": "googleapis/python-data-qna",
+ "distribution_name": "google-cloud-data-qna",
+ "api_id": "dataqna.googleapis.com",
+ "codeowner_team": "@googleapis/api-bigquery",
+ "default_version": "v1alpha"
}
diff --git a/.trampolinerc b/.trampolinerc
index 383b6ec..0eee72a 100644
--- a/.trampolinerc
+++ b/.trampolinerc
@@ -16,15 +16,26 @@
# Add required env vars here.
required_envvars+=(
- "STAGING_BUCKET"
- "V2_STAGING_BUCKET"
)
# Add env vars which are passed down into the container here.
pass_down_envvars+=(
+ "NOX_SESSION"
+ ###############
+ # Docs builds
+ ###############
"STAGING_BUCKET"
"V2_STAGING_BUCKET"
- "NOX_SESSION"
+ ##################
+ # Samples builds
+ ##################
+ "INSTALL_LIBRARY_FROM_SOURCE"
+ "RUN_TESTS_SESSION"
+ "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ # Target directories.
+ "RUN_TESTS_DIRS"
+ # The nox session to run.
+ "RUN_TESTS_SESSION"
)
# Prevent unintentional override on the default image.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70af584..243d8a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## [0.4.0](https://www.github.com/googleapis/python-data-qna/compare/v0.3.3...v0.4.0) (2021-10-08)
+
+
+### Features
+
+* add context manager support in client ([#93](https://www.github.com/googleapis/python-data-qna/issues/93)) ([9a0ef96](https://www.github.com/googleapis/python-data-qna/commit/9a0ef9636ec8deb2d7b8f0cc18eb3a2d363d5da1))
+
### [0.3.3](https://www.github.com/googleapis/python-data-qna/compare/v0.3.2...v0.3.3) (2021-09-24)
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 0886ec9..02b9e65 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -22,7 +22,7 @@ In order to add a feature:
documentation.
- The feature must work fully on the following CPython versions:
- 3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows.
+ 3.6, 3.7, 3.8, 3.9 and 3.10 on both UNIX and Windows.
- The feature must not add unnecessary dependencies (where
"unnecessary" is of course subjective, but new dependencies should
@@ -72,7 +72,7 @@ We use `nox `__ to instrument our tests.
- To run a single unit test::
- $ nox -s unit-3.9 -- -k
+ $ nox -s unit-3.10 -- -k
.. note::
@@ -225,11 +225,13 @@ We support:
- `Python 3.7`_
- `Python 3.8`_
- `Python 3.9`_
+- `Python 3.10`_
.. _Python 3.6: https://docs.python.org/3.6/
.. _Python 3.7: https://docs.python.org/3.7/
.. _Python 3.8: https://docs.python.org/3.8/
.. _Python 3.9: https://docs.python.org/3.9/
+.. _Python 3.10: https://docs.python.org/3.10/
Supported versions can be found in our ``noxfile.py`` `config`_.
diff --git a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py
index 9b631ff..6a2e000 100644
--- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py
+++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py
@@ -279,6 +279,12 @@ async def suggest_queries(
# Done; return the response.
return response
+ async def __aenter__(self):
+ return self
+
+ async def __aexit__(self, exc_type, exc, tb):
+ await self.transport.close()
+
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
diff --git a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py
index be21a0c..a6cb48d 100644
--- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py
+++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py
@@ -400,10 +400,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
- always_use_jwt_access=(
- Transport == type(self).get_transport_class("grpc")
- or Transport == type(self).get_transport_class("grpc_asyncio")
- ),
+ always_use_jwt_access=True,
)
def suggest_queries(
@@ -454,6 +451,19 @@ def suggest_queries(
# Done; return the response.
return response
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ """Releases underlying transport's resources.
+
+ .. warning::
+ ONLY use as a context manager if the transport is NOT shared
+ with other clients! Exiting the with block will CLOSE the transport
+ and may cause errors in other clients!
+ """
+ self.transport.close()
+
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
diff --git a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py
index afc02ce..8e02396 100644
--- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py
+++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py
@@ -157,6 +157,15 @@ def _prep_wrapped_messages(self, client_info):
),
}
+ def close(self):
+ """Closes resources associated with the transport.
+
+ .. warning::
+ Only call this method if the transport is NOT shared
+ with other clients - this may cause errors in other clients!
+ """
+ raise NotImplementedError()
+
@property
def suggest_queries(
self,
diff --git a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py
index 83ede04..78ed4b6 100644
--- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py
+++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py
@@ -325,5 +325,8 @@ def suggest_queries(
)
return self._stubs["suggest_queries"]
+ def close(self):
+ self.grpc_channel.close()
+
__all__ = ("AutoSuggestionServiceGrpcTransport",)
diff --git a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc_asyncio.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc_asyncio.py
index f182915..21af0d4 100644
--- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc_asyncio.py
+++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc_asyncio.py
@@ -328,5 +328,8 @@ def suggest_queries(
)
return self._stubs["suggest_queries"]
+ def close(self):
+ return self.grpc_channel.close()
+
__all__ = ("AutoSuggestionServiceGrpcAsyncIOTransport",)
diff --git a/google/cloud/dataqna_v1alpha/services/question_service/async_client.py b/google/cloud/dataqna_v1alpha/services/question_service/async_client.py
index 12bbfc3..0c6dac7 100644
--- a/google/cloud/dataqna_v1alpha/services/question_service/async_client.py
+++ b/google/cloud/dataqna_v1alpha/services/question_service/async_client.py
@@ -582,6 +582,12 @@ async def update_user_feedback(
# Done; return the response.
return response
+ async def __aenter__(self):
+ return self
+
+ async def __aexit__(self, exc_type, exc, tb):
+ await self.transport.close()
+
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
diff --git a/google/cloud/dataqna_v1alpha/services/question_service/client.py b/google/cloud/dataqna_v1alpha/services/question_service/client.py
index 1d754dd..b5cd307 100644
--- a/google/cloud/dataqna_v1alpha/services/question_service/client.py
+++ b/google/cloud/dataqna_v1alpha/services/question_service/client.py
@@ -383,10 +383,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
- always_use_jwt_access=(
- Transport == type(self).get_transport_class("grpc")
- or Transport == type(self).get_transport_class("grpc_asyncio")
- ),
+ always_use_jwt_access=True,
)
def get_question(
@@ -783,6 +780,19 @@ def update_user_feedback(
# Done; return the response.
return response
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ """Releases underlying transport's resources.
+
+ .. warning::
+ ONLY use as a context manager if the transport is NOT shared
+ with other clients! Exiting the with block will CLOSE the transport
+ and may cause errors in other clients!
+ """
+ self.transport.close()
+
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
diff --git a/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py b/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py
index 7677868..493845b 100644
--- a/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py
+++ b/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py
@@ -175,6 +175,15 @@ def _prep_wrapped_messages(self, client_info):
),
}
+ def close(self):
+ """Closes resources associated with the transport.
+
+ .. warning::
+ Only call this method if the transport is NOT shared
+ with other clients - this may cause errors in other clients!
+ """
+ raise NotImplementedError()
+
@property
def get_question(
self,
diff --git a/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py b/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py
index 272bf11..ff5c3c4 100644
--- a/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py
+++ b/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py
@@ -380,5 +380,8 @@ def update_user_feedback(
)
return self._stubs["update_user_feedback"]
+ def close(self):
+ self.grpc_channel.close()
+
__all__ = ("QuestionServiceGrpcTransport",)
diff --git a/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc_asyncio.py b/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc_asyncio.py
index 16c0989..57f171d 100644
--- a/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc_asyncio.py
+++ b/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc_asyncio.py
@@ -388,5 +388,8 @@ def update_user_feedback(
)
return self._stubs["update_user_feedback"]
+ def close(self):
+ return self.grpc_channel.close()
+
__all__ = ("QuestionServiceGrpcAsyncIOTransport",)
diff --git a/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py b/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py
index 075e553..b33666a 100644
--- a/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py
+++ b/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py
@@ -39,6 +39,7 @@ class SuggestionType(proto.Enum):
class SuggestQueriesRequest(proto.Message):
r"""Request for query suggestions.
+
Attributes:
parent (str):
Required. The parent of the suggestion query
@@ -72,6 +73,7 @@ class SuggestQueriesRequest(proto.Message):
class Suggestion(proto.Message):
r"""A suggestion for a query with a ranking score.
+
Attributes:
suggestion_info (google.cloud.dataqna_v1alpha.types.SuggestionInfo):
Detailed information about the suggestion.
@@ -91,6 +93,7 @@ class Suggestion(proto.Message):
class SuggestionInfo(proto.Message):
r"""Detailed information about the suggestion.
+
Attributes:
annotated_suggestion (google.cloud.dataqna_v1alpha.types.AnnotatedString):
Annotations for the suggestion. This provides
@@ -148,6 +151,7 @@ class MatchInfo(proto.Message):
class SuggestQueriesResponse(proto.Message):
r"""Response to SuggestQueries.
+
Attributes:
suggestions (Sequence[google.cloud.dataqna_v1alpha.types.Suggestion]):
A list of suggestions.
diff --git a/google/cloud/dataqna_v1alpha/types/question.py b/google/cloud/dataqna_v1alpha/types/question.py
index 5d79f86..9b600d8 100644
--- a/google/cloud/dataqna_v1alpha/types/question.py
+++ b/google/cloud/dataqna_v1alpha/types/question.py
@@ -118,6 +118,7 @@ class Question(proto.Message):
class InterpretError(proto.Message):
r"""Details on the failure to interpret the question.
+
Attributes:
message (str):
Error message explaining why this question
@@ -140,6 +141,7 @@ class InterpretErrorCode(proto.Enum):
class InterpretErrorDetails(proto.Message):
r"""Details on interpretation failure.
+
Attributes:
unsupported_details (google.cloud.dataqna_v1alpha.types.InterpretError.InterpretUnsupportedDetails):
Populated if parts of the query are
@@ -166,6 +168,7 @@ class InterpretErrorDetails(proto.Message):
class InterpretUnsupportedDetails(proto.Message):
r"""Details about unsupported parts in a query.
+
Attributes:
operators (Sequence[str]):
Unsupported operators. For example: median.
@@ -178,6 +181,7 @@ class InterpretUnsupportedDetails(proto.Message):
class InterpretIncompleteQueryDetails(proto.Message):
r"""Details about an incomplete query.
+
Attributes:
entities (Sequence[google.cloud.dataqna_v1alpha.types.InterpretEntity]):
List of missing interpret entities.
@@ -189,7 +193,8 @@ class InterpretAmbiguityDetails(proto.Message):
r"""Details about a query that was too ambiguous. Currently, the
message has no fields and its presence signals that there was
ambiguity.
- """
+
+ """
message = proto.Field(proto.STRING, number=1,)
code = proto.Field(proto.ENUM, number=2, enum=InterpretErrorCode,)
@@ -252,6 +257,7 @@ class BigQueryJob(proto.Message):
class Interpretation(proto.Message):
r"""An interpretation of a natural language query.
+
Attributes:
data_sources (Sequence[str]):
List of data sources used in the current
@@ -310,6 +316,7 @@ class DataQuery(proto.Message):
class HumanReadable(proto.Message):
r"""Human readable interpretation.
+
Attributes:
generated_interpretation (google.cloud.dataqna_v1alpha.types.AnnotatedString):
Generated query explaining the
@@ -361,6 +368,7 @@ class VisualizationType(proto.Enum):
class ColumnInfo(proto.Message):
r"""Information about a column.
+
Attributes:
output_alias (str):
The alias of the output column as used by the
@@ -382,6 +390,7 @@ class ColumnInfo(proto.Message):
class DebugFlags(proto.Message):
r"""Configuriation of debug flags.
+
Attributes:
include_va_query (bool):
Whether to include the original VAQuery.
diff --git a/google/cloud/dataqna_v1alpha/types/question_service.py b/google/cloud/dataqna_v1alpha/types/question_service.py
index d23c0d9..2e0cfde 100644
--- a/google/cloud/dataqna_v1alpha/types/question_service.py
+++ b/google/cloud/dataqna_v1alpha/types/question_service.py
@@ -34,6 +34,7 @@
class GetQuestionRequest(proto.Message):
r"""A request to get a previously created question.
+
Attributes:
name (str):
Required. The unique identifier for the question. Example:
@@ -48,6 +49,7 @@ class GetQuestionRequest(proto.Message):
class CreateQuestionRequest(proto.Message):
r"""Request to create a question resource.
+
Attributes:
parent (str):
Required. The name of the project this data source reference
@@ -62,6 +64,7 @@ class CreateQuestionRequest(proto.Message):
class ExecuteQuestionRequest(proto.Message):
r"""Request to execute an interpretation.
+
Attributes:
name (str):
Required. The unique identifier for the question. Example:
@@ -77,6 +80,7 @@ class ExecuteQuestionRequest(proto.Message):
class GetUserFeedbackRequest(proto.Message):
r"""Request to get user feedback.
+
Attributes:
name (str):
Required. The unique identifier for the user feedback. User
@@ -89,6 +93,7 @@ class GetUserFeedbackRequest(proto.Message):
class UpdateUserFeedbackRequest(proto.Message):
r"""Request to updates user feedback.
+
Attributes:
user_feedback (google.cloud.dataqna_v1alpha.types.UserFeedback):
Required. The user feedback to update. This
diff --git a/google/cloud/dataqna_v1alpha/types/user_feedback.py b/google/cloud/dataqna_v1alpha/types/user_feedback.py
index 8aa69bc..9fea580 100644
--- a/google/cloud/dataqna_v1alpha/types/user_feedback.py
+++ b/google/cloud/dataqna_v1alpha/types/user_feedback.py
@@ -23,6 +23,7 @@
class UserFeedback(proto.Message):
r"""Feedback provided by a user.
+
Attributes:
name (str):
Required. The unique identifier for the user feedback. User
diff --git a/noxfile.py b/noxfile.py
index 2bf3ffd..672b28d 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -29,7 +29,7 @@
DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
-UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
+UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
diff --git a/setup.py b/setup.py
index fc26562..129d35d 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@
import os
import setuptools # type: ignore
-version = "0.3.3"
+version = "0.4.0"
package_root = os.path.abspath(os.path.dirname(__file__))
diff --git a/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py b/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py
index 1b17290..8782bb9 100644
--- a/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py
+++ b/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py
@@ -29,6 +29,7 @@
from google.api_core import gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
+from google.api_core import path_template
from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.dataqna_v1alpha.services.auto_suggestion_service import (
@@ -758,6 +759,9 @@ def test_auto_suggestion_service_base_transport():
with pytest.raises(NotImplementedError):
getattr(transport, method)(request=object())
+ with pytest.raises(NotImplementedError):
+ transport.close()
+
@requires_google_auth_gte_1_25_0
def test_auto_suggestion_service_base_transport_with_credentials_file():
@@ -1220,3 +1224,49 @@ def test_client_withDEFAULT_CLIENT_INFO():
credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)
+
+
+@pytest.mark.asyncio
+async def test_transport_close_async():
+ client = AutoSuggestionServiceAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio",
+ )
+ with mock.patch.object(
+ type(getattr(client.transport, "grpc_channel")), "close"
+ ) as close:
+ async with client:
+ close.assert_not_called()
+ close.assert_called_once()
+
+
+def test_transport_close():
+ transports = {
+ "grpc": "_grpc_channel",
+ }
+
+ for transport, close_name in transports.items():
+ client = AutoSuggestionServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport
+ )
+ with mock.patch.object(
+ type(getattr(client.transport, close_name)), "close"
+ ) as close:
+ with client:
+ close.assert_not_called()
+ close.assert_called_once()
+
+
+def test_client_ctx():
+ transports = [
+ "grpc",
+ ]
+ for transport in transports:
+ client = AutoSuggestionServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport
+ )
+ # Test client calls underlying transport.
+ with mock.patch.object(type(client.transport), "close") as close:
+ close.assert_not_called()
+ with client:
+ pass
+ close.assert_called()
diff --git a/tests/unit/gapic/dataqna_v1alpha/test_question_service.py b/tests/unit/gapic/dataqna_v1alpha/test_question_service.py
index b887e88..7c8bd67 100644
--- a/tests/unit/gapic/dataqna_v1alpha/test_question_service.py
+++ b/tests/unit/gapic/dataqna_v1alpha/test_question_service.py
@@ -29,6 +29,7 @@
from google.api_core import gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
+from google.api_core import path_template
from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.dataqna_v1alpha.services.question_service import (
@@ -1780,6 +1781,9 @@ def test_question_service_base_transport():
with pytest.raises(NotImplementedError):
getattr(transport, method)(request=object())
+ with pytest.raises(NotImplementedError):
+ transport.close()
+
@requires_google_auth_gte_1_25_0
def test_question_service_base_transport_with_credentials_file():
@@ -2286,3 +2290,49 @@ def test_client_withDEFAULT_CLIENT_INFO():
credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)
+
+
+@pytest.mark.asyncio
+async def test_transport_close_async():
+ client = QuestionServiceAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio",
+ )
+ with mock.patch.object(
+ type(getattr(client.transport, "grpc_channel")), "close"
+ ) as close:
+ async with client:
+ close.assert_not_called()
+ close.assert_called_once()
+
+
+def test_transport_close():
+ transports = {
+ "grpc": "_grpc_channel",
+ }
+
+ for transport, close_name in transports.items():
+ client = QuestionServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport
+ )
+ with mock.patch.object(
+ type(getattr(client.transport, close_name)), "close"
+ ) as close:
+ with client:
+ close.assert_not_called()
+ close.assert_called_once()
+
+
+def test_client_ctx():
+ transports = [
+ "grpc",
+ ]
+ for transport in transports:
+ client = QuestionServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport
+ )
+ # Test client calls underlying transport.
+ with mock.patch.object(type(client.transport), "close") as close:
+ close.assert_not_called()
+ with client:
+ pass
+ close.assert_called()