Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Move imports to inside of CACHE_MODELS=true condition (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-gardner authored Apr 25, 2018
1 parent 53ae735 commit a869e0b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/cache_models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env python

import os
import sys

sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir))))
from allennlp.commands.serve import DEFAULT_MODELS
from allennlp.common.file_utils import cached_path

value = os.environ.get('CACHE_MODELS', 'false')
if value.lower() == "true":
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir))))
from allennlp.commands.serve import DEFAULT_MODELS
from allennlp.common.file_utils import cached_path
models = DEFAULT_MODELS.items()
print("CACHE_MODELS is '%s'. Downloading %i models." % (value, len(models)))
for i, (model, url) in enumerate(models):
Expand Down

0 comments on commit a869e0b

Please sign in to comment.