Skip to content

allow specifying the registry name explicitly for dynamic instantation

Wout De Nolf requested to merge manual_registry_name into main

This can be used to create wrapper tasks for anything from which we can retrieve the input and output signatures.

One example is registering a Task class for a (native) Orange widget:

def register_owwidget_task(widget_qualname):
    widget_class = import_qualname(widget_qualname)
    if not issubclass(widget_class, OWWidget):
        raise TypeError(widget_class, "expected to be a OWWidget")

    registry_name = widget_qualname + ".wrapper"
    if registry_name in Task.get_subclass_names():
        return Task.get_subclass(registry_name)

    class WrapperTask(
        Task,
        input_names=widget_class.input_names(),
        output_names=widget_class.output_names(),
        registry_name=registry_name,
    ):
        ...

The full qualifier name of WrapperTask is always the same so we need to specify it manually, in which case you are also responsible of uniqueness of course.

Another use case would be when you want to move a task class to a different module but don't want to break existing graphs.

Edited by Wout De Nolf

Merge request reports