allenai / allennlp

An open-source NLP research library, built on PyTorch.
http://www.allennlp.org
Apache License 2.0
11.73k stars 2.24k forks source link

how to use the test utils? #1983

Closed susht3 closed 5 years ago

susht3 commented 5 years ago

i implement some test utils for my predictors, but i do not know how to use the test class

susht3 commented 5 years ago

yeap,i know how to test, i run "python -m pytest.ini", but it seems not to register the predictor, because i get this error: allennlp.common.checks.ConfigurationError: 'bidaf_baseline is not a registered name for Predictor'

but i have register bidaf_baseline in my code: @Predictor.register('bidaf_baseline') class BidafPredictor(Predictor):

matt-gardner commented 5 years ago

In your test file, you need to be sure you import the class before trying to use it through the registry, otherwise you'll get that error.

susht3 commented 5 years ago

In your test file, you need to be sure you import the class before trying to use it through the registry, otherwise you'll get that error.

thanks a lot, i import the class then i can run it, but now i get a new error that the test file is killed: Python 3.6.2, pytest-3.8.2, py-1.6.0, pluggy-0.7.1 rootdir: /data1/susht3/workspace/allen, inifile: pytest.ini code/tests/models/my_bidaf_test.py FKilled my_bidaf_test.py is copy from allennlp and change the filename

schmmd commented 5 years ago

@susht3 it looks like your first test failed (see the F in FKilled). Hopefully the exception is tracked elsewhere.

schmmd commented 5 years ago

@susht3 it seems like you've moved on from this, but please do re-open if you have additional context (such as the exception that killed your tests).