eric-haibin-lin commented on a change in pull request #17372: [BUGFIX] fix
model zoo parallel download
URL: https://github.com/apache/incubator-mxnet/pull/17372#discussion_r370324247
##########
File path: python/mxnet/gluon/model_zoo/model_store.py
##########
@@ -103,16 +105,19 @@ def get_model_file(name,
root=os.path.join(base.data_dir(), 'models')):
util.makedirs(root)
- zip_file_path = os.path.join(root, file_name+'.zip')
repo_url = os.environ.get('MXNET_GLUON_REPO', apache_repo_url)
if repo_url[-1] != '/':
repo_url = repo_url + '/'
- download(_url_format.format(repo_url=repo_url, file_name=file_name),
- path=zip_file_path,
- overwrite=True)
- with zipfile.ZipFile(zip_file_path) as zf:
- zf.extractall(root)
- os.remove(zip_file_path)
+
+ with tempfile.NamedTemporaryFile(dir=root) as zip_file:
+ download(_url_format.format(repo_url=repo_url, file_name=file_name),
+ path=zip_file.name, overwrite=True, inplace=True)
Review comment:
I think @apeforest suggested using `TemporaryFile` because it can be
automatically cleaned up. If we need to cleanup ourselves, then there's not
much difference using it or not
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services