workflows update
This commit is contained in:
183429
backend/logs/app.log.1
183429
backend/logs/app.log.1
File diff suppressed because it is too large
Load Diff
@@ -57,7 +57,10 @@ class GitStatus(BaseModel):
|
||||
# [DEF:LastTask:DataClass]
|
||||
class LastTask(BaseModel):
|
||||
task_id: Optional[str] = None
|
||||
status: Optional[str] = Field(None, pattern="^RUNNING|SUCCESS|ERROR|WAITING_INPUT$")
|
||||
status: Optional[str] = Field(
|
||||
None,
|
||||
pattern="^PENDING|RUNNING|SUCCESS|FAILED|ERROR|AWAITING_INPUT|WAITING_INPUT|AWAITING_MAPPING$",
|
||||
)
|
||||
# [/DEF:LastTask:DataClass]
|
||||
|
||||
# [DEF:DashboardItem:DataClass]
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
# [SECTION: IMPORTS]
|
||||
from typing import List, Dict, Optional, Any
|
||||
from datetime import datetime
|
||||
from ..core.superset_client import SupersetClient
|
||||
from ..core.task_manager.models import Task
|
||||
from ..services.git_service import GitService
|
||||
@@ -39,7 +40,7 @@ class ResourceService:
|
||||
# @RETURN: List[Dict] - Dashboards with git_status and last_task fields
|
||||
# @RELATION: CALLS -> SupersetClient.get_dashboards_summary
|
||||
# @RELATION: CALLS -> self._get_git_status_for_dashboard
|
||||
# @RELATION: CALLS -> self._get_last_task_for_resource
|
||||
# @RELATION: CALLS -> self._get_last_llm_task_for_dashboard
|
||||
async def get_dashboards_with_status(
|
||||
self,
|
||||
env: Any,
|
||||
@@ -60,10 +61,11 @@ class ResourceService:
|
||||
git_status = self._get_git_status_for_dashboard(dashboard_id)
|
||||
dashboard_dict['git_status'] = git_status
|
||||
|
||||
# Get last task status
|
||||
last_task = self._get_last_task_for_resource(
|
||||
f"dashboard-{dashboard_id}",
|
||||
tasks
|
||||
# Show status of the latest LLM validation for this dashboard.
|
||||
last_task = self._get_last_llm_task_for_dashboard(
|
||||
dashboard_id,
|
||||
env.id,
|
||||
tasks,
|
||||
)
|
||||
dashboard_dict['last_task'] = last_task
|
||||
|
||||
@@ -72,6 +74,59 @@ class ResourceService:
|
||||
logger.info(f"[ResourceService][Coherence:OK] Fetched {len(result)} dashboards with status")
|
||||
return result
|
||||
# [/DEF:get_dashboards_with_status:Function]
|
||||
|
||||
# [DEF:_get_last_llm_task_for_dashboard:Function]
|
||||
# @PURPOSE: Get most recent LLM validation task for a dashboard in an environment
|
||||
# @PRE: dashboard_id is a valid integer identifier
|
||||
# @POST: Returns the newest llm_dashboard_validation task summary or None
|
||||
# @PARAM: dashboard_id (int) - The dashboard ID
|
||||
# @PARAM: env_id (Optional[str]) - Environment ID to match task params
|
||||
# @PARAM: tasks (Optional[List[Task]]) - List of tasks to search
|
||||
# @RETURN: Optional[Dict] - Task summary with task_id and status
|
||||
def _get_last_llm_task_for_dashboard(
|
||||
self,
|
||||
dashboard_id: int,
|
||||
env_id: Optional[str],
|
||||
tasks: Optional[List[Task]] = None,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
if not tasks:
|
||||
return None
|
||||
|
||||
dashboard_id_str = str(dashboard_id)
|
||||
matched_tasks = []
|
||||
|
||||
for task in tasks:
|
||||
if getattr(task, "plugin_id", None) != "llm_dashboard_validation":
|
||||
continue
|
||||
|
||||
params = getattr(task, "params", {}) or {}
|
||||
if str(params.get("dashboard_id")) != dashboard_id_str:
|
||||
continue
|
||||
|
||||
if env_id is not None:
|
||||
task_env = params.get("environment_id") or params.get("env")
|
||||
if str(task_env) != str(env_id):
|
||||
continue
|
||||
|
||||
matched_tasks.append(task)
|
||||
|
||||
if not matched_tasks:
|
||||
return None
|
||||
|
||||
def _task_time(task_obj: Any) -> datetime:
|
||||
return (
|
||||
getattr(task_obj, "started_at", None)
|
||||
or getattr(task_obj, "finished_at", None)
|
||||
or getattr(task_obj, "created_at", None)
|
||||
or datetime.min
|
||||
)
|
||||
|
||||
last_task = max(matched_tasks, key=_task_time)
|
||||
return {
|
||||
"task_id": str(getattr(last_task, "id", "")),
|
||||
"status": str(getattr(last_task, "status", "")),
|
||||
}
|
||||
# [/DEF:_get_last_llm_task_for_dashboard:Function]
|
||||
|
||||
# [DEF:get_datasets_with_status:Function]
|
||||
# @PURPOSE: Fetch datasets from environment with mapping progress and last task status
|
||||
|
||||
Reference in New Issue
Block a user