MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / maybe_download

Function maybe_download

tensorflow/contrib/learn/python/learn/datasets/base.py:237–257  ·  view source on GitHub ↗

Download the data from source url, unless it's already here. Args: filename: string, name of the file in the directory. work_directory: string, path to working directory. source_url: url to download from if file doesn't exist. Returns: Path to resulting file.

(filename, work_directory, source_url)

Source from the content-addressed store, hash-verified

235
236@deprecated(None, 'Please write your own downloading logic.')
237def maybe_download(filename, work_directory, source_url):
238 """Download the data from source url, unless it's already here.
239
240 Args:
241 filename: string, name of the file in the directory.
242 work_directory: string, path to working directory.
243 source_url: url to download from if file doesn't exist.
244
245 Returns:
246 Path to resulting file.
247 """
248 if not gfile.Exists(work_directory):
249 gfile.MakeDirs(work_directory)
250 filepath = os.path.join(work_directory, filename)
251 if not gfile.Exists(filepath):
252 temp_file_name, _ = urlretrieve_with_retry(source_url)
253 gfile.Copy(temp_file_name, filepath)
254 with gfile.GFile(filepath) as f:
255 size = f.size()
256 print('Successfully downloaded', filename, size, 'bytes.')
257 return filepath

Callers

nothing calls this directly

Calls 5

urlretrieve_with_retryFunction · 0.85
ExistsMethod · 0.45
joinMethod · 0.45
CopyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected