Extract row location policy

This commit is contained in:
2026-06-27 03:09:17 +02:00
parent d4d3be5789
commit 7f808be997
5 changed files with 256 additions and 102 deletions
+47
View File
@@ -45,6 +45,7 @@ import prompt_builder as pb # noqa: E402
import row_normalization # noqa: E402
import route_metadata # noqa: E402
import row_camera # noqa: E402
import row_location # noqa: E402
import server_routes # noqa: E402
import sdxl_formatter # noqa: E402
import sdxl_presets # noqa: E402
@@ -603,6 +604,51 @@ def smoke_location_config_policy() -> None:
_expect(json.loads(themed_composition).get("composition_entries"), "Themed location did not output compositions")
def smoke_row_location_policy() -> None:
location = json.loads(
location_config.build_location_pool_json(
combine_mode="replace",
custom_locations="archive_corner: hidden archive corner with repeated shelves and warm table lamps",
)
)
composition = json.loads(
location_config.build_composition_pool_json(
combine_mode="replace",
custom_compositions="long archive aisle composition",
)
)
row = {
"source": "built_in_generator",
"primary_subject": "adult woman",
"scene": "unknown_old_scene",
"composition": "old frame",
"prompt": "A generated adult prompt. Scene: old room. Pose: standing. Composition: vertical old frame. Avoid: low quality.",
"caption": "sxcppnl7, generated adult prompt, old room, old frame, illustration",
}
updated = row_location.apply_location_config_to_legacy_row(dict(row), location, {}, 123, 1)
updated = row_location.apply_composition_config_to_legacy_row(updated, composition, {}, 123, 1)
_expect(updated.get("scene") == "archive_corner", "Row location policy did not select forced custom scene slug")
_expect(
updated.get("scene_text") == "hidden archive corner with repeated shelves and warm table lamps",
"Row location policy did not apply forced custom scene text",
)
_expect(updated.get("source_scene") == "unknown_old_scene", "Row location policy lost source scene slug")
_expect(
"Scene: hidden archive corner with repeated shelves and warm table lamps. Pose:" in updated.get("prompt", ""),
"Row location policy did not rewrite prompt scene",
)
_expect(updated.get("composition") == "long archive aisle composition", "Row location policy did not apply forced composition")
_expect(
updated.get("composition_prompt") == "vertical long archive aisle composition",
"Row location policy did not compute composition prompt",
)
_expect(
"Composition: vertical long archive aisle composition." in updated.get("prompt", ""),
"Row location policy did not rewrite prompt composition",
)
_expect(", long archive aisle composition," in updated.get("caption", ""), "Row location policy did not rewrite caption composition")
def smoke_category_cast_config_policy() -> None:
_expect(pb.CATEGORY_PRESETS is category_cast_config.CATEGORY_PRESETS, "Prompt builder category presets are not delegated")
_expect(pb.CAST_PRESETS is category_cast_config.CAST_PRESETS, "Prompt builder cast presets are not delegated")
@@ -3475,6 +3521,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
("row_camera_policy", smoke_row_camera_policy),
("config_route_location_theme", smoke_config_route_location_theme),
("location_config_policy", smoke_location_config_policy),
("row_location_policy", smoke_row_location_policy),
("category_cast_config_policy", smoke_category_cast_config_policy),
("generation_profile_config_policy", smoke_generation_profile_config_policy),
("filter_config_policy", smoke_filter_config_policy),