As mentioned in this tutorial, if you want to use your own model you have to add the --include-package my_library parameter when you call allennlp train, so allennlp can load and register your model class (this works).
I can't figure out how to get pytest to work with my own model though. There is no allennlp subcommand to run tests, so you have to run pytests right? On the other hand, you cannot pass --include-package my_library to pytests, or am I wrong? So I'm getting allennlp.common.checks.ConfigurationError: 'classifier not in acceptable choices for model.type' errors. When I make model.type a fully classified classname instead, I get KeyError.
Any help would be much appreciated!
In your classifier_test.py file (or whatever it's called), import your library directly. This will accomplish the same thing as --include-package passed to the allennlp script.
That worked, thanks! I added from src.models import Classifier (the class that subclasses Model) in my classifier_test.py (it isn't used in the actual test code).
Most helpful comment
In your
classifier_test.pyfile (or whatever it's called), import your library directly. This will accomplish the same thing as--include-packagepassed to theallennlpscript.