(
value: Any,
current: Optional[Strategy],
path: str,
apply_fn: Callable[[Any, Dict[str, Any], str], None],
)
| 272 | } |
| 273 | |
| 274 | def _strategy_registry_handler( |
| 275 | value: Any, |
| 276 | current: Optional[Strategy], |
| 277 | path: str, |
| 278 | apply_fn: Callable[[Any, Dict[str, Any], str], None], |
| 279 | ): |
| 280 | is_training_strategy = False |
| 281 | |
| 282 | if isinstance(value, dict): |
| 283 | type_name = value.get("type") |
| 284 | if type_name in _STRATEGY_REGISTRY: |
| 285 | is_training_strategy = True |
| 286 | elif isinstance(current, Strategy): |
| 287 | field_names = {f.name for f in fields(type(current))} |
| 288 | if set(value.keys()).issubset(field_names): |
| 289 | is_training_strategy = True |
| 290 | elif isinstance(value, str) and value in _STRATEGY_REGISTRY: |
| 291 | is_training_strategy = True |
| 292 | elif isinstance(current, Strategy): |
| 293 | is_training_strategy = True |
| 294 | |
| 295 | if not is_training_strategy: |
| 296 | return current if isinstance(current, Strategy) else value |
| 297 | |
| 298 | return build_from_registry(value, _STRATEGY_REGISTRY, current, apply_fn=apply_fn, path=path) |
| 299 | |
| 300 | _REGISTRY_HANDLERS = { |
| 301 | "strategy": _strategy_registry_handler, |
nothing calls this directly
no test coverage detected