data_juicer.utils.registry module¶
- class data_juicer.utils.registry.Registry(name: str)[源代码]¶
基类:
object
This class is used to register some modules to registry by a repo name.
- property name¶
Get name of current registry.
- 返回:
name of current registry.
- property modules¶
Get all modules in current registry.
- 返回:
a dict storing modules in current registry.
- get(module_key)[源代码]¶
Get module named module_key from in current registry. If not found, return None.
- 参数:
module_key -- specified module name
- 返回:
module named module_key
- register_module(module_name: str = None, module_cls: type = None, force=False)[源代码]¶
Register module class object to registry with the specified modulename.
- 参数:
module_name -- module name
module_cls -- module class object
force -- Whether to override an existing class with the same name. Default: False.
示例
>>> registry = Registry() >>> @registry.register_module() >>> class TextFormatter: >>> pass
>>> class TextFormatter2: >>> pass >>> registry.register_module( module_name='text_formatter2', module_cls=TextFormatter2)