def test_checkpoint(self, valid_tree): model = Model('my-producer', 'py_pa', '1.0.0', 'my-model', 'my-model-id', valid_tree / 'my_config_file.yaml', {'my_param': 'my_value'}) assert len(model.checkpoint_collection) == 0 checkpoint_1 = Checkpoint( 'first', valid_tree / 'data' / 'checkpoints' / '1.weight', 1) checkpoint_6 = Checkpoint( 'sixth', valid_tree / 'data' / 'checkpoints' / '6.weight', 6) model.add_checkpoint(checkpoint_1) assert len(model.checkpoint_collection) == 1 assert model.checkpoint_collection['first'] == checkpoint_1 model.add_checkpoint(checkpoint_6) assert len(model.checkpoint_collection) == 2 assert model.checkpoint_collection['sixth'] == checkpoint_6 model = Model('my-producer', 'py_pa', '1.0.0', 'my-model', 'my-model-id', valid_tree / 'my_config_file.yaml', {'my_param': 'my_value'}) assert len(model.checkpoint_collection) == 0 checkpoint_1 = Checkpoint( 'first', valid_tree / 'data' / 'checkpoints' / '1.weight', 1) checkpoint_6 = Checkpoint( 'sixth', valid_tree / 'data' / 'checkpoints' / '6.weight', 6) model.add_checkpoint(checkpoint_1, checkpoint_6) assert len(model.checkpoint_collection) == 2 assert model.checkpoint_collection['first'] == checkpoint_1 assert model.checkpoint_collection['sixth'] == checkpoint_6
def test_load_extra(self, valid_tree_extra): reference_model = Model('a_producer_name', 'py_pa', '1.0.0', 'my_model', 'some_id', valid_tree_extra / 'my_config_file.yaml', {}) reference_model._initialisation = Model( 'a_producer_name', 'py_pa', '1.0.0', 'my_init_model', 'some_init_id', valid_tree_extra / 'data' / 'initialisation' / 'my_config_file.yaml', {}) reference_model.initialisation._initialisation = \ Checkpoint('my_init_file', valid_tree_extra / 'data' / 'initialisation' / 'data' / 'initialisation' / 'init.weight', hash='d41d8cd98f00b204e9800998ecf8427e') checkpoint_1 = Checkpoint(1, valid_tree_extra / 'data' / 'checkpoints' / '1.weight', 3, hash='d41d8cd98f00b204e9800998ecf8427e') checkpoint_6 = Checkpoint(6, valid_tree_extra / 'data' / 'checkpoints' / '6.weight', 10, hash='cfcd208495d565ef66e7dff9f98764da') init_checkpoint_6 = Checkpoint(6, epoch=10, hash='cfcd208495d565ef66e7dff9f98764da') init_checkpoint_7 = Checkpoint(7, epoch=9, hash='cfcd208495d565ef66e7dff9f98764da') reference_model.add_checkpoint(checkpoint_1, checkpoint_6) reference_model.initialisation.add_checkpoint(init_checkpoint_6, init_checkpoint_7) reference_model.training = Training( **{ 'status': 'finished', 'start_epoch': 0, 'start_time': 0, 'latest_epoch': 10, 'latest_time': 10, 'end_epoch': 10, 'end_time': 10 }) reference_model.initialisation.training = Training( **{ 'status': 'finished', 'start_epoch': 0, 'start_time': 0, 'latest_epoch': 10, 'latest_time': 10, 'end_epoch': 10, 'end_time': 10 }) assert _model_equal(Model.load(valid_tree_extra), reference_model)