vak.models.decorator.model

vak.models.decorator.model(family: LightningModule)[source]

Decorator that makes a vak.models.ModelFactory, given a definition of the model, and a lightning.LightningModule that represents a family of models that the new model belongs to.

The function returns a new instance of vak.models.ModelFactory, that can create new instances of the model with its from_config() and from_instances() methods.

Parameters:
  • definition (type) – The definition of the new model that will be made. A class with all the class variables required by vak.models.definition.validate(). See docstring of that function for specification. See also vak.models.definition.ModelDefinition, but note that it is not necessary to subclass ModelDefinition to define a model.

  • family (lightning.LightningModule) – The class representing the family of models that the new model will belong to. E.g., vak.models.FrameClassificationModel. Should be a subclass of lightning.LightningModule that was registered with the vak.models.registry.model_family() decorator.

Returns:

model_factory – An instance of ModelFactory, with attribute definition and family, that will be used when making new instances of the model by calling the from_config() method or the from_instances() method.

Return type:

vak.models.ModelFactory