From 3bb2cc87befaec9962666ca00b7054066f58ab76 Mon Sep 17 00:00:00 2001 From: Josef Kudera <46950237+kudj@users.noreply.github.com> Date: Tue, 16 Sep 2025 11:59:17 +0200 Subject: [PATCH 1/3] add without_files parameter to client, allow saving memory by not importing libraries for all storage backends --- kbcstorage/client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kbcstorage/client.py b/kbcstorage/client.py index 0e848e8..5c1f673 100644 --- a/kbcstorage/client.py +++ b/kbcstorage/client.py @@ -5,7 +5,6 @@ from kbcstorage.buckets import Buckets from kbcstorage.components import Components from kbcstorage.configurations import Configurations -from kbcstorage.files import Files from kbcstorage.jobs import Jobs from kbcstorage.tables import Tables from kbcstorage.tokens import Tokens @@ -18,7 +17,7 @@ class Client: Storage API Client. """ - def __init__(self, api_domain, token, branch_id='default'): + def __init__(self, api_domain, token, branch_id='default', without_files=False): """ Initialise a client. @@ -27,13 +26,18 @@ def __init__(self, api_domain, token, branch_id='default'): "https://connection.keboola.com". token (str): A storage API key. branch_id (str): The ID of branch to use, use 'default' to work without branch (in main). + without_files (bool): If True, do not init the Files endpoint and saves memory by not importing libraries for all backends. """ self.root_url = api_domain.rstrip("/") self._token = token self._branch_id = branch_id self.buckets = Buckets(self.root_url, self.token) - self.files = Files(self.root_url, self.token) + + if not without_files: + from kbcstorage.files import Files + self.files = Files(self.root_url, self.token) + self.jobs = Jobs(self.root_url, self.token) self.tables = Tables(self.root_url, self.token) self.workspaces = Workspaces(self.root_url, self.token) From 8e193794a54ce4093f8e139a7fb8dece2ed44674 Mon Sep 17 00:00:00 2001 From: Josef Kudera <46950237+kudj@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:09:02 +0200 Subject: [PATCH 2/3] flake8 --- kbcstorage/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kbcstorage/client.py b/kbcstorage/client.py index 5c1f673..b1e179c 100644 --- a/kbcstorage/client.py +++ b/kbcstorage/client.py @@ -26,7 +26,7 @@ def __init__(self, api_domain, token, branch_id='default', without_files=False): "https://connection.keboola.com". token (str): A storage API key. branch_id (str): The ID of branch to use, use 'default' to work without branch (in main). - without_files (bool): If True, do not init the Files endpoint and saves memory by not importing libraries for all backends. + without_files (bool): If True saves memory by not importing files and libraries for all backends. """ self.root_url = api_domain.rstrip("/") self._token = token From 702f52341f476d6a4a454b408e3dc72631ded43a Mon Sep 17 00:00:00 2001 From: Josef Kudera <46950237+kudj@users.noreply.github.com> Date: Tue, 16 Sep 2025 15:28:17 +0200 Subject: [PATCH 3/3] changed variable to positive meaning, fix docstring --- kbcstorage/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kbcstorage/client.py b/kbcstorage/client.py index b1e179c..0b0a7a3 100644 --- a/kbcstorage/client.py +++ b/kbcstorage/client.py @@ -17,7 +17,7 @@ class Client: Storage API Client. """ - def __init__(self, api_domain, token, branch_id='default', without_files=False): + def __init__(self, api_domain, token, branch_id='default', file_storage_support=True): """ Initialise a client. @@ -26,7 +26,7 @@ def __init__(self, api_domain, token, branch_id='default', without_files=False): "https://connection.keboola.com". token (str): A storage API key. branch_id (str): The ID of branch to use, use 'default' to work without branch (in main). - without_files (bool): If True saves memory by not importing files and libraries for all backends. + file_storage_support (bool): If False, it saves memory by not importing libraries for all storage backends. """ self.root_url = api_domain.rstrip("/") self._token = token @@ -34,7 +34,7 @@ def __init__(self, api_domain, token, branch_id='default', without_files=False): self.buckets = Buckets(self.root_url, self.token) - if not without_files: + if file_storage_support: from kbcstorage.files import Files self.files = Files(self.root_url, self.token)