From e746b3e5351290d8e190543655ed419fc930b32f Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 5 Nov 2023 21:01:56 +0200 Subject: [PATCH] Support GS credentials as JSON string if not a JSON file reference --- clearml/storage/helper.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/clearml/storage/helper.py b/clearml/storage/helper.py index 1d62cc68..8fca9c85 100644 --- a/clearml/storage/helper.py +++ b/clearml/storage/helper.py @@ -791,10 +791,21 @@ class _GoogleCloudStorageDriver(_Driver): self.name = name[len(_GoogleCloudStorageDriver.scheme_prefix):] if cfg.credentials_json: + # noinspection PyBroadException try: credentials = service_account.Credentials.from_service_account_file(cfg.credentials_json) - except ValueError: + except Exception: credentials = None + + if not credentials: + # noinspection PyBroadException + try: + # Try parsing this as json to support actual json content and not a file path + credentials = service_account.Credentials.from_service_account_info( + json.loads(cfg.credentials_json) + ) + except Exception: + pass else: credentials = None