facebookresearch / ParlAI

A framework for training and evaluating AI models on a variety of openly available dialogue datasets.
https://parl.ai
MIT License
10.49k stars 2.1k forks source link

Following HuggingFace - ModuleNotFoundError: No module named 'parlai.zoo.convai2.build' #2380

Closed ghost closed 4 years ago

ghost commented 4 years ago

Bug description Everytime I run "python ../convai_evaluation.py --eval_type hits@1" it throws an error.

Reproduction steps

git clone https://github.com/huggingface/transfer-learning-conv-ai
cd transfer-learning-conv-ai
pip install -r requirements.txt
python -m spacy download en
git clone https://github.com/facebookresearch/ParlAI.git
cd ParlAI
python setup.py develop
python ../convai_evaluation.py --eval_type hits@1

Expected behavior Downloads and evaluates the fine-tuned model on hits@1

Logs

INFO:F:\AchilliosOmega\transfer-learning-conv-ai\convai_evaluation.py:Build BPE prefix dictionary
Traceback (most recent call last):
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\parlai\core\build_data.py", line 419, in modelzoo_path
    my_module = importlib.import_module(module_name)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'parlai.zoo.convai2.build'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\parlai\core\build_data.py", line 426, in modelzoo_path
    my_module = importlib.import_module(module_name_)
  File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'parlai.zoo.convai2.build'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "convai_evaluation.py", line 239, in <module>
    eval_fct(opt)
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\projects\convai2\eval_hits.py", line 29, in eval_hits
    report = eval_model(opt, print_parser)
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\parlai\scripts\eval_model.py", line 166, in eval_model
    agent = create_agent(opt, requireModelExists=True)
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\parlai\core\agents.py", line 399, in create_agent
    model = model_class(opt)
  File "F:\AchilliosOmega\transfer-learning-conv-ai\convai_evaluation.py", line 73, in __init__
    convai_dict = build_dict()
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\projects\convai2\build_dict.py", line 35, in build_dict
    opt = parser.parse_args(args="")
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\parlai\core\params.py", line 975, in parse_args
    self._process_args_to_opts(args)
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\parlai\core\params.py", line 942, in _process_args_to_opts
    self.opt.get('datapath'), self.opt['dict_file']
  File "f:\achilliosomega\transfer-learning-conv-ai\parlai\parlai\core\build_data.py", line 431, in modelzoo_path
    f'Could not find pretrained model in {module_name} or {module_name_}.'
ImportError: Could not find pretrained model in parlai.zoo.convai2.build or parlai.zoo.convai2.build.
ghost commented 4 years ago

https://github.com/huggingface/transfer-learning-conv-ai#running-convai2-evaluation-scripts

stephenroller commented 4 years ago

Thanks for reporting. As a temporary fix, you can replace that ImportError on line 431 with pass and it should continue okay.

danielriddell21 commented 4 years ago

I have this issue too, is this a known issue?

stephenroller commented 4 years ago

This is the result of a recent change which tried to strengthen requirements of zoo files (part of #2327). I'm wondering if we should undo that -- it was behavior that wasn't really desirable. @bobland1 can you say more? Are you specifically using the HF repo?

ghost commented 4 years ago

I put pass and it carried on and evaluated fine. Ty

danielriddell21 commented 4 years ago

It was the exact same issue as @memologyserver. Putting pass fixed it for me

stephenroller commented 4 years ago

The root cause solution is to create parlai/zoo/convai2/build.py and have it download the dict file.

stephenroller commented 4 years ago

I've decided to archive the former convai2 code (#2420). The last supported version is tagged as convai2archive.

$ git checkout convai2archive.