Skip to content

Generics #72

@bpiwowar

Description

@bpiwowar

Currently, generics are not well supported in XPM, which prevents some basic type checking before running tasks – and this in turn can lead to errors that will only be detected when running the task. There are two things to do here:

  1. Support simple generic support (i.e. Param[MyConfig[int]])
  2. Support multi-field generic support

For (2), here is an example

Data = TypeVar("Data", bound=Base)

class Supervised(Base, Generic[Data]):
    train: Param[Data]
    """The training dataset"""

    validation: Param[Optional[Data]] = None
    """The validation dataset (optional)"""

    test: Param[Optional[Data]] = None
    """The training optional"""

In that case, the three fields (train, validation, and test) should have the same base class (constrained by the TypeVar specification)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions