Crash when pre-trained model is not properly loaded
🐛 Bug
In the fairseq/hub_utils.py function from_pretrained:
model_path = file_utils.load_archive_file(model_name_or_path)
# convenience hack for loading data and BPE codes from model archive
if data_name_or_path.startswith('.'):
kwargs['data'] = os.path.abspath(os.path.join(model_path, data_name_or_path))
else:
kwargs['data'] = file_utils.load_archive_file(data_name_or_path)
when the load_archive_file failed to load pre-trained model, it returns model_path as None, and os.path.join(model_path, data_name_or_path) will throw exceptions
snippet for load_archive_file
def load_archive_file(archive_file):
# redirect to the cache, if necessary
try:
resolved_archive_file = cached_path(archive_file, cache_dir=None)
except EnvironmentError:
logger.info(
"Archive name '{}' was not found in archive name list. "
"We assumed '{}' was a path or URL but couldn't find any file "
"associated to this path or URL.".format(
archive_file,
archive_file,
)
)
return None
To Reproduce
When the pre-trained model was not properly downloaded at the first place. Renaming or deleting the pre-trained model also causes the same issue.
Expected behavior
If the pre-trained model no longer resides, it should re-download the file.
Environment
- fairseq Version (0.9):
- PyTorch Version (1.4)
- OS (Ubuntu 18):
- How you installed fairseq (
pip): - Python version: 3.7
- CUDA/cuDNN version: 10.1
- GPU models and configuration:
- Any other relevant information:
Feel free to submit a PR! That said, files get downloaded to a temporary file and then copied to the actual cached path once the download has completed successfully. If the download fails to complete, I don't think this should be a problem.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!
Currently running into this issue. Has anyone found a resolution?