gapic-generator-python icon indicating copy to clipboard operation
gapic-generator-python copied to clipboard

Missing default deadlines in generated stubs

Open igorbernstein2 opened this issue 3 years ago • 1 comments
trafficstars

Code example

from google.cloud.bigtable_admin_v2 import BigtableTableAdminClient
from google.cloud.bigtable_admin_v2.types import ModifyColumnFamiliesRequest, ColumnFamily,GcRule

c = BigtableTableAdminClient()
c.modify_column_families(
    ModifyColumnFamiliesRequest(
        name="projects/my-project/instances/my-instance/tables/my-table",
        modifications=[
            ModifyColumnFamiliesRequest.Modification(
                id="family",
                create=ColumnFamily(
                    gc_rule=GcRule(
                        max_num_versions=1
                    )
                )
            )
        ]
    )
)

This should send the RPC using the default deadline configured here in service json file, which generates the defaults base.py: https://github.com/googleapis/python-bigtable/blob/0841824c7b9539df2530370ea128c140eda0f2b2/google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/base.py#L199-L203

However this deadline is not respected. I believe the problem comes from the generator using None as the default in the stub:

https://github.com/googleapis/python-bigtable/blob/0841824c7b9539df2530370ea128c140eda0f2b2/google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py#L1229

Which will end up being pushed down into determine_timeout: https://github.com/googleapis/python-api-core/blob/ddcc2499fa756f98268eb552edba6f25ddbe0c26/google/api_core/gapic_v1/method.py#L63-L101

Which seems to treat None to mean no deadline and wants Method.DEFAULT to mean the default deadline

Specifically this:

   if specified_timeout is DEFAULT:
        specified_timeout = default_timeout

This effectively means that gapic generated clients will never send a default deadline

igorbernstein2 avatar Oct 20 '22 15:10 igorbernstein2

Hi Igor, The retry, polling and timeotus are in a bad shape in python libraries and we are actively working on cleaning all that up. The default timeout=None is a known issue and is going to be addressed soon in gapic-genertor-python PR, which first needs this big PR be submitted: https://github.com/googleapis/python-api-core/pull/462.

I.e. the issue is much more fundamental bug we are right in the process of fixing it (and also the terminology used is broken)

vam-google avatar Oct 20 '22 18:10 vam-google