Skip to content

Commit

Permalink
[MRG] Add random string as suffix of the temp folder name (#325)
Browse files Browse the repository at this point in the history
* Change Image class document

* change text documentation

* change parameters to attributes

* change doc to google format

* change image supervised doc Attributes

*  change text supervised doc with attributes

* fix download pre train doc

* fix some small issues

* fix the line break

* Add random string to the temp folder generator
  • Loading branch information
boyuangong authored and haifeng-jin committed Nov 16, 2018
1 parent 4e59e6e commit ce72d39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions autokeras/utils.py
Expand Up @@ -12,7 +12,8 @@
from skimage.transform import resize
import torch
import subprocess

import string
import random
from autokeras.constant import Constant


Expand Down Expand Up @@ -86,8 +87,11 @@ def get_device():

def temp_folder_generator():
"""Create and return a temporary directory with the path name '/temp_dir_name/autokeras' (E:g:- /tmp/autokeras)."""
chars = string.ascii_uppercase + string.digits
size = 6
sys_temp = tempfile.gettempdir()
path = os.path.join(sys_temp, 'autokeras')
random_suffix = ''.join(random.choice(chars) for _ in range(size))
path = os.path.join(sys_temp, 'autokeras_' + random_suffix)
ensure_dir(path)
return path

Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Expand Up @@ -37,7 +37,7 @@ def get(self, key):
def test_temp_folder_generator(_):
clean_dir(TEST_TEMP_DIR)
path = temp_folder_generator()
assert path == "tests/resources/temp/autokeras"
assert path.find("tests/resources/temp/autokeras") != -1
clean_dir(TEST_TEMP_DIR)


Expand Down

0 comments on commit ce72d39

Please sign in to comment.