feat: implement async rest transport constructor#2123
Conversation
5f258b8 to
9b45d08
Compare
90999f3 to
7d58f1f
Compare
b90b18f to
7124af4
Compare
097aa19 to
9f9471d
Compare
9f9471d to
f4f941c
Compare
fbceb22 to
dd34d55
Compare
2c28ab3 to
6cad5b9
Compare
dd34d55 to
aa4bfa6
Compare
aa4bfa6 to
d9f8d2b
Compare
6cad5b9 to
fcc89de
Compare
| matrix: | ||
| python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | ||
| variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins] | ||
| variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, "_w_rest_async"] |
There was a problem hiding this comment.
It seems like the previous entries were a comprehensive listing of various combinations (on/off along two axes: alternate_templates, mixins). Now it seems like you're adding another axis, async_rest, so we should have 8 entries to test all combinations. (In other words, with _w_rest_async, what are we using for template type and for mixins?
Ideally, we would have a 2x2x2 matrix here of (template-type, mixins, rest_async). That said, we don't want to get too distracted from the async work right now, so maybe simply a comment about what this variant includes/excludes is fine for now.
| {% if rest_async_io_enabled %} | ||
| from .transports.rest_asyncio import Async{{ service.name }}RestTransport | ||
| {% endif %}{# if rest_async_io_enabled #} |
There was a problem hiding this comment.
| {% if rest_async_io_enabled %} | |
| from .transports.rest_asyncio import Async{{ service.name }}RestTransport | |
| {% endif %}{# if rest_async_io_enabled #} | |
| {# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove this condition (and the variable set at the top of this file) for async rest transport once support for it is GA #} | |
| {% if rest_async_io_enabled %} | |
| from .transports.rest_asyncio import Async{{ service.name }}RestTransport | |
| {% endif %}{# if rest_async_io_enabled #} |
There was a problem hiding this comment.
Also use the same format for these GA-TODOs in the other files.
| {% endif %} | ||
| {% if "rest" in opts.transport %} | ||
| _transport_registry["rest"] = {{ service.name }}RestTransport | ||
| {% if rest_async_io_enabled %} |
There was a problem hiding this comment.
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove this condition when async rest is GA #}
There was a problem hiding this comment.
LOL. GitHub shortened and hyperlinked the full URL I intended here.
| {% macro transport_kind_test(service, transport_name) %} | ||
| {%- set named_clients = { |
There was a problem hiding this comment.
| {% macro transport_kind_test(service, transport_name) %} | |
| {%- set named_clients = { | |
| {% macro transport_kind_test(service, transport_name) %} | |
| {# Look-up tables for parameter values corresponding to each possible transport-name #} | |
| {%- set named_clients = { |
There was a problem hiding this comment.
I ended up removing this dict since there's only two possible clients that we can have i.e. sync or async. Added a separate macro for it.
| session, templates="DEFAULT", other_opts: typing.Iterable[str] = (), | ||
| include_service_yaml=True, | ||
| retry_config=True, | ||
| rest_async_io_enabled=False |
There was a problem hiding this comment.
This line should also have a TODO to remove the param once async REST is GA?
| {% macro get_client(service, is_async) %} | ||
| {{-service.async_client_name if is_async else service.client_name-}} | ||
| {% endmacro %} | ||
|
|
||
| {% macro transport_kind_test(service, transport_name, is_async) %} | ||
| def test_transport_kind_{{transport_name}}(): | ||
| transport = {{ get_client(service, is_async) }}.get_transport_class("{{transport_name}}")( | ||
| credentials={{get_credentials(is_async)}} |
There was a problem hiding this comment.
| {% macro get_client(service, is_async) %} | |
| {{-service.async_client_name if is_async else service.client_name-}} | |
| {% endmacro %} | |
| {% macro transport_kind_test(service, transport_name, is_async) %} | |
| def test_transport_kind_{{transport_name}}(): | |
| transport = {{ get_client(service, is_async) }}.get_transport_class("{{transport_name}}")( | |
| credentials={{get_credentials(is_async)}} | |
| {% macro get_client(service, is_async) %} | |
| {{- service.async_client_name if is_async else service.client_name -}} | |
| {% endmacro %} | |
| {% macro transport_kind_test(service, transport_name, is_async) %} | |
| def test_transport_kind_{{ transport_name }}(): | |
| transport = {{ get_client(service, is_async) }}.get_transport_class("{{ transport_name }}")( | |
| credentials={{ get_credentials(is_async) }} |
| {% endif %} | ||
| {% if "rest" in opts.transport %} | ||
| _transport_registry["rest"] = {{ service.name }}RestTransport | ||
| {% if rest_async_io_enabled %} |
There was a problem hiding this comment.
LOL. GitHub shortened and hyperlinked the full URL I intended here.
vchudnov-g
left a comment
There was a problem hiding this comment.
Thanks for doing this! Looks great!
This PR introduces an async rest transport with minimal parameters and a
kindproperty. It also sets up the testing infra for async rest i.e: