core.transformer.spec_utils#

Module Contents#

Classes#

ModuleSpec

This is a Module Specification dataclass.

Functions#

import_module

Import a named object from a module in the context of this function.

get_module

Returns or imports the provided module.

build_module

Builds an instance of the module from the spec.

Data#

API#

core.transformer.spec_utils.logger#

‘getLogger(…)’

class core.transformer.spec_utils.ModuleSpec#

This is a Module Specification dataclass.

Specification defines the location of the module (to import dynamically) or the imported module itself. It also defines the params that need to be passed to initialize the module.

Parameters:
  • module (Union[Tuple, type]) – A tuple describing the location of the module class e.g. (module.location, ModuleClass) or the imported module class itself e.g. ModuleClass (which is already imported using from module.location import ModuleClass).

  • params (dict) – A dictionary of params that need to be passed while init.

module: Union[Tuple, type]#

None

params: dict#

‘field(…)’

submodules: object#

None

__call__(*args: Any, **kwargs: Any) Any#

Builds an instance of the module from the spec.

Parameters:
  • *args – Positional arguments to be passed to the module init.

  • **kwargs – Keyword arguments to be passed to the module init.

core.transformer.spec_utils.import_module(module_path: Tuple[str])#

Import a named object from a module in the context of this function.

TODO: make this importer module more robust, at least make sure there are no side effects of using this as is

core.transformer.spec_utils.get_module(
spec_or_module: Union[core.transformer.spec_utils.ModuleSpec, type],
**additional_kwargs,
)#

Returns or imports the provided module.

core.transformer.spec_utils.build_module(
spec_or_module: Union[core.transformer.spec_utils.ModuleSpec, type],
*args,
**kwargs,
)#

Builds an instance of the module from the spec.

Parameters:
  • spec_or_module – The module spec or module class to build.

  • *args – Positional arguments to be passed to the module init.

  • **kwargs – Keyword arguments to be passed to the module init.