Extending the libraryΒΆ

In order to extend the library, you need to register your classes and functions; it is done in two steps.

  1. Decorate your Component (or DatasetReader, or DataLearningIterator, or DataFittingIterator) using register() and/or metrics function using register_metric().
  2. Rebuild the registry running from DeepPavlov root directory:
python -m utils.prepare.registry

This script imports all the modules in deeppavlov package, builds the registry from them and writes it to a file.

However, it is possible to use some classes and functions inside configuration files without registering them explicitly. There are two options available here:

  • instead of {"name": "registered_component_name"} in config file use key-value pair similar to {"class": "my_package.my_module:MyClass"}
  • if your classes/functions are properly decorated but not included in the registry, use "metadata" section of your config file specifying imports as "metadata": {"imports": ["my_local_package.my_module", "global_package.module"]}; then the second step described above will be unnecessary (local packages are imported from the current working directory).