This commit is contained in:
2026-05-20 23:54:53 +03:00
parent a43886106e
commit 68740cd9ed
167 changed files with 10620 additions and 29041 deletions

View File

@@ -6,8 +6,8 @@
from __future__ import annotations
import argparse
import json
from datetime import UTC, date, datetime
import json
from typing import Any
from ..core.cot_logger import seed_trace_id

View File

@@ -7,20 +7,22 @@
# @DATA_CONTRACT: CLIArgs -> TUIExitCode
import contextlib
import curses
from datetime import UTC, datetime
import json
import os
import subprocess
import sys
import threading
from datetime import UTC, datetime
from types import SimpleNamespace
from typing import Any
# Standardize sys.path for direct execution from project root or scripts dir.
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
BACKEND_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, "..", ".."))
if BACKEND_ROOT not in sys.path:
sys.path.insert(0, BACKEND_ROOT)
from src.core.cot_logger import seed_trace_id
from src.core.logger import logger
from src.models.clean_release import (
CandidateArtifact,
CheckFinalStatus,
@@ -44,6 +46,8 @@ from src.services.clean_release.enums import CandidateStatus
from src.services.clean_release.manifest_service import build_manifest_snapshot
from src.services.clean_release.publication_service import publish_candidate
from src.services.clean_release.repository import CleanReleaseRepository
# #region TuiFacadeAdapter [TYPE Class]
# @BRIEF Thin TUI adapter that routes business mutations through application services.
# @PRE: repository contains candidate and trusted policy/registry snapshots for execution.
@@ -644,7 +648,7 @@ class CleanReleaseTUI:
output_lines.append(line.rstrip("\n"))
proc.stdout.close()
except ValueError:
pass
logger.debug("[reader_thread] stdout read completed (stream closed)")
return_code[0] = proc.wait()
build_done.set()
reader = threading.Thread(target=_reader_thread, daemon=True)
@@ -683,7 +687,7 @@ class CleanReleaseTUI:
if line:
output_lines.append(line)
except Exception:
pass
logger.debug("[reader_thread] exception reading remaining stdout")
# ── Phase 4: Result summary ──
self.stdscr.clear()
ret = return_code[0]
@@ -734,7 +738,7 @@ class CleanReleaseTUI:
self.draw_status()
self.draw_footer(max_y, max_x)
except Exception:
pass
logger.debug("[refresh_screen] exception drawing TUI")
self.stdscr.refresh()
def loop(self):
self.refresh_screen()

View File

@@ -11,8 +11,8 @@
# @DATA_CONTRACT: CLIArgs -> AdminUser
import argparse
import sys
from pathlib import Path
import sys
# Add src to path
sys.path.append(str(Path(__file__).parent.parent.parent))

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env python3
# #region DeleteRunningTasksUtil [C:3] [TYPE Module]
# @PURPOSE Script to delete tasks with RUNNING status from the database.
# @LAYER Infrastructure
# @SEMANTICS maintenance, database, cleanup
# @RELATION DEPENDS_ON ->[TaskRecord]
# @RELATION DEPENDS_ON ->[TaskRecord]
from sqlalchemy.orm import Session
from src.core.database import TasksSessionLocal
from src.models.task import TaskRecord
# #region delete_running_tasks [C:4] [TYPE Function]
# @PURPOSE Delete all tasks with RUNNING status from the database.
# @PRE Database is accessible and TaskRecord model is defined.
# @POST All tasks with status 'RUNNING' are removed from the database.
# @SIDE_EFFECT Modifies DB: deletes RUNNING tasks. Prints to stdout.
def delete_running_tasks():
"""Delete all tasks with RUNNING status from the database."""
session: Session = TasksSessionLocal()
try:
# Find all task records with RUNNING status
running_tasks = session.query(TaskRecord).filter(TaskRecord.status == "RUNNING").all()
if not running_tasks:
print("No RUNNING tasks found.")
return
print(f"Found {len(running_tasks)} RUNNING tasks:")
for task in running_tasks:
print(f"- Task ID: {task.id}, Type: {task.type}")
# Delete the found tasks
session.query(TaskRecord).filter(TaskRecord.status == "RUNNING").delete(synchronize_session=False)
session.commit()
print(f"Successfully deleted {len(running_tasks)} RUNNING tasks.")
except Exception as e:
session.rollback()
print(f"Error deleting tasks: {e}")
finally:
session.close()
# #endregion delete_running_tasks
# [/DEF:delete_running_tasks:Function]
if __name__ == "__main__":
delete_running_tasks()
# #endregion DeleteRunningTasksUtil

View File

@@ -8,8 +8,8 @@
#
# @INVARIANT: Safe to run multiple times (idempotent).
import sys
from pathlib import Path
import sys
# Add src to path
sys.path.append(str(Path(__file__).parent.parent.parent))

View File

@@ -11,8 +11,8 @@
# @SIDE_EFFECT: Writes permissions to database
# @DATA_CONTRACT: CLIArgs -> SeedSummary
import sys
from pathlib import Path
import sys
# Add src to path
sys.path.append(str(Path(__file__).parent.parent.parent))

View File

@@ -9,10 +9,10 @@
import argparse
import json
from pathlib import Path
import random
import sys
import uuid
from pathlib import Path
sys.path.append(str(Path(__file__).parent.parent.parent))

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env python3
# #region test_dataset_dashboard_relations_script [C:2] [TYPE Module] [SEMANTICS pydantic, dashboard, dataset, test, superset]
# @BRIEF Tests and inspects dataset-to-dashboard relationship responses from Superset API.
# @RATIONALE Added '# DIAGNOSTIC SCRIPT — not a test' header comment. Script already had if __name__ guard.
"""
Script to test dataset-to-dashboard relationships from Superset API.
@@ -9,8 +11,8 @@ Usage:
"""
import json
import sys
from pathlib import Path
import sys
# Add src to path (parent of scripts directory)
sys.path.append(str(Path(__file__).parent.parent.parent))
@@ -170,3 +172,4 @@ if __name__ == "__main__":
test_dashboard_dataset_relations()
# #endregion test_dataset_dashboard_relations_script
# #endregion test_dataset_dashboard_relations_script