032: fix missing awaits in translate datasource endpoints (#5,6,7)

Three sync functions called async SupersetClient methods without await:
  - get_datasource_columns(): get_dataset_detail + get_database (async)
  - fetch_available_datasources(): get_datasets (async)
  - Route handlers: both calls missing await

Converted to async functions + added awaits. Both endpoints now return
proper data instead of coroutine errors.
This commit is contained in:
2026-06-04 23:57:46 +03:00
parent fe2602dc89
commit f6dc7c47e7
3 changed files with 7 additions and 7 deletions

View File

@@ -211,7 +211,7 @@ async def list_datasources(
with belief_scope("list_datasources"):
try:
service = TranslateJobService(db, config_manager)
datasets = service.fetch_available_datasources(env_id, search)
datasets = await service.fetch_available_datasources(env_id, search)
return datasets
except Exception as e:
logger.explore("list_datasources failed", extra={"src": "translate_routes", "error": str(e)})
@@ -231,7 +231,7 @@ async def get_datasource_columns(
extra={"src": "translate_routes"}
)
try:
result = fetch_datasource_columns_service(
result = await fetch_datasource_columns_service(
datasource_id=datasource_id,
env_id=env_id,
config_manager=config_manager,

View File

@@ -234,13 +234,13 @@ class TranslateJobService:
# region fetch_available_datasources [TYPE Function]
# @PURPOSE: List available Superset datasets for translation job creation.
def fetch_available_datasources(self, env_id: str, search: str | None = None) -> list:
async def fetch_available_datasources(self, env_id: str, search: str | None = None) -> list:
from ...core.superset_client import SupersetClient
env = self.config_manager.get_environment(env_id)
if not env:
raise ValueError(f"Environment '{env_id}' not found")
client = SupersetClient(env)
_, datasets = client.get_datasets()
_, datasets = await client.get_datasets()
result = []
for ds in datasets:
name = ds.get("table_name", "")

View File

@@ -114,7 +114,7 @@ def detect_virtual_columns(columns: list[dict[str, Any]]) -> list[str]:
# #region get_datasource_columns [C:3] [TYPE Function]
# @BRIEF Fetch datasource column metadata from Superset and return structured response.
def get_datasource_columns(
async def get_datasource_columns(
datasource_id: int,
env_id: str,
config_manager: ConfigManager,
@@ -128,7 +128,7 @@ def get_datasource_columns(
raise ValueError(f"Superset environment '{env_id}' not found")
client = SupersetClient(env_config)
dataset_detail = client.get_dataset_detail(datasource_id)
dataset_detail = await client.get_dataset_detail(datasource_id)
database_info = dataset_detail.get("database", {})
dialect = None
@@ -140,7 +140,7 @@ def get_datasource_columns(
if dialect is None:
database_id = dataset_detail.get("database_id")
if database_id:
db_record = client.get_database(int(database_id))
db_record = await client.get_database(int(database_id))
db_result = db_record.get("result", db_record) if isinstance(db_record, dict) else db_record
dialect = get_dialect_from_database(db_result)
else: