Extract row pool routing policy
This commit is contained in:
+6
-76
@@ -12,12 +12,8 @@ try:
|
||||
category_json_files as _json_files,
|
||||
compatible_entries as _compatible_entries,
|
||||
compatible_entry as _compatible_entry,
|
||||
configured_pool as _configured_pool,
|
||||
find_subcategory as _find_subcategory,
|
||||
load_category_library,
|
||||
load_composition_pool_library,
|
||||
load_expression_pool_library,
|
||||
load_scene_pool_library,
|
||||
merged_axes as _merged_axes,
|
||||
merged_field as _merged_field,
|
||||
read_category_json as _read_json,
|
||||
@@ -46,6 +42,7 @@ try:
|
||||
from . import row_normalization as row_policy
|
||||
from . import row_camera as row_camera_policy
|
||||
from . import row_location as row_location_policy
|
||||
from . import row_pools as row_pool_policy
|
||||
from . import seed_config as seed_policy
|
||||
from . import subject_context as subject_context_policy
|
||||
from .hardcore_text_cleanup import (
|
||||
@@ -59,12 +56,8 @@ except ImportError: # Allows local smoke tests with `python -c`.
|
||||
category_json_files as _json_files,
|
||||
compatible_entries as _compatible_entries,
|
||||
compatible_entry as _compatible_entry,
|
||||
configured_pool as _configured_pool,
|
||||
find_subcategory as _find_subcategory,
|
||||
load_category_library,
|
||||
load_composition_pool_library,
|
||||
load_expression_pool_library,
|
||||
load_scene_pool_library,
|
||||
merged_axes as _merged_axes,
|
||||
merged_field as _merged_field,
|
||||
read_category_json as _read_json,
|
||||
@@ -93,6 +86,7 @@ except ImportError: # Allows local smoke tests with `python -c`.
|
||||
import row_normalization as row_policy
|
||||
import row_camera as row_camera_policy
|
||||
import row_location as row_location_policy
|
||||
import row_pools as row_pool_policy
|
||||
import seed_config as seed_policy
|
||||
import subject_context as subject_context_policy
|
||||
from hardcore_text_cleanup import (
|
||||
@@ -2519,46 +2513,11 @@ def _scene_pool(
|
||||
subject_type: str,
|
||||
location_config: dict[str, Any] | None = None,
|
||||
) -> list[Any]:
|
||||
location_config = location_config or {}
|
||||
location_entries = _list_from(location_config.get("scene_entries"))
|
||||
if _location_config_active(location_config) and location_config.get("apply_mode") == "replace":
|
||||
return location_entries
|
||||
fallback = g.GROUP_SCENES if subject_type in ("group", "configured_cast") else g.SCENES
|
||||
scene_entries: list[Any] = []
|
||||
scene_pools = load_scene_pool_library()
|
||||
item_source = item if isinstance(item, dict) else None
|
||||
if item_source is not None and _is_false(item_source.get("inherit_scenes")):
|
||||
sources = (item_source,)
|
||||
elif _is_false(subcategory.get("inherit_scenes")):
|
||||
sources = (subcategory, item_source)
|
||||
else:
|
||||
sources = (category, subcategory, item_source)
|
||||
for source in sources:
|
||||
if not isinstance(source, dict):
|
||||
continue
|
||||
if "scenes" in source:
|
||||
_unique_extend(scene_entries, _list_from(source["scenes"]))
|
||||
refs = _list_from(source.get("scene_pool")) + _list_from(source.get("scene_pools"))
|
||||
for ref in refs:
|
||||
ref_name = str(ref).strip()
|
||||
if ref_name not in scene_pools:
|
||||
raise ValueError(f"Unknown scene pool '{ref_name}'")
|
||||
_unique_extend(scene_entries, scene_pools[ref_name])
|
||||
if _location_config_active(location_config) and location_config.get("apply_mode") == "add":
|
||||
_unique_extend(scene_entries, location_entries)
|
||||
return scene_entries or fallback
|
||||
return row_pool_policy.scene_pool(category, subcategory, item, subject_type, location_config)
|
||||
|
||||
|
||||
def _expression_pool(category: dict[str, Any], subcategory: dict[str, Any], item: Any) -> list[Any]:
|
||||
return _configured_pool(
|
||||
category,
|
||||
subcategory,
|
||||
item,
|
||||
"expressions",
|
||||
"expression_pools",
|
||||
load_expression_pool_library(),
|
||||
"inherit_expressions",
|
||||
) or g.EXPRESSIONS
|
||||
return row_pool_policy.expression_pool(category, subcategory, item)
|
||||
|
||||
|
||||
def _expression_intensity_hint(entry: Any) -> float:
|
||||
@@ -2685,14 +2644,7 @@ def _expression_entries_for_intensity(entries: list[Any], expression_intensity:
|
||||
|
||||
|
||||
def _pose_pool(category: dict[str, Any], subcategory: dict[str, Any], item: Any, subject_type: str, poses: str) -> list[Any]:
|
||||
configured = _merged_field(category, subcategory, item, "poses")
|
||||
if configured:
|
||||
return _list_from(configured)
|
||||
if subject_type == "couple":
|
||||
return [entry[2] for entry in g.COUPLE_TYPES]
|
||||
if subject_type in ("layout", "scene"):
|
||||
return ["clean designed layout"]
|
||||
return g.EVOCATIVE_ALL if poses == "evocative" else g.POSES
|
||||
return row_pool_policy.pose_pool(category, subcategory, item, subject_type, poses)
|
||||
|
||||
|
||||
def _composition_pool(
|
||||
@@ -2702,29 +2654,7 @@ def _composition_pool(
|
||||
subject_type: str,
|
||||
composition_config: dict[str, Any] | None = None,
|
||||
) -> list[Any]:
|
||||
composition_config = composition_config or {}
|
||||
composition_entries = _list_from(composition_config.get("composition_entries"))
|
||||
if _composition_config_active(composition_config) and composition_config.get("apply_mode") == "replace":
|
||||
return composition_entries
|
||||
configured = _configured_pool(
|
||||
category,
|
||||
subcategory,
|
||||
item,
|
||||
"compositions",
|
||||
"composition_pools",
|
||||
load_composition_pool_library(),
|
||||
"inherit_compositions",
|
||||
)
|
||||
if _composition_config_active(composition_config) and composition_config.get("apply_mode") == "add":
|
||||
configured = list(configured or [])
|
||||
_unique_extend(configured, composition_entries)
|
||||
if configured:
|
||||
return configured
|
||||
if subject_type in ("group", "configured_cast"):
|
||||
return g.GROUP_COMPOSITIONS
|
||||
if subject_type in ("layout", "scene"):
|
||||
return ["designed illustration layout"]
|
||||
return g.COMPOSITIONS
|
||||
return row_pool_policy.composition_pool(category, subcategory, item, subject_type, composition_config)
|
||||
|
||||
|
||||
def _build_custom_row(
|
||||
|
||||
Reference in New Issue
Block a user