Saving a trainer created by HuggingFaceNmtModel.create_trainer raises an AttributeError. Calling save() on the trainer is enough to trigger it. The trained model is not copied to the model path, and the model's engine is not reset.
Affected: _Trainer in machine/translation/huggingface/hugging_face_nmt_model.py.
Versions: main and #363. I found this by reading the code. I have not reproduced it.
Expected: save() saves the model, copies it to the model path, and resets the engine.
Actual: AttributeError: 'str' object has no attribute 'training_args'
Cause: _Trainer.__init__ assigns self._model = model and then calls super().__init__. HuggingFaceNmtModelTrainer.__init__ sets self._model to its first argument, which is the parent model name. save() then reads self._model.training_args from a str. Storing the HuggingFaceNmtModel under a different attribute name would fix it.
Test: no test covers HuggingFaceNmtModel.
Saving a trainer created by
HuggingFaceNmtModel.create_trainerraises anAttributeError. Callingsave()on the trainer is enough to trigger it. The trained model is not copied to the model path, and the model's engine is not reset.Affected:
_Trainerinmachine/translation/huggingface/hugging_face_nmt_model.py.Versions:
mainand #363. I found this by reading the code. I have not reproduced it.Expected:
save()saves the model, copies it to the model path, and resets the engine.Actual:
AttributeError: 'str' object has no attribute 'training_args'Cause:
_Trainer.__init__assignsself._model = modeland then callssuper().__init__.HuggingFaceNmtModelTrainer.__init__setsself._modelto its first argument, which is the parent model name.save()then readsself._model.training_argsfrom astr. Storing theHuggingFaceNmtModelunder a different attribute name would fix it.Test: no test covers
HuggingFaceNmtModel.