Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement async rest transport constructor #2123

Merged
merged 8 commits into from
Sep 5, 2024

Conversation

ohmayr
Copy link
Contributor

@ohmayr ohmayr commented Sep 1, 2024

This PR introduces an async rest transport with minimal parameters and a kind property. It also sets up the testing infra for async rest i.e:

  • add a new nox session to test async rest transport.
  • updates the github workflow to include the new nox session.
  • adds a list of configurations to run macros against.
  • update the redis golden service yaml file to include the experimental feature flag
  • update the service yaml for showcase within the noxfile for testing the new feature against the added feature flag.

@product-auto-label product-auto-label bot added size: m Pull request size is medium. size: l Pull request size is large. and removed size: m Pull request size is medium. labels Sep 1, 2024
@ohmayr ohmayr force-pushed the introduce-async-transport branch from 5f258b8 to 9b45d08 Compare September 1, 2024 20:01
@ohmayr ohmayr changed the title initial setup: implement async rest transport constructor setup: implement async rest transport constructor Sep 1, 2024
@ohmayr ohmayr force-pushed the introduce-async-transport branch from 90999f3 to 7d58f1f Compare September 1, 2024 20:44
@ohmayr ohmayr changed the base branch from main to async-rest-initial September 1, 2024 20:46
@ohmayr ohmayr force-pushed the introduce-async-transport branch 2 times, most recently from b90b18f to 7124af4 Compare September 1, 2024 20:52
@ohmayr ohmayr changed the title setup: implement async rest transport constructor feat: implement async rest transport constructor Sep 1, 2024
@ohmayr ohmayr force-pushed the introduce-async-transport branch 5 times, most recently from 097aa19 to 9f9471d Compare September 2, 2024 17:12
@ohmayr ohmayr marked this pull request as ready for review September 3, 2024 17:26
@ohmayr ohmayr requested a review from a team as a code owner September 3, 2024 17:26
@ohmayr ohmayr force-pushed the introduce-async-transport branch from 9f9471d to f4f941c Compare September 3, 2024 19:48
@ohmayr ohmayr force-pushed the async-rest-initial branch from fbceb22 to dd34d55 Compare September 3, 2024 20:20
@ohmayr ohmayr force-pushed the introduce-async-transport branch 2 times, most recently from 2c28ab3 to 6cad5b9 Compare September 3, 2024 20:33
@ohmayr ohmayr force-pushed the async-rest-initial branch from dd34d55 to aa4bfa6 Compare September 3, 2024 20:35
@ohmayr ohmayr force-pushed the async-rest-initial branch from aa4bfa6 to d9f8d2b Compare September 3, 2024 20:36
@ohmayr ohmayr force-pushed the introduce-async-transport branch from 6cad5b9 to fcc89de Compare September 3, 2024 20:42
.github/workflows/tests.yaml Outdated Show resolved Hide resolved
@@ -140,7 +140,7 @@ jobs:
strategy:
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"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +70 to +72
{% if rest_async_io_enabled %}
from .transports.rest_asyncio import Async{{ service.name }}RestTransport
{% endif %}{# if rest_async_io_enabled #}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% 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 #}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also use the same format for these GA-TODOs in the other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed.

@@ -79,6 +87,9 @@ class {{ service.client_name }}Meta(type):
{% endif %}
{% if "rest" in opts.transport %}
_transport_registry["rest"] = {{ service.name }}RestTransport
{% if rest_async_io_enabled %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{# TODO(#2121): Remove this condition when async rest is GA #}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL. GitHub shortened and hyperlinked the full URL I intended here.

Comment on lines 1881 to 1882
{% macro transport_kind_test(service, transport_name) %}
{%- set named_clients = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% 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 = {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

noxfile.py Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
@contextmanager
def showcase_library(
session, templates="DEFAULT", other_opts: typing.Iterable[str] = (),
include_service_yaml=True,
retry_config=True,
rest_async_io_enabled=False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should also have a TODO to remove the param once async REST is GA?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed.

noxfile.py Show resolved Hide resolved
Comment on lines 1884 to 1891
{% 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)}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% 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) }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed.

Base automatically changed from async-rest-initial to main September 4, 2024 21:16
noxfile.py Outdated Show resolved Hide resolved
@@ -79,6 +87,9 @@ class {{ service.client_name }}Meta(type):
{% endif %}
{% if "rest" in opts.transport %}
_transport_registry["rest"] = {{ service.name }}RestTransport
{% if rest_async_io_enabled %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL. GitHub shortened and hyperlinked the full URL I intended here.

Copy link
Contributor

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! Looks great!

@ohmayr ohmayr merged commit 2809753 into main Sep 5, 2024
73 checks passed
@ohmayr ohmayr deleted the introduce-async-transport branch September 5, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants