detrium.core.registry

Stateless, isolation-safe component registry and factory for Detrium. Replaces the legacy mutable GLOBAL_CONFIG pattern so multiple DETR models and configurations can coexist in the same Python process without state leakage.

class RegisteredEntry

Immutable metadata describing a registered class or function.

字段

名称类型默认值
namestr—
targetAny—
is_classbool—
defaultsDict[str, Any]field(default_factory=dict)
arg_namesTuple[str, ...]()
injectTuple[str, ...]()
shareTuple[str, ...]()
class Registry

Stateless registry for Detrium modules, datasets, transforms, optimizers, and teachers.

名称类型默认值
namestr'detrium'
register(self, name: Optional[str]=None, *, force: bool=False) -> Callable[[Any], Any]

Decorator to register a class or function by name.

名称类型默认值
nameOptional[str]None
forceboolFalse
build_from_dict(self, spec: Mapping[str, Any], context: Optional[Mapping[str, Any]]=None, **extra_kwargs: Any) -> Any

Instantiate a registered component from a dict containing a 'type' key without mutating spec.

名称类型默认值
specMapping[str, Any]—
contextOptional[Mapping[str, Any]]None
extra_kwargsAny—
create(self, type_or_name: Union[Type[Any], str], cfg: Optional[Mapping[str, Any]]=None, **extra_kwargs: Any) -> Any

Statelessly create a registered component using `cfg` as an isolated config context. Never mutates either the registry's stored defaults or the caller's `cfg` dict.

名称类型默认值
type_or_nameUnion[Type[Any], str]—
cfgOptional[Mapping[str, Any]]None
extra_kwargsAny—
register(target_or_name: Any=None, *, name: Optional[str]=None, force: bool=False) -> Callable[[Any], Any]

Register a class or function into the default Detrium registry. Supports `@register()`, `@register(name="Alias")`, `@register("Alias")`, or `@register(force=True)`.

名称类型默认值
target_or_nameAnyNone
nameOptional[str]None
forceboolFalse
create(type_or_name: Union[Type[Any], str], cfg: Optional[Mapping[str, Any]]=None, **kwargs: Any) -> Any

Create a component from the default Detrium registry without mutating `cfg`.

名称类型默认值
type_or_nameUnion[Type[Any], str]—
cfgOptional[Mapping[str, Any]]None
kwargsAny—