MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / _strategy_registry_handler

Function _strategy_registry_handler

examples/simple_trainer.py:274–298  ·  view source on GitHub ↗
(
    value: Any,
    current: Optional[Strategy],
    path: str,
    apply_fn: Callable[[Any, Dict[str, Any], str], None],
)

Source from the content-addressed store, hash-verified

272}
273
274def _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,

Callers

nothing calls this directly

Calls 2

build_from_registryFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected