增强validator和打印区别
This commit is contained in:
@@ -28,6 +28,44 @@ async def print_pipeline_summary(*, logger, node_types, binding_manager, local_d
|
||||
return text[:width]
|
||||
return text[: width - 1] + "…"
|
||||
|
||||
def print_consistency_summary() -> None:
|
||||
line_width = 96
|
||||
|
||||
def _format_sample(sample: dict) -> str:
|
||||
local_text = _clip(repr(sample.get("local")), 72)
|
||||
remote_text = _clip(repr(sample.get("remote")), 72)
|
||||
return f"{local_text}/{remote_text}"
|
||||
|
||||
logger.info(f"\n{'=' * line_width}")
|
||||
logger.info("🔎 Consistency Summary")
|
||||
logger.info(f"{'=' * line_width}")
|
||||
|
||||
for node_type in node_types:
|
||||
item = consistency_by_type.get(node_type, {}) or {}
|
||||
checked_pairs = int(item.get("checked_pairs", 0))
|
||||
mismatch_count = int(item.get("mismatch_count", 0))
|
||||
logger.info(f"{node_type} (checked_pairs={checked_pairs}, mismatches={mismatch_count})")
|
||||
|
||||
fields = item.get("fields", []) or []
|
||||
differing_fields = [field for field in fields if int(field.get("mismatch_count", 0)) > 0]
|
||||
if not differing_fields:
|
||||
logger.info(" pass")
|
||||
continue
|
||||
|
||||
logger.info(" field mismatch/total diff_schemas samples")
|
||||
logger.info(" ------------------------------------------------------------------------------")
|
||||
for field_report in differing_fields:
|
||||
field_name = str(field_report.get("field_name", ""))
|
||||
field_mismatch = int(field_report.get("mismatch_count", 0))
|
||||
field_total = int(field_report.get("total_count", 0))
|
||||
schema_refs = ",".join(str(item) for item in (field_report.get("schema_refs", []) or [])) or "-"
|
||||
samples = field_report.get("samples", []) or []
|
||||
sample_text = _format_sample(samples[0]) if samples else "-"
|
||||
logger.info(
|
||||
f" {_clip(field_name, 30):<30} {field_mismatch:>4}/{field_total:<4} "
|
||||
f"{_clip(schema_refs, 28):<28} {sample_text}"
|
||||
)
|
||||
|
||||
def print_collection_summary(title: str, datasource, collection) -> None:
|
||||
action_summary = datasource.get_action_summary()
|
||||
line_width = 133
|
||||
@@ -110,20 +148,17 @@ async def print_pipeline_summary(*, logger, node_types, binding_manager, local_d
|
||||
f"{_clip(total_consistency_sft, consistency_w):<{consistency_w}}"
|
||||
)
|
||||
|
||||
print_collection_summary("Local", local_datasource, local_collection)
|
||||
print_collection_summary("Remote", remote_datasource, remote_collection)
|
||||
|
||||
loaded = int(stats.get("loaded", 0))
|
||||
synced = int(stats.get("synced", 0))
|
||||
failed = int(stats.get("failed", 0))
|
||||
post_check_passed = bool(stats.get("post_check_passed", True))
|
||||
|
||||
mismatch_node_types = [
|
||||
node_type
|
||||
for node_type, item in consistency_by_type.items()
|
||||
if int(item.get("mismatch_count", 0)) > 0
|
||||
]
|
||||
|
||||
loaded = int(stats.get("loaded", 0))
|
||||
synced = int(stats.get("synced", 0))
|
||||
failed = int(stats.get("failed", 0))
|
||||
post_check_passed = bool(stats.get("post_check_passed", True))
|
||||
|
||||
logger.info("\n" + "=" * 96)
|
||||
logger.info(
|
||||
f"📈 Pipeline Stats: loaded={loaded}, synced={synced}, failed={failed}, post_check_passed={post_check_passed}, mismatch_types={len(mismatch_node_types)}"
|
||||
@@ -132,19 +167,6 @@ async def print_pipeline_summary(*, logger, node_types, binding_manager, local_d
|
||||
logger.info(f"🔎 Mismatch Node Types: {', '.join(mismatch_node_types)}")
|
||||
logger.info("=" * 96)
|
||||
|
||||
sample_per_type = 3
|
||||
has_mismatch_samples = any(int(item.get("mismatch_count", 0)) > 0 for item in consistency_by_type.values())
|
||||
if has_mismatch_samples:
|
||||
logger.info("\n" + "=" * 96)
|
||||
logger.info("🧪 Inconsistency Samples (per type)")
|
||||
logger.info("=" * 96)
|
||||
for node_type in node_types:
|
||||
item = consistency_by_type.get(node_type, {})
|
||||
mismatch_count = int(item.get("mismatch_count", 0))
|
||||
if mismatch_count <= 0:
|
||||
continue
|
||||
checked_pairs = int(item.get("checked_pairs", 0))
|
||||
samples = item.get("samples", []) or []
|
||||
logger.info(f"- {node_type}: mismatches={mismatch_count}, checked_pairs={checked_pairs}")
|
||||
for sample in samples[:sample_per_type]:
|
||||
logger.info(f" • {sample}")
|
||||
print_consistency_summary()
|
||||
print_collection_summary("Local", local_datasource, local_collection)
|
||||
print_collection_summary("Remote", remote_datasource, remote_collection)
|
||||
|
||||
Reference in New Issue
Block a user