ksuit.factory.dataset_factory

Classes

DatasetFactory

Base factory. Implements base structures for creating a single object, a list of objects and a dict

Module Contents

class ksuit.factory.dataset_factory.DatasetFactory(dataset_wrapper_factory=None)

Bases: ksuit.factory.base.Factory

Base factory. Implements base structures for creating a single object, a list of objects and a dict of objects. The main difference between these methods are the default return values. As python does not like using an empty list/dict as default value for an argument, arguments are by default often None. By differentiating between these three types, one avoids none checks whenever the factory is called. - create: creates an object. - create_list: creates a list of objects. - create_dict: creates a dict of objects.

For example, creating a list ``` class Example:

def __init__(self, callbacks: list[Callback] | None = None)

# automatic none check in create_list (this is how FactoryBase is implemented) self.callbacks = create_list(callbacks) # required none check after creating the list (this is how one could implement it without create_list) self.callbacks = create(callbacks) or []

```

Parameters:

dataset_wrapper_factory (ksuit.factory.base.Factory | None)

dataset_wrapper_factory
instantiate(object_config=None, **_)

Instantiates the dataset either based on dataset_config or from the checkpoint.

Parameters:

object_config (Any)

Return type:

object