Chiusura fase di ristrutturazione e modularizzazione del workflow per favorire sviluppo modulare
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
import typer
|
||||
|
||||
from tht.adapters.factory import build_dwh
|
||||
from tht.cli.config_cmd import CONFIG_OPT
|
||||
from tht.config import ConfigError, load_config
|
||||
|
||||
@@ -16,7 +16,7 @@ def _extract_lsh_values(dwh, physical, annotations, limit):
|
||||
continue
|
||||
try:
|
||||
distinct = dwh.distinct_values(table_name, column_name, limit=limit)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 - an unreadable DWH column is non-fatal
|
||||
skipped.append(SkippedColumn(table_name, column_name, f"errore: {exc}"))
|
||||
continue
|
||||
vals = [str(value) for value in distinct.values if value not in (None, "")]
|
||||
|
||||
@@ -459,8 +459,8 @@ def solved_search_cmd(
|
||||
from rich.table import Table
|
||||
|
||||
from tht.cli.vector_cmd import make_embedder, open_searcher
|
||||
from tht.ports.vector import VectorReadUnavailable, VectorStoreError
|
||||
from tht.memory import search_solved_questions
|
||||
from tht.ports.vector import VectorReadUnavailable, VectorStoreError
|
||||
from tht.vectorstore.embeddings import EmbeddingsError
|
||||
|
||||
cfg = _load_config_or_exit(config)
|
||||
|
||||
@@ -12,8 +12,8 @@ import json
|
||||
import typer
|
||||
|
||||
from tht.phase import (
|
||||
auto_advance_eligible,
|
||||
advance_problems,
|
||||
auto_advance_eligible,
|
||||
current_phase,
|
||||
)
|
||||
from tht.workflow import load_workflow
|
||||
@@ -93,12 +93,11 @@ def advance_cmd(
|
||||
if cur > wf.max_phase:
|
||||
typer.secho("Sessione già alla fase terminale.", fg=typer.colors.YELLOW)
|
||||
raise typer.Exit(0)
|
||||
if auto:
|
||||
if not auto_advance_eligible(snapshot):
|
||||
problems = advance_problems(snapshot, cur)
|
||||
for p in problems:
|
||||
typer.echo(p)
|
||||
raise typer.Exit(6) # needs human confirmation (gate contract)
|
||||
if auto and not auto_advance_eligible(snapshot):
|
||||
problems = advance_problems(snapshot, cur)
|
||||
for p in problems:
|
||||
typer.echo(p)
|
||||
raise typer.Exit(6) # needs human confirmation (gate contract)
|
||||
session_repository(cfg).append_decisions(
|
||||
session, [{"type": "phase_approved", "subject": f"phase:{cur}"}]
|
||||
)
|
||||
@@ -164,7 +163,7 @@ def _cfg():
|
||||
ws = os.environ.get("THT_WORKSPACE") or os.environ.get("THT_CONFIG")
|
||||
config_path = Path(ws) if ws else Path("config/tht.yaml")
|
||||
try:
|
||||
from tht.cli.schema_cmd import _load_config_or_exit # noqa: F401 (portato in Onda 1.4)
|
||||
from tht.cli.schema_cmd import _load_config_or_exit
|
||||
|
||||
return _load_config_or_exit(config_path)
|
||||
except ImportError:
|
||||
|
||||
@@ -96,9 +96,9 @@ def run_from_config(config: Path, *, dry_run: bool = False, resume: str | None =
|
||||
from tht.adapters.factory import build_vector_store
|
||||
from tht.cli.schema_cmd import _load_config_or_exit
|
||||
from tht.cli.vector_cmd import make_embedder
|
||||
from tht.evidence import build_preprocessing_pipeline, build_sources
|
||||
from tht.evidence.corpus.chunk import ChunkPolicy
|
||||
from tht.evidence.corpus.store import CorpusStore
|
||||
from tht.evidence import build_preprocessing_pipeline, build_sources
|
||||
|
||||
cfg = _load_config_or_exit(config)
|
||||
if cfg.embeddings is None:
|
||||
@@ -130,9 +130,9 @@ def gc_from_config(config: Path, *, dry_run: bool = False):
|
||||
from tht.adapters.factory import build_vector_store
|
||||
from tht.cli.schema_cmd import _load_config_or_exit
|
||||
from tht.cli.vector_cmd import make_embedder
|
||||
from tht.evidence import build_preprocessing_pipeline, build_sources
|
||||
from tht.evidence.corpus.chunk import ChunkPolicy
|
||||
from tht.evidence.corpus.store import CorpusStore
|
||||
from tht.evidence import build_preprocessing_pipeline, build_sources
|
||||
|
||||
cfg = _load_config_or_exit(config)
|
||||
if cfg.embeddings is None:
|
||||
|
||||
@@ -303,7 +303,7 @@ def _suggest_fk_result(physical, annotations, *, sql_inputs: list[tuple[str, str
|
||||
@schema_app.command("check")
|
||||
def check_cmd(
|
||||
config: Path = CONFIG_OPT,
|
||||
annotations: Path | None = typer.Option(None, "--annotations"), # noqa: B008
|
||||
annotations: Path | None = typer.Option(None, "--annotations"),
|
||||
reviewed_candidates: str | None = typer.Option(None, "--reviewed-candidates"),
|
||||
json_output: bool = typer.Option(False, "--json"),
|
||||
) -> None:
|
||||
@@ -411,11 +411,11 @@ _GENERIC_PK_NAMES = {"id", "key", "code"}
|
||||
@schema_app.command("suggest-fks")
|
||||
def suggest_fks_cmd(
|
||||
config: Path = CONFIG_OPT,
|
||||
from_sql: list[Path] = typer.Option( # noqa: B008
|
||||
from_sql: list[Path] = typer.Option(
|
||||
None, "--from-sql",
|
||||
help="Directory o file .sql approvati da cui minare i join reali (ripetibile).",
|
||||
),
|
||||
assume: list[str] = typer.Option( # noqa: B008
|
||||
assume: list[str] = typer.Option(
|
||||
None, "--assume",
|
||||
help="Disambigua una PK con piu' proprietari: col=tabella_ref "
|
||||
"(es. cod_paz=dim_patient). Ripetibile.",
|
||||
@@ -548,10 +548,10 @@ def render_cmd(
|
||||
format: str = typer.Option(
|
||||
"markdown", "--format", "-f", help="Formato: markdown | mschema-text | schema-dict"
|
||||
),
|
||||
tables: list[str] = typer.Option( # noqa: B008
|
||||
tables: list[str] = typer.Option(
|
||||
None, "--table", "-t", help="Limita alle tabelle indicate (ripetibile)."
|
||||
),
|
||||
output: Path = typer.Option(None, "--output", "-o", help="File di output (default stdout)."), # noqa: B008
|
||||
output: Path = typer.Option(None, "--output", "-o", help="File di output (default stdout)."),
|
||||
) -> None:
|
||||
"""Serializza mschema (physical + annotations) nel formato richiesto."""
|
||||
import json
|
||||
|
||||
@@ -258,9 +258,9 @@ def pack_cmd(
|
||||
build_retrieval_entries,
|
||||
validate_corpus_workspace,
|
||||
)
|
||||
from tht.memory import SOLVED_KIND
|
||||
from tht.ports.vector import VectorReadUnavailable, VectorStoreError
|
||||
from tht.search import combined_search, schema_tables
|
||||
from tht.memory import SOLVED_KIND
|
||||
from tht.vectorstore.embeddings import EmbeddingsError
|
||||
|
||||
cfg = _load_config_or_exit(config)
|
||||
|
||||
@@ -515,12 +515,12 @@ def finalize_cmd(session_id: str = typer.Argument(...), config: Path = CONFIG_OP
|
||||
promoted_tables_for,
|
||||
)
|
||||
from tht.ctetest import CteError, CteTestRecord, _iter_json_objects
|
||||
from tht.evidence import project_session
|
||||
from tht.execute import ExecutionError
|
||||
from tht.execute.warnings import plan_warnings, runtime_warnings, static_warnings
|
||||
from tht.report import extract_reviewer_notes, render_validation_report
|
||||
from tht.evidence import project_session
|
||||
from tht.phase import cte_plan as effective_cte_plan
|
||||
from tht.phase import effective_decisions
|
||||
from tht.report import extract_reviewer_notes, render_validation_report
|
||||
from tht.session.models import SchemaLinking
|
||||
from tht.sqlcheck import validate_sql
|
||||
|
||||
@@ -656,7 +656,7 @@ def finalize_cmd(session_id: str = typer.Argument(...), config: Path = CONFIG_OP
|
||||
"Coppia domanda->SQL gia' aggiornata nel vectordb (nessun upsert).",
|
||||
fg=typer.colors.CYAN,
|
||||
)
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 - solved-question indexing is explicitly best effort
|
||||
typer.secho(
|
||||
f"ATTENZIONE: coppia domanda->SQL non indicizzata ({e}). "
|
||||
f"Recupera con `tht memory solved-index {session_id}`.",
|
||||
|
||||
Reference in New Issue
Block a user