From ddd4b0cabbd74f5a9aeeb3dda9f6e6fb79ed8706 Mon Sep 17 00:00:00 2001 From: Duong Le Date: Fri, 3 May 2024 18:43:43 +0700 Subject: [PATCH] fix(bigquery-connection): Fix the chain authentication logic when we try to create bigquery client --- src/vanna/base/base.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/vanna/base/base.py b/src/vanna/base/base.py index 29c7e2dc..d1665d0a 100644 --- a/src/vanna/base/base.py +++ b/src/vanna/base/base.py @@ -1146,19 +1146,14 @@ def connect_to_bigquery(self, cred_file_path: str = None, project_id: str = None conn = None - try: - conn = bigquery.Client(project=project_id) - except: - print("Could not found any google cloud implicit credentials") - - if cred_file_path: + if not cred_file_path: + try: + conn = bigquery.Client(project=project_id) + except: + print("Could not found any google cloud implicit credentials") + else: # Validate file path and pemissions validate_config_path(cred_file_path) - else: - if not conn: - raise ValidationError( - "Pleae provide a service account credentials json file" - ) if not conn: with open(cred_file_path, "r") as f: