Extract row assembly policy
This commit is contained in:
@@ -50,6 +50,7 @@ import pair_clothing # noqa: E402
|
||||
import prompt_builder as pb # noqa: E402
|
||||
import pov_policy # noqa: E402
|
||||
import row_normalization # noqa: E402
|
||||
import row_assembly # noqa: E402
|
||||
import route_metadata # noqa: E402
|
||||
import row_camera # noqa: E402
|
||||
import row_category_route # noqa: E402
|
||||
@@ -1687,6 +1688,99 @@ def smoke_row_rendering_policy() -> None:
|
||||
)
|
||||
|
||||
|
||||
def smoke_row_assembly_policy() -> None:
|
||||
context = {
|
||||
"subject": "configured cast",
|
||||
"subject_phrase": "configured adult cast",
|
||||
"age": "21+ adults",
|
||||
"body": "varied adult builds",
|
||||
"body_phrase": "varied adult builds",
|
||||
"figure": "balanced cast",
|
||||
"skin": "warm skin tones",
|
||||
"hair": "dark hair",
|
||||
"eyes": "brown eyes",
|
||||
"cast_summary": "one woman and one man",
|
||||
"scene_kind": "configured_cast",
|
||||
"women_count": "1",
|
||||
"men_count": "1",
|
||||
"person_count": "2",
|
||||
}
|
||||
count_adjustment = {"requested_women_count": 1, "requested_men_count": 1}
|
||||
kwargs = {
|
||||
"row_number": 2,
|
||||
"start_index": 10,
|
||||
"category": {"name": "Axis Test", "slug": "axis_test"},
|
||||
"subcategory": {
|
||||
"name": "Custom Scene",
|
||||
"slug": "custom_scene",
|
||||
"prompt_template": "Scene: {item}. Composition: {composition_prompt}. Avoid: {negative_prompt}.",
|
||||
"caption_template": "{trigger}, {item}, {scene}",
|
||||
},
|
||||
"item": {"text": "shared structured action"},
|
||||
"context": context,
|
||||
"subject_type": "configured_cast",
|
||||
"item_text": "shared structured action",
|
||||
"item_name": "shared_action",
|
||||
"item_axis_values": {"action_family": "test_action"},
|
||||
"item_template_metadata": {"position_key": "test_position"},
|
||||
"formatter_hints": {"krea": ["test_hint"]},
|
||||
"item_label": "Scene",
|
||||
"style": "clean test style",
|
||||
"positive_suffix": "clear readable composition.",
|
||||
"negative_prompt": "bad anatomy",
|
||||
"scene_slug": "test_room",
|
||||
"scene": "warm test room",
|
||||
"pose": "standing close",
|
||||
"expression": "focused look",
|
||||
"shared_expression": "focused look",
|
||||
"character_expressions": ["Woman A has focused look"],
|
||||
"character_expression_text": "Woman A has focused look",
|
||||
"expression_disabled": True,
|
||||
"expression_intensity": 0.7,
|
||||
"expression_intensity_source": "disabled",
|
||||
"composition": "centered frame",
|
||||
"source_composition": "centered frame",
|
||||
"role_graph": "the visible partner stays centered",
|
||||
"source_role_graph": "Man A stays centered",
|
||||
"action_family": "test_action",
|
||||
"position_family": "standing",
|
||||
"position_key": "test_position",
|
||||
"position_keys": ["test_position"],
|
||||
"pov_character_labels": ["Man A"],
|
||||
"cast_descriptors": ["Woman A: adult woman", "Man A: adult man"],
|
||||
"cast_descriptor_text": "Woman A: adult woman; Man A: adult man",
|
||||
"seed_config": {"content_seed": 123},
|
||||
"hardcore_position_config": {"family": "standing"},
|
||||
"location_config": {"location": "test_room"},
|
||||
"composition_config": {"composition": "centered"},
|
||||
"content_seed_axis": "pose",
|
||||
"count_adjustment": count_adjustment,
|
||||
"applied_profile": {"name": "profile_a"},
|
||||
"profile_status": "applied",
|
||||
"applied_slot": {"label": "Woman A"},
|
||||
"slot_status": "applied",
|
||||
"character_slots": [{"label": "Woman A"}, {"label": "Man A"}],
|
||||
}
|
||||
row = row_assembly.assemble_custom_row(**kwargs)
|
||||
delegated = pb._assemble_custom_row(**kwargs)
|
||||
|
||||
_expect(row == delegated, "Prompt builder row assembly wrapper should delegate without changing output")
|
||||
_expect(row["id"] == "sxcp_0011", "Row assembly changed row indexing")
|
||||
_expect(row["batch"] == "batch_001", "Row assembly changed batch calculation")
|
||||
_expect(row["source"] == "json_category", "Row assembly lost source marker")
|
||||
_expect(row["figure"] == "balanced cast", "Row assembly lost figure metadata")
|
||||
_expect(row["formatter_hints"] == {"krea": ["test_hint"]}, "Row assembly lost formatter hints")
|
||||
_expect(row["cast_count_adjustment"] == count_adjustment, "Row assembly lost configured-cast count adjustment")
|
||||
_expect(row["content_seed_axis"] == "pose", "Row assembly lost content seed axis")
|
||||
_expect("POV participant: Man A" in row["prompt"], "Row assembly lost POV prompt directive")
|
||||
_expect("Characters: Woman A: adult woman; Man A: adult man." in row["prompt"], "Row assembly lost cast descriptor insertion")
|
||||
_expect(row["caption"].endswith("Woman A: adult woman; Man A: adult man"), "Row assembly lost caption descriptor append")
|
||||
_expect(row["expression"] == "", "Disabled expression should clear row expression")
|
||||
_expect(row["expression_enabled"] is False, "Disabled expression should mark expression disabled")
|
||||
_expect(row["expression_intensity"] is None, "Disabled expression should clear intensity")
|
||||
_expect(row["expression_intensity_source"] == "disabled", "Disabled expression should preserve disabled source")
|
||||
|
||||
|
||||
def smoke_formatter_input_policy() -> None:
|
||||
source_row = {
|
||||
"prompt": "A simple adult portrait. Setting: quiet studio. Pose: standing calmly. Avoid: low quality.",
|
||||
@@ -4486,6 +4580,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
|
||||
("character_profile_policy", smoke_character_profile_policy),
|
||||
("row_normalization_policy", smoke_row_normalization_policy),
|
||||
("row_rendering_policy", smoke_row_rendering_policy),
|
||||
("row_assembly_policy", smoke_row_assembly_policy),
|
||||
("formatter_input_policy", smoke_formatter_input_policy),
|
||||
("formatter_cast_policy", smoke_formatter_cast_policy),
|
||||
("caption_policy", smoke_caption_policy),
|
||||
|
||||
Reference in New Issue
Block a user