MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / _maybe_download

Function _maybe_download

neural_network/input_data.py:247–266  ·  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

245
246@deprecated(None, "Please write your own downloading logic.")
247def _maybe_download(filename, work_directory, source_url):
248 """Download the data from source url, unless it's already here.
249
250 Args:
251 filename: string, name of the file in the directory.
252 work_directory: string, path to working directory.
253 source_url: url to download from if file doesn't exist.
254
255 Returns:
256 Path to resulting file.
257 """
258 if not gfile.Exists(work_directory):
259 gfile.MakeDirs(work_directory)
260 filepath = os.path.join(work_directory, filename)
261 if not gfile.Exists(filepath):
262 urllib.request.urlretrieve(source_url, filepath) # noqa: S310
263 with gfile.GFile(filepath) as f:
264 size = f.size()
265 print("Successfully downloaded", filename, size, "bytes.")
266 return filepath
267
268
269@deprecated(None, "Please use alternatives such as: tensorflow_datasets.load('mnist')")

Callers 1

read_data_setsFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected