mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
refactor: extract credentials_path from USE_BIGQUERY environment variable
This commit is contained in:
parent
0e555699bd
commit
4ee9cee52a
1 changed files with 15 additions and 14 deletions
|
@ -220,9 +220,10 @@ def get_badges_md():
|
||||||
# Load environment variables from .env file
|
# Load environment variables from .env file
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
# Check if we should use BigQuery
|
# Check if we should use BigQuery and get credentials path
|
||||||
use_bigquery = os.environ.get("USE_BIGQUERY", "false").lower() in ("true", "1", "yes")
|
bigquery_env = os.environ.get("USE_BIGQUERY", "false")
|
||||||
credentials_path = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
|
use_bigquery = bigquery_env.lower() in ("true", "1", "yes") or os.path.exists(bigquery_env)
|
||||||
|
credentials_path = bigquery_env if os.path.exists(bigquery_env) else None
|
||||||
|
|
||||||
# Get API key from environment variable if not using BigQuery
|
# Get API key from environment variable if not using BigQuery
|
||||||
api_key = None
|
api_key = None
|
||||||
|
@ -258,9 +259,10 @@ def get_badges_html():
|
||||||
# Load environment variables from .env file
|
# Load environment variables from .env file
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
# Check if we should use BigQuery
|
# Check if we should use BigQuery and get credentials path
|
||||||
use_bigquery = os.environ.get("USE_BIGQUERY", "false").lower() in ("true", "1", "yes")
|
bigquery_env = os.environ.get("USE_BIGQUERY", "false")
|
||||||
credentials_path = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
|
use_bigquery = bigquery_env.lower() in ("true", "1", "yes") or os.path.exists(bigquery_env)
|
||||||
|
credentials_path = bigquery_env if os.path.exists(bigquery_env) else None
|
||||||
|
|
||||||
# Get API key from environment variable if not using BigQuery
|
# Get API key from environment variable if not using BigQuery
|
||||||
api_key = None
|
api_key = None
|
||||||
|
@ -356,13 +358,12 @@ def main():
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Determine whether to use BigQuery
|
# Determine whether to use BigQuery and get credentials path
|
||||||
use_bigquery = args.use_bigquery or os.environ.get("USE_BIGQUERY", "false").lower() in (
|
bigquery_env = os.environ.get("USE_BIGQUERY", "false")
|
||||||
"true",
|
use_bigquery = args.use_bigquery or bigquery_env.lower() in (
|
||||||
"1",
|
"true", "1", "yes"
|
||||||
"yes",
|
) or os.path.exists(bigquery_env)
|
||||||
)
|
credentials_path = args.credentials_path or (bigquery_env if os.path.exists(bigquery_env) else None)
|
||||||
credentials_path = args.credentials_path or os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")
|
|
||||||
|
|
||||||
# Check for required parameters
|
# Check for required parameters
|
||||||
api_key = None
|
api_key = None
|
||||||
|
@ -382,7 +383,7 @@ def main():
|
||||||
print(
|
print(
|
||||||
(
|
(
|
||||||
"BigQuery enabled but no credentials provided. Please set"
|
"BigQuery enabled but no credentials provided. Please set"
|
||||||
" GOOGLE_APPLICATION_CREDENTIALS environment variable or use --credentials-path"
|
" USE_BIGQUERY to path of credentials file or use --credentials-path"
|
||||||
),
|
),
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue