mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-21 17:40:33 +00:00
Refactored docstring to google style
This commit is contained in:
@@ -9,11 +9,10 @@ class Registry:
|
||||
"""This is a registry class used to register classes and modules so that a universal
|
||||
object builder can be enabled.
|
||||
|
||||
:param name: The name of the registry
|
||||
:type name: str
|
||||
:param third_party_library: List of third party libraries which are used in the
|
||||
initialization of the register module
|
||||
:type third_party_library: list, optional
|
||||
Args:
|
||||
name (str): The name of the registry .
|
||||
third_party_library (list, optional):
|
||||
List of third party libraries which are used in the initialization of the register module.
|
||||
"""
|
||||
|
||||
def __init__(self, name: str, third_party_library: List[ModuleType] = None):
|
||||
@@ -28,12 +27,12 @@ class Registry:
|
||||
def register_module(self, module_class):
|
||||
"""Registers a module represented in `module_class`.
|
||||
|
||||
:param module_class: The module to be registered
|
||||
:type module_class: class
|
||||
:raises AssertionError: Raises an AssertionError if the module has already been
|
||||
registered before
|
||||
:return: The module to be registered, so as to use it normally if via importing
|
||||
:rtype: class
|
||||
Args:
|
||||
module_class (class): The module to be registered.
|
||||
Returns:
|
||||
class: The module to be registered, so as to use it normally if via importing.
|
||||
Raises:
|
||||
AssertionError: Raises an AssertionError if the module has already been registered before.
|
||||
"""
|
||||
module_name = module_class.__name__
|
||||
assert module_name not in self._registry
|
||||
@@ -46,12 +45,13 @@ class Registry:
|
||||
"""Retrieves a module with name `module_name` and returns the module if it has
|
||||
already been registered before.
|
||||
|
||||
:param module_name: The name of the module to be retrieved
|
||||
:type module_name: str
|
||||
:raises NameError: Raises a NameError if the module to be retrieved has neither been
|
||||
registered directly nor as third party modules before
|
||||
:return: The retrieved module or None
|
||||
:rtype: :class:`object`
|
||||
Args:
|
||||
module_name (str): The name of the module to be retrieved.
|
||||
Returns:
|
||||
:class:`object`: The retrieved module or None.
|
||||
Raises:
|
||||
NameError: Raises a NameError if the module to be retrieved has neither been
|
||||
registered directly nor as third party modules before.
|
||||
"""
|
||||
if module_name in self._registry:
|
||||
return self._registry[module_name]
|
||||
@@ -65,11 +65,11 @@ class Registry:
|
||||
"""Searches for a module with name `module_name` and returns a boolean value indicating
|
||||
whether the module has been registered directly or as third party modules before.
|
||||
|
||||
:param module_name: The name of the module to be searched for
|
||||
:type module_name: str
|
||||
:return: A boolean value indicating whether the module has been registered directly or
|
||||
as third party modules before
|
||||
:rtype: bool
|
||||
Args:
|
||||
module_name (str): The name of the module to be searched for.
|
||||
Returns:
|
||||
bool: A boolean value indicating whether the module has been registered directly or
|
||||
as third party modules before.
|
||||
"""
|
||||
found_flag = module_name in self._registry
|
||||
|
||||
|
Reference in New Issue
Block a user