From 3c0ec88ce38d381ba8000943186a09af60a9d36e Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Tue, 19 Jul 2022 00:55:38 +0300 Subject: [PATCH] fs: gdrive: upgrade pydrive2 to 1.12.0 --- setup.cfg | 2 +- src/dvc_objects/fs/implementations/gdrive.py | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/setup.cfg b/setup.cfg index 3fb867c..7fd114a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,7 +55,7 @@ azure = adlfs>=2021.10.0 azure-identity>=1.4.0 knack -gdrive = pydrive2[fsspec]>=1.11.2 +gdrive = pydrive2[fsspec]>=1.12.0 gs = gcsfs>=2021.11.1 hdfs = # due to https://github.com/python-poetry/poetry/issues/4683, we have to diff --git a/src/dvc_objects/fs/implementations/gdrive.py b/src/dvc_objects/fs/implementations/gdrive.py index 2483cfa..dd925a8 100644 --- a/src/dvc_objects/fs/implementations/gdrive.py +++ b/src/dvc_objects/fs/implementations/gdrive.py @@ -158,8 +158,6 @@ def _validate_credentials(auth, settings): @wrap_prop(threading.RLock()) @cached_property def fs(self): - import json - from pydrive2.auth import GoogleAuth from pydrive2.fs import GDriveFileSystem as _GDriveFileSystem @@ -174,15 +172,10 @@ def fs(self): ], } - env_creds_json = os.getenv(self.GDRIVE_CREDENTIALS_DATA) - try: - env_creds_dict = json.loads(env_creds_json) - except ValueError as exc: - raise GDriveAuthError(self.GDRIVE_CREDENTIALS_DATA) from exc - - if env_creds_json: + env_creds = os.getenv(self.GDRIVE_CREDENTIALS_DATA) + if env_creds: auth_settings["save_credentials_backend"] = "dictionary" - auth_settings["save_credentials_dict"] = {"creds": env_creds_json} + auth_settings["save_credentials_dict"] = {"creds": env_creds} auth_settings["save_credentials_key"] = "creds" else: auth_settings["save_credentials_backend"] = "file" @@ -195,8 +188,8 @@ def fs(self): "client_user_email": self._service_account_user_email, } - if env_creds_dict: - service_config["client_creds_dict"] = env_creds_dict + if env_creds: + service_config["client_json"] = env_creds else: service_config[ "client_json_file_path"