python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Users want to have control over the request timeout

Open rhamzeh opened this issue 1 year ago • 1 comments

Checklist

  • [X] I have looked into the README and have not found a suitable solution or answer.
  • [X] I have looked into the documentation and have not found a suitable solution or answer.
  • [X] I have searched the issues and have not found a suitable solution or answer.
  • [X] I have upgraded to the latest version of OpenFGA and the issue still persists.
  • [X] I have searched the Slack community and have not found a suitable solution or answer.
  • [X] I agree to the terms within the OpenFGA Code of Conduct.

Description

OpenFgaApi methods support passing in a _request_timeout: https://github.com/openfga/python-sdk/blob/e82545e8ae2bdd4064ce846d8eb4a11c95359e85/openfga_sdk/sync/open_fga_api.py#L64-L67

However the options_to_kwargs https://github.com/openfga/python-sdk/blob/e82545e8ae2bdd4064ce846d8eb4a11c95359e85/openfga_sdk/sync/client/client.py#L92-L106 does not pass in that option down from the OpenFgaClient methods to the OpenFgaApi methods

Expectation

A user should be able to set the request timeout on a method.

Note that instead of just allowing passing in _request_timeout per method, this should be done like in the Java SDK.

Users should be able to configure a default timeout in the Configuration/ClientConfiguration, and override it per method.

Example in Java: https://github.com/openfga/java-sdk/blob/b1e03e523c530824f5921313c2191dc5f6d93af8/src/main/java/dev/openfga/sdk/api/configuration/BaseConfiguration.java#L22-L24

Reproduction

.

OpenFGA SDK version

v0.6.1

OpenFGA version

N/A

SDK Configuration

N/A

Logs

No response

References

https://cloud-native.slack.com/archives/C06G1NNH47N/p1723022081318009

rhamzeh avatar Aug 07 '24 11:08 rhamzeh

~~I'd like to pick this up 😀~~ Nevermind I see there is a PR for this already 👍

GMorris-professional avatar Sep 19 '24 08:09 GMorris-professional

@Oscmage you have a draft PR for this - are you still working on it?

If not, would you mind if @ryanpq steps in to help take it to completion?

rhamzeh avatar Oct 28 '24 15:10 rhamzeh

Please be my guest!

Oscmage avatar Oct 29 '24 07:10 Oscmage

I've revised the updates in the PR to use milliseconds as advised for consistency across sdks while still passing second values to requests and urllib3 as they require.

ryanpq avatar Nov 01 '24 17:11 ryanpq

@ryanpq Thanks a lot for taking this all the way.

Oscmage avatar Nov 04 '24 14:11 Oscmage

👋 Is there an update on the fix for this issue? We have encountered multiple scenarios where we need to define a shorter timeout on the request.

jasehackman avatar Nov 25 '24 15:11 jasehackman

Hey @jasehackman! We just merged a PR with the fix. It should make it's way to be released sometime this week

rhamzeh avatar Nov 25 '24 16:11 rhamzeh

This is now out in v0.8.1 https://github.com/openfga/python-sdk/releases/tag/v0.8.1

rhamzeh avatar Nov 30 '24 22:11 rhamzeh