Skip to content

[Task Registry] How to register generic bas class #147

Description

@yizhuoliang

Inside python/cornserve/services/task_registry/task_class_registry.py, when we register the unit tasks, I check if the input/output types are valid input/output classes. But now I have to do a special treatment for LLMBaseUnitTask, whose input/output classes are generic. So I patch it with dummy input/outputs (see below code block). Maybe this is not the right way, but I'm not sure if just ignore the missing classes can lead to other side-effects.

if task_input_cls is None or task_output_cls is None:
                # Special case:  the  "LLMBaseUnitTask" is a generic task class
                # so it doesn't have concrete input/output types,
                # so to let it goes through, we register it with dummy TaskInput/Output types
                # TODO: Such special case is definitely not legetimate, what should we do instead?
                if task_class_name == "LLMBaseUnitTask":
                    from cornserve.task.base import TaskInput as DummyInput  # noqa: PLC0415
                    from cornserve.task.base import TaskOutput as DummyOutput  # noqa: PLC0415

                    task_input_cls, task_output_cls = DummyInput, DummyOutput
                else:
                    raise ValueError(
                        f"Task class {task_class_name} missing generic type arguments. "
                        f"Expected format: class {task_class_name}(UnitTask[InputType, OutputType])"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions