diff --git a/pyproject.toml b/pyproject.toml index 168ee29a..541a80f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "supabase" -version = "1.0.1" +version = "1.0.2" description = "Supabase client for Python." authors = ["Joel Lee ", "Leon Fedden ", "Daniel Reinón García ", "Leynier Gutiérrez González ", "Anand"] homepage = "https://github.com/supabase-community/supabase-py" diff --git a/supabase/__version__.py b/supabase/__version__.py index 5c4105cd..7863915f 100644 --- a/supabase/__version__.py +++ b/supabase/__version__.py @@ -1 +1 @@ -__version__ = "1.0.1" +__version__ = "1.0.2" diff --git a/supabase/client.py b/supabase/client.py index 5980e291..8e14e468 100644 --- a/supabase/client.py +++ b/supabase/client.py @@ -4,6 +4,7 @@ from httpx import Timeout from postgrest import SyncFilterRequestBuilder, SyncPostgrestClient, SyncRequestBuilder from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT +from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT from supafunc import FunctionsClient from .lib.auth_client import SupabaseAuthClient @@ -89,16 +90,15 @@ def __init__( supabase_key=self.supabase_key, headers=options.headers, schema=options.schema, - timeout=options.timeout, + timeout=options.postgrest_client_timeout, + ) + self.storage = self._init_storage_client( + self.storage_url, self._get_auth_headers(), options.storage_client_timeout ) def functions(self) -> FunctionsClient: return FunctionsClient(self.functions_url, self._get_auth_headers()) - def storage(self) -> SupabaseStorageClient: - """Create instance of the storage client""" - return SupabaseStorageClient(self.storage_url, self._get_auth_headers()) - def table(self, table_name: str) -> SyncRequestBuilder: """Perform a table operation. @@ -168,6 +168,13 @@ def rpc(self, fn: str, params: Dict[Any, Any]) -> SyncFilterRequestBuilder: # return SupabaseRealtimeClient( # realtime_url, {"params": {"apikey": supabase_key}} # ) + @staticmethod + def _init_storage_client( + storage_url: str, + headers: Dict[str, str], + storage_client_timeout: int = DEFAULT_STORAGE_CLIENT_TIMEOUT, + ) -> SupabaseStorageClient: + return SupabaseStorageClient(storage_url, headers, storage_client_timeout) @staticmethod def _init_supabase_auth_client( diff --git a/supabase/lib/client_options.py b/supabase/lib/client_options.py index f6a158eb..91afe1b5 100644 --- a/supabase/lib/client_options.py +++ b/supabase/lib/client_options.py @@ -4,6 +4,7 @@ from gotrue import SyncMemoryStorage, SyncSupportedStorage from httpx import Timeout from postgrest.constants import DEFAULT_POSTGREST_CLIENT_TIMEOUT +from storage3.constants import DEFAULT_TIMEOUT as DEFAULT_STORAGE_CLIENT_TIMEOUT from supabase import __version__ @@ -36,9 +37,14 @@ class ClientOptions: fetch: Optional[Callable] = None """A custom `fetch` implementation.""" - timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT + postgrest_client_timeout: Union[ + int, float, Timeout + ] = DEFAULT_POSTGREST_CLIENT_TIMEOUT """Timeout passed to the SyncPostgrestClient instance.""" + storage_client_timeout: Union[int, float, Timeout] = DEFAULT_STORAGE_CLIENT_TIMEOUT + """Timeout passed to the SyncStorageClient instance""" + def replace( self, schema: Optional[str] = None, @@ -48,7 +54,12 @@ def replace( storage: Optional[SyncSupportedStorage] = None, realtime: Optional[Dict[str, Any]] = None, fetch: Optional[Callable] = None, - timeout: Union[int, float, Timeout] = DEFAULT_POSTGREST_CLIENT_TIMEOUT, + postgrest_client_timeout: Union[ + int, float, Timeout + ] = DEFAULT_POSTGREST_CLIENT_TIMEOUT, + storage_client_timeout: Union[ + int, float, Timeout + ] = DEFAULT_STORAGE_CLIENT_TIMEOUT, ) -> "ClientOptions": """Create a new SupabaseClientOptions with changes""" client_options = ClientOptions() @@ -61,5 +72,10 @@ def replace( client_options.storage = storage or self.storage client_options.realtime = realtime or self.realtime client_options.fetch = fetch or self.fetch - client_options.timeout = timeout or self.timeout + client_options.postgrest_client_timeout = ( + postgrest_client_timeout or self.postgrest_client_timeout + ) + client_options.storage_client_timeout = ( + storage_client_timeout or self.storage_client_timeout + ) return client_options