Extract row generation policy
This commit is contained in:
@@ -52,6 +52,7 @@ import row_normalization # noqa: E402
|
||||
import route_metadata # noqa: E402
|
||||
import row_camera # noqa: E402
|
||||
import row_expression # noqa: E402
|
||||
import row_generation # noqa: E402
|
||||
import row_item # noqa: E402
|
||||
import row_location # noqa: E402
|
||||
import row_pools # noqa: E402
|
||||
@@ -810,6 +811,77 @@ def smoke_row_item_policy() -> None:
|
||||
_expect(metadata.get("action_family") == "oral", "Row item compose lost template metadata")
|
||||
|
||||
|
||||
def smoke_row_generation_policy() -> None:
|
||||
_expect(pb._ratio_or_none(-1) is None, "Prompt builder ratio helper should treat negative as unset")
|
||||
_expect(pb._ratio_or_none(1.5) == row_generation.ratio_or_none(1.5) == 1.0, "Row generation ratio clamp changed")
|
||||
_expect(pb._clamped_float("bad", 0.4) == row_generation.clamped_float("bad", 0.4) == 0.4, "Row generation float default changed")
|
||||
|
||||
_expect(
|
||||
pb._pick_clothing_mode(random.Random(1), "random", None)
|
||||
== row_generation.pick_clothing_mode(random.Random(1), "random", None),
|
||||
"Prompt builder clothing mode picker should delegate to row_generation",
|
||||
)
|
||||
_expect(
|
||||
row_generation.pick_pose_mode(random.Random(2), "evocative", 1.0) == "standard",
|
||||
"Row generation standard pose ratio override changed",
|
||||
)
|
||||
_expect(
|
||||
pb._pick_figure_bias(random.Random(3), "random") == row_generation.pick_figure_bias(random.Random(3), "random"),
|
||||
"Prompt builder figure picker should delegate to row_generation",
|
||||
)
|
||||
_expect(
|
||||
row_generation.pick_expression_intensity(random.Random(4), -1) == (0.24, "random"),
|
||||
"Row generation random expression intensity changed",
|
||||
)
|
||||
_expect(
|
||||
pb._pick_expression_intensity(random.Random(4), 2.0) == row_generation.pick_expression_intensity(random.Random(4), 2.0) == (1.0, "input"),
|
||||
"Prompt builder expression intensity picker should delegate to row_generation",
|
||||
)
|
||||
|
||||
direct_args = dict(
|
||||
category="woman",
|
||||
row_number=3,
|
||||
start_index=41,
|
||||
clothing="full",
|
||||
ethnicity="any",
|
||||
poses="standard",
|
||||
backside_bias=0.25,
|
||||
figure="curvy",
|
||||
no_plus_women=False,
|
||||
no_black=False,
|
||||
minimal_clothing_ratio=None,
|
||||
standard_pose_ratio=None,
|
||||
seed=5050,
|
||||
)
|
||||
_expect(
|
||||
pb._build_direct_builtin_row(**direct_args) == row_generation.build_direct_builtin_row(**direct_args),
|
||||
"Prompt builder direct built-in row should delegate to row_generation",
|
||||
)
|
||||
auto_args = dict(
|
||||
row_number=2,
|
||||
start_index=41,
|
||||
clothing="minimal",
|
||||
ethnicity="any",
|
||||
poses="evocative",
|
||||
backside_bias=0.0,
|
||||
figure="balanced",
|
||||
no_plus_women=False,
|
||||
no_black=False,
|
||||
minimal_clothing_ratio=None,
|
||||
standard_pose_ratio=None,
|
||||
seed=6060,
|
||||
)
|
||||
auto_row = row_generation.build_auto_weighted_row(**auto_args)
|
||||
_expect(pb._build_auto_weighted_row(**auto_args) == auto_row, "Prompt builder auto-weighted row should delegate to row_generation")
|
||||
_expect(auto_row.get("source") == "built_in_generator", "Row generation auto-weighted row lost source metadata")
|
||||
|
||||
seed_cfg = seed_config.parse_seed_config({"category_seed": 123})
|
||||
_expect(
|
||||
pb._auto_full_choice(seed_cfg, 7070, 1) == row_generation.auto_full_choice(seed_cfg, 7070, 1),
|
||||
"Prompt builder auto-full choice should delegate to row_generation",
|
||||
)
|
||||
|
||||
|
||||
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")
|
||||
@@ -4010,6 +4082,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
|
||||
("row_location_policy", smoke_row_location_policy),
|
||||
("row_expression_policy", smoke_row_expression_policy),
|
||||
("row_item_policy", smoke_row_item_policy),
|
||||
("row_generation_policy", smoke_row_generation_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),
|
||||
|
||||
Reference in New Issue
Block a user