Skip to content

Commit

Permalink
Change the cached model checking logic (onnx#545)
Browse files Browse the repository at this point in the history
* Change the cached model checking logic

* Move the old folder, instead of deleting
  • Loading branch information
houseroad committed Feb 22, 2018
1 parent 7966daf commit 05122fe
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion onnx/backend/test/runner/__init__.py
Expand Up @@ -8,6 +8,7 @@
import glob
import os
import re
import shutil
import tarfile
import tempfile
import unittest
Expand Down Expand Up @@ -151,7 +152,16 @@ def _prepare_model_data(self, model_test):
models_dir = os.getenv('ONNX_MODELS',
os.path.join(onnx_home, 'models'))
model_dir = os.path.join(models_dir, model_test.model_name)
if not os.path.exists(model_dir):
if not os.path.exists(os.path.join(model_dir, 'model.onnx')):
if os.path.exists(model_dir):
bi = 0
while True:
dest = '{}.old.{}'.format(model_dir, bi)
if os.path.exists(dest):
bi += 1
continue
shutil.move(model_dir, dest)
break
os.makedirs(model_dir)
url = 'https://s3.amazonaws.com/download.onnx/models/{}.tar.gz'.format(
model_test.model_name)
Expand Down

0 comments on commit 05122fe

Please sign in to comment.