Skip to content

Commit f51565c

Browse files
[executors] fix: make import of sql and bq executors optional
1 parent fad838c commit f51565c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

libs/executors/garf_executors/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 Google LLC
1+
# Copyright 2025 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -15,15 +15,21 @@
1515

1616
from __future__ import annotations
1717

18-
from garf_executors import bq_executor, fetchers, sql_executor
18+
import importlib
19+
20+
from garf_executors import executor, fetchers
1921
from garf_executors.api_executor import ApiExecutionContext, ApiQueryExecutor
2022

2123

22-
def setup_executor(source: str, fetcher_parameters: dict[str, str]):
24+
def setup_executor(
25+
source: str, fetcher_parameters: dict[str, str]
26+
) -> type[executor.Executor]:
2327
"""Initializes executors based on a source and parameters."""
2428
if source == 'bq':
29+
bq_executor = importlib.import_module('garf_executors.bq_executor')
2530
query_executor = bq_executor.BigQueryExecutor(**fetcher_parameters)
2631
elif source == 'sqldb':
32+
sql_executor = importlib.import_module('garf_executors.sql_executor')
2733
query_executor = (
2834
sql_executor.SqlAlchemyQueryExecutor.from_connection_string(
2935
fetcher_parameters.get('connection_string')
@@ -42,4 +48,4 @@ def setup_executor(source: str, fetcher_parameters: dict[str, str]):
4248
'ApiExecutionContext',
4349
]
4450

45-
__version__ = '0.0.8'
51+
__version__ = '0.0.9'

0 commit comments

Comments
 (0)