Expose formatter route traces
This commit is contained in:
+53
-2
@@ -3150,6 +3150,10 @@ def smoke_krea_format_route_policy() -> None:
|
||||
_expect(typed_single.output == public_single, "Typed Krea format route should match public single formatter output")
|
||||
_expect(typed_single.branch == "metadata(single)", "Typed Krea format route changed single branch")
|
||||
_expect(typed_single.target == "single", "Typed Krea format route lost target normalization")
|
||||
single_trace = json.loads(_expect_text("krea_format_route_policy.single_trace", typed_single.output.get("route_trace_json"), 20))
|
||||
_expect(single_trace.get("formatter") == "krea2", "Typed Krea single trace lost formatter")
|
||||
_expect(single_trace.get("branch") == "metadata(single)", "Typed Krea single trace lost branch")
|
||||
_expect(single_trace.get("target") == "single", "Typed Krea single trace lost target")
|
||||
_expect("krea route marker" in typed_single.output.get("krea_prompt", ""), "Typed Krea route lost extra positive")
|
||||
_expect("krea route negative" in typed_single.output.get("negative_prompt", ""), "Typed Krea route lost extra negative")
|
||||
|
||||
@@ -3191,6 +3195,9 @@ def smoke_krea_format_route_policy() -> None:
|
||||
)
|
||||
_expect(typed_pair.output == public_pair, "Typed Krea format route should match public pair formatter output")
|
||||
_expect(typed_pair.branch == "insta_of_pair", "Typed Krea format route changed pair branch")
|
||||
pair_trace = json.loads(_expect_text("krea_format_route_policy.pair_trace", typed_pair.output.get("route_trace_json"), 20))
|
||||
_expect(pair_trace.get("branch") == "insta_of_pair", "Typed Krea pair trace lost branch")
|
||||
_expect(pair_trace.get("selected_side") == "hardcore", "Typed Krea pair trace lost selected side")
|
||||
_expect_text("krea_format_route_policy.hard_prompt", typed_pair.output.get("krea_hardcore_prompt"), 40)
|
||||
_expect("pair route marker" in typed_pair.output.get("krea_prompt", ""), "Typed Krea pair route lost extra positive")
|
||||
|
||||
@@ -3217,6 +3224,9 @@ def smoke_krea_format_route_policy() -> None:
|
||||
_expect(typed_fallback.output == public_fallback, "Typed Krea format route should match public fallback output")
|
||||
_expect(typed_fallback.branch == "fallback", "Typed Krea format route changed fallback branch")
|
||||
_expect(typed_fallback.target == "auto", "Typed Krea format route should normalize invalid target")
|
||||
fallback_trace = json.loads(_expect_text("krea_format_route_policy.fallback_trace", typed_fallback.output.get("route_trace_json"), 20))
|
||||
_expect(fallback_trace.get("branch") == "fallback", "Typed Krea fallback trace lost branch")
|
||||
_expect(fallback_trace.get("input_hint") == "prompt", "Typed Krea fallback trace lost input hint")
|
||||
_expect(typed_fallback.detail_level == "balanced", "Typed Krea format route should normalize invalid detail level")
|
||||
_expect(typed_fallback.style_mode == "preserve", "Typed Krea format route should normalize invalid style mode")
|
||||
_expect(krea_format_route.style_mode_choices() == ["preserve", "photographic", "minimal"], "Krea style mode choices changed")
|
||||
@@ -3378,6 +3388,22 @@ def smoke_caption_format_route_policy() -> None:
|
||||
_expect(typed_metadata.detail_level == "dense", "Typed caption route lost training_dense detail override")
|
||||
_expect(typed_metadata.style_policy == "drop_style_tail", "Typed caption route lost training_dense style override")
|
||||
_expect(typed_metadata.include_trigger is True, "Typed caption route lost training_dense trigger override")
|
||||
metadata_trace = json.loads(_expect_text("caption_format_route_policy.metadata_trace", typed_metadata.route_trace_json, 20))
|
||||
_expect(metadata_trace.get("formatter") == "caption", "Typed caption metadata trace lost formatter")
|
||||
_expect(metadata_trace.get("branch") == "metadata", "Typed caption metadata trace lost branch")
|
||||
_expect(metadata_trace.get("target") == "single", "Typed caption metadata trace lost target")
|
||||
traced_public_metadata = caption_naturalizer.naturalize_caption_with_trace(
|
||||
"",
|
||||
metadata_json=metadata_request.metadata_json,
|
||||
input_hint=metadata_request.input_hint,
|
||||
target=metadata_request.target,
|
||||
trigger=metadata_request.trigger,
|
||||
include_trigger=metadata_request.include_trigger,
|
||||
detail_level=metadata_request.detail_level,
|
||||
style_policy=metadata_request.style_policy,
|
||||
caption_profile=metadata_request.caption_profile,
|
||||
)
|
||||
_expect(traced_public_metadata == typed_metadata.as_trace_tuple(), "Caption trace wrapper drifted from typed route")
|
||||
_expect(typed_metadata.caption.startswith(Trigger), "Typed caption metadata route should prepend training trigger")
|
||||
|
||||
fallback_request = caption_format_route.CaptionFormatRequest(
|
||||
@@ -3409,6 +3435,9 @@ def smoke_caption_format_route_policy() -> None:
|
||||
_expect(typed_fallback.input_hint == "auto", "Typed caption route should normalize invalid input hint")
|
||||
_expect(typed_fallback.target == "auto", "Typed caption route should normalize invalid target")
|
||||
_expect(typed_fallback.include_trigger is False, "Typed caption browsing profile should disable trigger")
|
||||
fallback_trace = json.loads(_expect_text("caption_format_route_policy.fallback_trace", typed_fallback.route_trace_json, 20))
|
||||
_expect(fallback_trace.get("branch") == "text", "Typed caption fallback trace lost branch")
|
||||
_expect(fallback_trace.get("input_hint") == "auto", "Typed caption fallback trace lost input hint")
|
||||
_expect(typed_fallback.keep_style is True, "Typed caption browsing profile should keep style terms")
|
||||
_expect(not typed_fallback.caption.startswith(Trigger), "Typed caption fallback route should not prepend browsing trigger")
|
||||
_expect(typed_fallback.method == "text(fallback)", "Typed caption fallback method changed")
|
||||
@@ -3721,6 +3750,11 @@ def smoke_sdxl_format_route_policy() -> None:
|
||||
_expect(typed_single.target == "single", "Typed SDXL format route lost target normalization")
|
||||
_expect(typed_single.nude_weight == 3.0, "Typed SDXL format route should clamp high nude weight")
|
||||
_expect(typed_single.style_preset == "photographic", "Typed SDXL format route lost profile style override")
|
||||
single_trace = json.loads(_expect_text("sdxl_format_route_policy.single_trace", typed_single.output.get("route_trace_json"), 20))
|
||||
_expect(single_trace.get("formatter") == "sdxl", "Typed SDXL single trace lost formatter")
|
||||
_expect(single_trace.get("branch") == "metadata", "Typed SDXL single trace lost branch")
|
||||
_expect(single_trace.get("target") == "single", "Typed SDXL single trace lost target")
|
||||
_expect(single_trace.get("nude_weight") == 3.0, "Typed SDXL single trace lost clamped nude weight")
|
||||
_expect("sdxl route marker" in typed_single.output.get("sdxl_prompt", ""), "Typed SDXL route lost extra positive")
|
||||
_expect("sdxl route negative" in typed_single.output.get("negative_prompt", ""), "Typed SDXL route lost extra negative")
|
||||
|
||||
@@ -3762,6 +3796,9 @@ def smoke_sdxl_format_route_policy() -> None:
|
||||
)
|
||||
_expect(typed_pair.output == public_pair, "Typed SDXL format route should match public pair formatter output")
|
||||
_expect(typed_pair.branch == "insta_of_pair", "Typed SDXL format route changed pair branch")
|
||||
pair_trace = json.loads(_expect_text("sdxl_format_route_policy.pair_trace", typed_pair.output.get("route_trace_json"), 20))
|
||||
_expect(pair_trace.get("branch") == "insta_of_pair", "Typed SDXL pair trace lost branch")
|
||||
_expect(pair_trace.get("selected_side") == "hardcore", "Typed SDXL pair trace lost selected side")
|
||||
_expect_text("sdxl_format_route_policy.hard_prompt", typed_pair.output.get("sdxl_hardcore_prompt"), 40)
|
||||
_expect("pair sdxl route marker" in typed_pair.output.get("sdxl_prompt", ""), "Typed SDXL pair route lost extra positive")
|
||||
|
||||
@@ -3793,6 +3830,9 @@ def smoke_sdxl_format_route_policy() -> None:
|
||||
_expect(typed_fallback.branch == "fallback", "Typed SDXL format route changed fallback branch")
|
||||
_expect(typed_fallback.target == "auto", "Typed SDXL format route should normalize invalid target")
|
||||
_expect(typed_fallback.nude_weight == 0.1, "Typed SDXL format route should clamp low nude weight")
|
||||
fallback_trace = json.loads(_expect_text("sdxl_format_route_policy.fallback_trace", typed_fallback.output.get("route_trace_json"), 20))
|
||||
_expect(fallback_trace.get("branch") == "fallback", "Typed SDXL fallback trace lost branch")
|
||||
_expect(fallback_trace.get("input_hint") == "prompt", "Typed SDXL fallback trace lost input hint")
|
||||
_expect("Characters:" not in typed_fallback.output.get("sdxl_prompt", ""), "Typed SDXL fallback leaked Characters label")
|
||||
_expect("blur" in typed_fallback.output.get("negative_prompt", ""), "Typed SDXL fallback route lost Avoid negative")
|
||||
|
||||
@@ -7005,7 +7045,7 @@ def smoke_node_formatter_registration() -> None:
|
||||
_expect(krea_optional["metadata_json"][1].get("forceInput") is True, "Krea2 Formatter metadata_json should be connectable")
|
||||
_expect(krea_optional["negative_prompt"][1].get("forceInput") is True, "Krea2 Formatter negative_prompt should be connectable")
|
||||
|
||||
caption, caption_method = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPCaptionNaturalizer"]().build(
|
||||
caption, caption_method, caption_trace_json = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPCaptionNaturalizer"]().build(
|
||||
"A woman standing by a window, best quality",
|
||||
"caption_or_prompt",
|
||||
"manual_controls",
|
||||
@@ -7017,6 +7057,9 @@ def smoke_node_formatter_registration() -> None:
|
||||
_expect_text("node_formatter.caption", caption, 20)
|
||||
_expect(caption.startswith("sxcppnl7"), "Caption Naturalizer did not prepend trigger")
|
||||
_expect("text(" in caption_method, "Caption Naturalizer method changed unexpectedly")
|
||||
caption_trace = json.loads(_expect_text("node_formatter.caption_trace", caption_trace_json, 20))
|
||||
_expect(caption_trace.get("formatter") == "caption", "Caption Naturalizer trace lost formatter")
|
||||
_expect(caption_trace.get("branch") == "text", "Caption Naturalizer trace lost text branch")
|
||||
caption_inputs = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPCaptionNaturalizer"].INPUT_TYPES().get("required") or {}
|
||||
_expect("caption_profile" in caption_inputs, "Caption Naturalizer lost caption_profile input")
|
||||
_expect("target" in caption_inputs, "Caption Naturalizer lost target input")
|
||||
@@ -7039,6 +7082,9 @@ def smoke_node_formatter_registration() -> None:
|
||||
_expect_text("node_formatter.krea_prompt", krea_output[0], 20)
|
||||
_expect("sxcppnl7" in krea_output[0], "Krea2 Formatter did not preserve trigger when enabled")
|
||||
_expect(krea_output[6].startswith("text("), "Krea2 Formatter method changed unexpectedly")
|
||||
krea_trace = json.loads(_expect_text("node_formatter.krea_trace", krea_output[7], 20))
|
||||
_expect(krea_trace.get("formatter") == "krea2", "Krea2 Formatter trace lost formatter")
|
||||
_expect(krea_trace.get("branch") == "fallback", "Krea2 Formatter trace lost fallback branch")
|
||||
|
||||
sdxl_output = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPSDXLFormatter"]().build(
|
||||
"A woman standing by a window",
|
||||
@@ -7056,6 +7102,9 @@ def smoke_node_formatter_registration() -> None:
|
||||
_expect_trigger_once("node_formatter.sdxl_prompt", sdxl_output[0], "mythp0rt")
|
||||
_expect_text("node_formatter.sdxl_negative", sdxl_output[1], 20)
|
||||
_expect(sdxl_output[6].startswith("text("), "SDXL Formatter method changed unexpectedly")
|
||||
sdxl_trace = json.loads(_expect_text("node_formatter.sdxl_trace", sdxl_output[7], 20))
|
||||
_expect(sdxl_trace.get("formatter") == "sdxl", "SDXL Formatter trace lost formatter")
|
||||
_expect(sdxl_trace.get("branch") == "fallback", "SDXL Formatter trace lost fallback branch")
|
||||
sdxl_inputs = sxcp_nodes.NODE_CLASS_MAPPINGS["SxCPSDXLFormatter"].INPUT_TYPES().get("required") or {}
|
||||
_expect("formatter_profile" in sdxl_inputs, "SDXL Formatter lost formatter_profile input")
|
||||
_expect(sdxl_inputs["target"][0] == formatter_target.target_choices(), "SDXL Formatter target choices drifted")
|
||||
@@ -7108,6 +7157,7 @@ def smoke_node_formatter_registration() -> None:
|
||||
expected_krea_pair["softcore_negative_prompt"],
|
||||
expected_krea_pair["hardcore_negative_prompt"],
|
||||
expected_krea_pair["method"],
|
||||
expected_krea_pair["route_trace_json"],
|
||||
),
|
||||
"Krea2 Formatter node output drifted from public metadata formatter",
|
||||
)
|
||||
@@ -7152,11 +7202,12 @@ def smoke_node_formatter_registration() -> None:
|
||||
expected_sdxl_pair["softcore_negative_prompt"],
|
||||
expected_sdxl_pair["hardcore_negative_prompt"],
|
||||
expected_sdxl_pair["method"],
|
||||
expected_sdxl_pair["route_trace_json"],
|
||||
),
|
||||
"SDXL Formatter node output drifted from public metadata formatter",
|
||||
)
|
||||
|
||||
expected_caption_pair = caption_naturalizer.naturalize_caption(
|
||||
expected_caption_pair = caption_naturalizer.naturalize_caption_with_trace(
|
||||
"",
|
||||
metadata_json=pair_metadata,
|
||||
input_hint="metadata_json",
|
||||
|
||||
Reference in New Issue
Block a user