Extract row prompt axes policy
This commit is contained in:
@@ -58,6 +58,7 @@ import row_generation # noqa: E402
|
||||
import row_item # noqa: E402
|
||||
import row_location # noqa: E402
|
||||
import row_pools # noqa: E402
|
||||
import row_prompt_axes # noqa: E402
|
||||
import row_rendering # noqa: E402
|
||||
import row_route_metadata # noqa: E402
|
||||
import row_subject_route # noqa: E402
|
||||
@@ -758,6 +759,91 @@ def smoke_row_expression_policy() -> None:
|
||||
)
|
||||
|
||||
|
||||
def smoke_row_prompt_axes_policy() -> None:
|
||||
category = {
|
||||
"name": "Axis Test",
|
||||
"slug": "axis_test",
|
||||
"scenes": [{"slug": "studio", "prompt": "quiet studio with repeatable anchors"}],
|
||||
"poses": ["standing fallback pose"],
|
||||
"expressions": ["quiet focus", "heated smirk"],
|
||||
"compositions": ["all participants visible centered frame"],
|
||||
}
|
||||
subcategory = {"name": "Axis Sub", "slug": "axis_sub", "items": ["axis item"]}
|
||||
item = "axis item"
|
||||
base_kwargs = {
|
||||
"category": category,
|
||||
"subcategory": subcategory,
|
||||
"item": item,
|
||||
"subject_type": "woman",
|
||||
"context": {"fallback_pose": ""},
|
||||
"poses": "standard",
|
||||
"women_count": 1,
|
||||
"men_count": 0,
|
||||
"expression_disabled": True,
|
||||
"expression_intensity": 0.5,
|
||||
"is_pose_category": False,
|
||||
"location_config": {},
|
||||
"composition_config": {},
|
||||
}
|
||||
route = row_prompt_axes.resolve_prompt_axes(
|
||||
**base_kwargs,
|
||||
scene_rng=random.Random(1),
|
||||
pose_rng=random.Random(2),
|
||||
expression_rng=random.Random(3),
|
||||
composition_rng=random.Random(4),
|
||||
)
|
||||
delegated = pb._prompt_axes_route(
|
||||
**base_kwargs,
|
||||
scene_rng=random.Random(1),
|
||||
pose_rng=random.Random(2),
|
||||
expression_rng=random.Random(3),
|
||||
composition_rng=random.Random(4),
|
||||
)
|
||||
_expect(delegated == route, "Prompt builder prompt-axes route should delegate to row_prompt_axes")
|
||||
_expect(route["scene_slug"] == "studio", "Prompt axes route lost selected scene slug")
|
||||
_expect(route["scene"] == "quiet studio with repeatable anchors", "Prompt axes route lost selected scene text")
|
||||
_expect(route["pose"] == "standing fallback pose", "Prompt axes route lost selected fallback pose")
|
||||
_expect(route["expression"] == "", "Prompt axes route should omit expression when disabled")
|
||||
_expect(route["shared_expression"] == "", "Prompt axes route should omit shared expression when disabled")
|
||||
_expect(route["source_composition"] == "all participants visible centered frame", "Prompt axes route lost source composition")
|
||||
|
||||
pov_route = row_prompt_axes.resolve_prompt_axes(
|
||||
**{**base_kwargs, "expression_disabled": True},
|
||||
scene_rng=random.Random(1),
|
||||
pose_rng=random.Random(2),
|
||||
expression_rng=random.Random(3),
|
||||
composition_rng=random.Random(4),
|
||||
pov_character_labels=["Man A"],
|
||||
)
|
||||
_expect("first-person POV" in pov_route["composition"], "Prompt axes route did not adapt composition for POV")
|
||||
|
||||
woman_slot = character_slot.normalize_character_slot(
|
||||
{"subject_type": "woman", "label": "A", "expression_intensity": 0.25}
|
||||
)
|
||||
configured_route = row_prompt_axes.resolve_prompt_axes(
|
||||
**{
|
||||
**base_kwargs,
|
||||
"subject_type": "configured_cast",
|
||||
"context": {"subject_type": "configured_cast"},
|
||||
"expression_disabled": False,
|
||||
"character_slots": [woman_slot],
|
||||
"character_slot_map": {"Woman A": woman_slot},
|
||||
},
|
||||
scene_rng=random.Random(1),
|
||||
pose_rng=random.Random(2),
|
||||
expression_rng=random.Random(3),
|
||||
composition_rng=random.Random(4),
|
||||
)
|
||||
_expect(
|
||||
configured_route["character_expression_text"].startswith("Woman A has "),
|
||||
"Prompt axes route lost configured-cast character expression",
|
||||
)
|
||||
_expect(
|
||||
configured_route["expression"] == configured_route["character_expression_text"],
|
||||
"Prompt axes route did not promote character expression text to row expression",
|
||||
)
|
||||
|
||||
|
||||
def smoke_row_item_policy() -> None:
|
||||
weighted_entries = [
|
||||
{"text": "first", "weight": 0.0},
|
||||
@@ -4387,6 +4473,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
|
||||
("location_config_policy", smoke_location_config_policy),
|
||||
("row_location_policy", smoke_row_location_policy),
|
||||
("row_expression_policy", smoke_row_expression_policy),
|
||||
("row_prompt_axes_policy", smoke_row_prompt_axes_policy),
|
||||
("row_item_policy", smoke_row_item_policy),
|
||||
("row_category_route_policy", smoke_row_category_route_policy),
|
||||
("row_generation_policy", smoke_row_generation_policy),
|
||||
|
||||
Reference in New Issue
Block a user