Pinafore / qb

QANTA Quiz Bowl AI
MIT License
167 stars 50 forks source link

StopIteration error halts training for Python ^3.7 #92

Closed GeneralPoxter closed 3 years ago

GeneralPoxter commented 3 years ago

While trying to train the rnn guesser, I encountered the following error:

ERROR: [pid 8772] Worker Worker(salt=781876901, workers=1, host=poxter, username=poxter, pid=8772) failed    TrainGuesser(guesser_module=qanta.guesser.rnn, guesser_class=RnnGuesser, dependency_module=qanta.pipeline.guesser, dependency_class=EmptyTask, config_num=0)
Traceback (most recent call last):
  File "/home/poxter/.cache/pypoetry/virtualenvs/qanta-virId68h-py3.9/lib/python3.9/site-packages/torchtext/data/iterator.py", line 182, in __iter__
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/poxter/.cache/pypoetry/virtualenvs/qanta-virId68h-py3.9/lib/python3.9/site-packages/luigi/worker.py", line 191, in run
    new_deps = self._run_get_new_deps()
  File "/home/poxter/.cache/pypoetry/virtualenvs/qanta-virId68h-py3.9/lib/python3.9/site-packages/luigi/worker.py", line 133, in _run_get_new_deps
    task_gen = self.task.run()
  File "/home/poxter/qb/qanta/pipeline/guesser.py", line 42, in run
    guesser_instance.train(qb_dataset.training_data())
  File "/home/poxter/qb/qanta/guesser/rnn.py", line 311, in train
    train_acc, train_loss, train_time = self.run_epoch(train_iter)
  File "/home/poxter/qb/qanta/guesser/rnn.py", line 334, in run_epoch
    for batch in iterator:
RuntimeError: generator raised StopIteration

This is connected to the custom torchtext package used by the pyproject.toml, and specifically, these lines of code.

This StackOverflow post explains the issue regarding StopIteration for Python versions 3.7 and up.

I made changes in my own fork according to the corresponding lines in the current torchtext repo. On my system, these changes seem to fix the issue.

keithcallenberg commented 3 years ago

Changing that line in iterator.py fixes the issue on my system too.

EntilZha commented 3 years ago

Could you make a pull request to fix this for everyone?

GeneralPoxter commented 3 years ago

I made a modification to the pyproject.toml changing the source repo to my fork of your fork, since it appears that I cannot make pull requests directly to your fork.