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 mixin methods #2181

Merged

Conversation

ohmayr
Copy link
Contributor

@ohmayr ohmayr commented Sep 20, 2024

Fixes: #2148, #2156

@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Sep 20, 2024
@ohmayr ohmayr force-pushed the implement-async-rest-mixins-call-method branch 2 times, most recently from d2b45c9 to 831c55a Compare September 20, 2024 07:33
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Sep 20, 2024
@ohmayr ohmayr force-pushed the refactor-mixins-callables branch 2 times, most recently from abdba51 to f0ccd61 Compare September 23, 2024 19:54
Base automatically changed from refactor-mixins-callables to async-rest-support-in-gapics September 23, 2024 20:07
@ohmayr ohmayr force-pushed the implement-async-rest-mixins-call-method branch from 831c55a to 931feda Compare September 24, 2024 18:14
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Sep 24, 2024
@ohmayr ohmayr marked this pull request as ready for review September 24, 2024 18:19
@ohmayr ohmayr requested a review from a team as a code owner September 24, 2024 18:19
@ohmayr ohmayr force-pushed the implement-async-rest-mixins-call-method branch from 931feda to 4e52cd7 Compare September 24, 2024 18:40
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.

Looks good.

A non-trivial comment about the auth import. Some layout comments an nits. A question. And a suggestion for a follow-up.

@@ -265,6 +265,13 @@ def _prep_wrapped_messages(self, client_info):
client_info=client_info,
),
{% endfor %}{# service.methods.values() #}
{% for method_name in api.mixin_api_methods.keys() %}
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need transport_safe_name? Seems like it would be a good practice to use, like in the loop above. . Are the values of the api_methods dict Method objects, so we could do that? Otherwise, no worries. We deal with mixin methods individually, so we can know when a problem arises.

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'm not sure if transport_safe_name is available in api.mixin_api_methods.keys() . I've filed and linked an issue to follow up on this.

default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self.transport._wrapped_methods[self._client._transport.get_iam_policy]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have a call to wrapped_methods[get_iam_policy] both here in in _async_mixins.py.j2? I realize this was here before, but it's a genuine question. Does IAM have special treatment for historical reasons from before we used mixins?

Copy link
Contributor Author

@ohmayr ohmayr Sep 25, 2024

Choose a reason for hiding this comment

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

I updated all the instances just because it makes sense to use wraped_methods everywhere. However, the methods defined in async client aren't generated / used. There's a linked PR which mentions that those methods should be cleaned up. We can follow up on it. Thanks for filing the issue!

@@ -388,7 +388,7 @@ class {{ service.grpc_asyncio_transport_name }}({{ service.name }}Transport):
return self._stubs["test_iam_permissions"]
{% endif %}

{{ shared_macros.prep_wrapped_messages_async_method(service)|indent(4) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned in that higher up in this functions, we add set_iam_policy if opts.add_iam_methods. But the TODO above {% if opts.add_iam_methods %} makes it seem like that may not be used any more. WDYT?

Incidentally, I just filed #2196 to remove these TODOs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, the methods defined within async client aren't used. The ones defined in async mixins file are.

@@ -225,6 +225,9 @@ class Async{{service.name}}RestTransport(_Base{{ service.name }}RestTransport):
return self._{{method.name}}(self._session, self._host, self._interceptor) # type: ignore

{% endfor %}
{% for name, sig in api.mixin_api_signatures.items() %}
{{ shared_macros.generate_mixin_call_method(service, api, name, sig, is_async=True) | indent(4) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to block, but would be a good follow-up: this macro is defining the each _Mixin class next to the corresponding @property. The other _Method classes are defined all together, and then their @property all together. I think it would be good to define the _mixin classes right after the _Method classes, and the mixin @property right after the method @property. WDYT? Could you file an issue so we don't forget?

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've filed and linked an issue to follow up on this.

@ohmayr ohmayr merged commit ed04b26 into async-rest-support-in-gapics Sep 25, 2024
72 checks passed
@ohmayr ohmayr deleted the implement-async-rest-mixins-call-method branch September 25, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants