Skip to main content

bitfount_model_migration

Migration code for converting between PyTorchBitfountModels v1 and v2.

Module

Functions

convert_bitfount_model_class_to_v2

def convert_bitfount_model_class_to_v2(    old_bitfount_model_cls: type[PyTorchBitfountModel[T_DTYPE]],)> type[PyTorchBitfountModelv2[T_DTYPE]]:

Convert a PyTorchBitfountModel class to a PyTorchBitfountModelv2 class.

Moves methods around to make them match with the new form, deletes others and reconstitutes the class with PyTorchBitfountModelv2 as one of its parent classes instead of PyTorchBitfountModel.

Arguments

  • old_bitfount_model_cls: The class (not instance) of the old form model.

Returns A "Converted" class which is the original class converted to be a subclass of PyTorchBitfountModelv2 instead.

maybe_convert_bitfount_model_class_to_v2

def maybe_convert_bitfount_model_class_to_v2(    model_cls: type[BitfountModel] | type[PyTorchBitfountModel[T_DTYPE]],)> type[BitfountModel] | type[PyTorchBitfountModelv2[T_DTYPE]]:

If model_cls is a PyTorchBitfountModel, convert to PyTorchBitfountModelv2.