Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix makedirs() condition in contrib. #2942

Merged
merged 1 commit into from
Apr 2, 2019
Merged

Fix makedirs() condition in contrib. #2942

merged 1 commit into from
Apr 2, 2019

Conversation

cbalint13
Copy link
Contributor

@cbalint13 cbalint13 commented Apr 1, 2019

This fix contrib.download when only the filename is specified as destination.

  • See the failure and debug below:
------------->>>>> tvm/contrib/download.py <<<<--------------
    dirpath = os.path.dirname(path)
    print ("DBG: dirpath:[%s] path:[%s]" % (dirpath,path))
    if not os.path.isdir(dirpath):
        print ("DBG: not os.path.isdir(dirpath) is [True]")
        os.makedirs(dirpath)
-------------<<<<< tvm/contrib/download.py >>>>--------------

[cbalint@tune]$ ./test_tune.py 
Downloading from url https://sample.com/nn/my.weights to my.weights
DBG: dirpath:[] path:[my.weights]
DBG: not os.path.isdir(dirpath) is [True]

Traceback (most recent call last):
  File "./test_tune.py", line 137, in <module>
    download(WEIGHTS_URL, WEIGHTS_NAME)
  File "/usr/lib64/python3.7/site-packages/tvm/contrib/download.py", line 65, in download
    os.makedirs(dirpath)
  File "/usr/lib64/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
FileNotFoundError: [Errno 2] No such file or directory: ''

@@ -59,7 +59,7 @@ def download(url, path, overwrite=False, size_compare=False, verbose=1, retries=
# Stateful start time
start_time = time.time()
dirpath = os.path.dirname(path)
if not os.path.isdir(dirpath):
if not os.path.isdir(dirpath) and not dirpath is '':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use not dirpath to check whether a string is empty.
Could you also put the non-empty check before the os.path.isdir check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as desired. There are other ways to check if empty too.

@icemelon icemelon self-assigned this Apr 1, 2019
@icemelon icemelon merged commit fbd1c16 into apache:master Apr 2, 2019
@icemelon
Copy link
Member

icemelon commented Apr 2, 2019

Thanks @cbalint13

ajtulloch pushed a commit to ajtulloch/tvm that referenced this pull request Apr 5, 2019
wweic pushed a commit to wweic/tvm that referenced this pull request Apr 7, 2019
wweic pushed a commit to wweic/tvm that referenced this pull request Apr 7, 2019
wweic pushed a commit to wweic/tvm that referenced this pull request Apr 8, 2019
wweic pushed a commit to wweic/tvm that referenced this pull request Apr 10, 2019
wweic pushed a commit to neo-ai/tvm that referenced this pull request Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants