semantics: complete DEF-to-region migration, fix regressions
- Convert legacy [DEF🆔Type] anchors to #region/#endregion across 329 files
- Reinstate _normalize_timestamp_value in sql_generator.py
- Fix MarkerLogger→logger migration in events.py (molecular CoT markers)
- Fix dataset_review orchestrator dependencies (_build_execution_snapshot)
- Fix config_manager stale-record deletion (moved to save path only)
- Add 77 missing [/DEF:] closers in 5 unbalanced test files
- Update assistant_chat.integration.test.js for #region format
- Apply molecular-cot-logging markers (REASON/REFLECT/EXPLORE) via logger.* methods
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
# #region DatasetsApi [C:3] [TYPE Module] [SEMANTICS api, datasets, resources, hub]
|
||||
#
|
||||
# @BRIEF API endpoints for the Dataset Hub - listing datasets with mapping progress
|
||||
# @LAYER API
|
||||
# @INVARIANT All dataset responses include last_task metadata
|
||||
# @LAYER: API
|
||||
# @RELATION DEPENDS_ON -> [AppDependencies]
|
||||
# @RELATION DEPENDS_ON -> [ResourceService]
|
||||
# @RELATION DEPENDS_ON -> [SupersetClient]
|
||||
#
|
||||
#
|
||||
# @INVARIANT: All dataset responses include last_task metadata
|
||||
|
||||
# [SECTION: IMPORTS]
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel, Field
|
||||
from ...dependencies import get_config_manager, get_task_manager, get_resource_service, has_permission
|
||||
from ...core.logger import logger, belief_scope
|
||||
from ...core.superset_client import SupersetClient
|
||||
# [/SECTION]
|
||||
|
||||
router = APIRouter(prefix="/api/datasets", tags=["Datasets"])
|
||||
|
||||
@@ -105,12 +103,9 @@ class TaskResponse(BaseModel):
|
||||
|
||||
# #region get_dataset_ids [C:3] [TYPE Function]
|
||||
# @BRIEF Fetch list of all dataset IDs from a specific environment (without pagination)
|
||||
# @PRE env_id must be a valid environment ID
|
||||
# @POST Returns a list of all dataset IDs
|
||||
# @PARAM: env_id (str) - The environment ID to fetch datasets from
|
||||
# @PARAM: search (Optional[str]) - Filter by table name
|
||||
# @RETURN: List[int] - List of dataset IDs
|
||||
# @RELATION: CALLS ->[get_datasets_with_status]
|
||||
# @PRE: env_id must be a valid environment ID
|
||||
# @POST: Returns a list of all dataset IDs
|
||||
# @RELATION CALLS -> [get_datasets_with_status]
|
||||
@router.get("/ids")
|
||||
async def get_dataset_ids(
|
||||
env_id: str,
|
||||
@@ -156,17 +151,12 @@ async def get_dataset_ids(
|
||||
|
||||
# #region get_datasets [C:3] [TYPE Function]
|
||||
# @BRIEF Fetch list of datasets from a specific environment with mapping progress
|
||||
# @PRE env_id must be a valid environment ID
|
||||
# @PRE page must be >= 1 if provided
|
||||
# @PRE page_size must be between 1 and 100 if provided
|
||||
# @POST Returns a list of datasets with enhanced metadata and pagination info
|
||||
# @POST Response includes pagination metadata (page, page_size, total, total_pages)
|
||||
# @PARAM: env_id (str) - The environment ID to fetch datasets from
|
||||
# @PARAM: search (Optional[str]) - Filter by table name
|
||||
# @PARAM: page (Optional[int]) - Page number (default: 1)
|
||||
# @PARAM: page_size (Optional[int]) - Items per page (default: 10, max: 100)
|
||||
# @RETURN: DatasetsResponse - List of datasets with status metadata
|
||||
# @RELATION: CALLS ->[get_datasets_with_status]
|
||||
# @PRE: env_id must be a valid environment ID
|
||||
# @PRE: page must be >= 1 if provided
|
||||
# @PRE: page_size must be between 1 and 100 if provided
|
||||
# @POST: Returns a list of datasets with enhanced metadata and pagination info
|
||||
# @POST: Response includes pagination metadata (page, page_size, total, total_pages)
|
||||
# @RELATION CALLS -> [get_datasets_with_status]
|
||||
@router.get("", response_model=DatasetsResponse)
|
||||
async def get_datasets(
|
||||
env_id: str,
|
||||
@@ -245,15 +235,13 @@ class MapColumnsRequest(BaseModel):
|
||||
|
||||
# #region map_columns [C:3] [TYPE Function]
|
||||
# @BRIEF Trigger bulk column mapping for datasets
|
||||
# @PRE User has permission plugin:mapper:execute
|
||||
# @PRE env_id is a valid environment ID
|
||||
# @PRE dataset_ids is a non-empty list
|
||||
# @POST Returns task_id for tracking mapping progress
|
||||
# @POST Task is created and queued for execution
|
||||
# @PARAM: request (MapColumnsRequest) - Mapping request with environment and dataset IDs
|
||||
# @RETURN: TaskResponse - Task ID for tracking
|
||||
# @RELATION: DISPATCHES ->[MapperPlugin]
|
||||
# @RELATION: CALLS ->[create_task]
|
||||
# @PRE: User has permission plugin:mapper:execute
|
||||
# @PRE: env_id is a valid environment ID
|
||||
# @PRE: dataset_ids is a non-empty list
|
||||
# @POST: Returns task_id for tracking mapping progress
|
||||
# @POST: Task is created and queued for execution
|
||||
# @RELATION DISPATCHES -> [MapperPlugin]
|
||||
# @RELATION CALLS -> [create_task]
|
||||
@router.post("/map-columns", response_model=TaskResponse)
|
||||
async def map_columns(
|
||||
request: MapColumnsRequest,
|
||||
@@ -315,15 +303,13 @@ class GenerateDocsRequest(BaseModel):
|
||||
|
||||
# #region generate_docs [C:3] [TYPE Function]
|
||||
# @BRIEF Trigger bulk documentation generation for datasets
|
||||
# @PRE User has permission plugin:llm_analysis:execute
|
||||
# @PRE env_id is a valid environment ID
|
||||
# @PRE dataset_ids is a non-empty list
|
||||
# @POST Returns task_id for tracking documentation generation progress
|
||||
# @POST Task is created and queued for execution
|
||||
# @PARAM: request (GenerateDocsRequest) - Documentation generation request
|
||||
# @RETURN: TaskResponse - Task ID for tracking
|
||||
# @RELATION: DISPATCHES ->[DocumentationPlugin]
|
||||
# @RELATION: CALLS ->[create_task]
|
||||
# @PRE: User has permission plugin:llm_analysis:execute
|
||||
# @PRE: env_id is a valid environment ID
|
||||
# @PRE: dataset_ids is a non-empty list
|
||||
# @POST: Returns task_id for tracking documentation generation progress
|
||||
# @POST: Task is created and queued for execution
|
||||
# @RELATION DISPATCHES -> [DocumentationPlugin]
|
||||
# @RELATION CALLS -> [create_task]
|
||||
@router.post("/generate-docs", response_model=TaskResponse)
|
||||
async def generate_docs(
|
||||
request: GenerateDocsRequest,
|
||||
@@ -370,13 +356,10 @@ async def generate_docs(
|
||||
|
||||
# #region get_dataset_detail [C:3] [TYPE Function]
|
||||
# @BRIEF Get detailed dataset information including columns and linked dashboards
|
||||
# @PRE env_id is a valid environment ID
|
||||
# @PRE dataset_id is a valid dataset ID
|
||||
# @POST Returns detailed dataset info with columns and linked dashboards
|
||||
# @PARAM: env_id (str) - The environment ID
|
||||
# @PARAM: dataset_id (int) - The dataset ID
|
||||
# @RETURN: DatasetDetailResponse - Detailed dataset information
|
||||
# @RELATION: CALLS ->[SupersetClientGetDatasetDetail]
|
||||
# @PRE: env_id is a valid environment ID
|
||||
# @PRE: dataset_id is a valid dataset ID
|
||||
# @POST: Returns detailed dataset info with columns and linked dashboards
|
||||
# @RELATION CALLS -> [SupersetClientGetDatasetDetail]
|
||||
@router.get("/{dataset_id}", response_model=DatasetDetailResponse)
|
||||
async def get_dataset_detail(
|
||||
env_id: str,
|
||||
|
||||
Reference in New Issue
Block a user