From eb20a9ad620a7cd3a96fe41c06d5978e49be3bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Hukkel=C3=A5s?= Date: Tue, 5 Feb 2019 14:16:48 +0100 Subject: [PATCH 1/3] add: download directory to args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Author: Håkon Hukkelås --- download_ffhq.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/download_ffhq.py b/download_ffhq.py index e516335bf..3183ca3df 100755 --- a/download_ffhq.py +++ b/download_ffhq.py @@ -56,9 +56,10 @@ #---------------------------------------------------------------------------- -def download_file(session, file_spec, stats, chunk_size=128, num_attempts=10): +def download_file(session, file_spec, stats, chunk_size=128, num_attempts=10, base_directory=""): file_path = file_spec['file_path'] file_url = file_spec['file_url'] + file_path = os.path.join(base_directory, file_path) file_dir = os.path.dirname(file_path) tmp_path = file_path + '.tmp.' + uuid.uuid4().hex if file_dir: @@ -384,6 +385,7 @@ def run_cmdline(argv): parser.add_argument('--timing_window', help='samples for estimating download eta (default: 50)', type=int, default=50, metavar='LEN') parser.add_argument('--chunk_size', help='chunk size for each download thread (default: 128)', type=int, default=128, metavar='KB') parser.add_argument('--num_attempts', help='number of download attempts per file (default: 10)', type=int, default=10, metavar='NUM') + parser.add_argument('--base_directory', help="directory to save the downloaded files (default: current folder", default="") args = parser.parse_args() if not args.tasks: From 89ca66408510d7e16e35ebb1f5cdaf54b5b8df40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Hukkel=C3=A5s?= Date: Tue, 5 Feb 2019 14:22:06 +0100 Subject: [PATCH 2/3] fix: minor typo --- download_ffhq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download_ffhq.py b/download_ffhq.py index 3183ca3df..976cf7dbd 100755 --- a/download_ffhq.py +++ b/download_ffhq.py @@ -385,7 +385,7 @@ def run_cmdline(argv): parser.add_argument('--timing_window', help='samples for estimating download eta (default: 50)', type=int, default=50, metavar='LEN') parser.add_argument('--chunk_size', help='chunk size for each download thread (default: 128)', type=int, default=128, metavar='KB') parser.add_argument('--num_attempts', help='number of download attempts per file (default: 10)', type=int, default=10, metavar='NUM') - parser.add_argument('--base_directory', help="directory to save the downloaded files (default: current folder", default="") + parser.add_argument('--base_directory', help="directory to save the downloaded files (default: current folder)", default="") args = parser.parse_args() if not args.tasks: From 42c61dee75aaceef9acadfe3df065a2c95fb961c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Hukkel=C3=A5s?= Date: Tue, 5 Feb 2019 14:39:26 +0100 Subject: [PATCH 3/3] refactor: change argument to download_directory --- download_ffhq.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/download_ffhq.py b/download_ffhq.py index 976cf7dbd..2c32fad4d 100755 --- a/download_ffhq.py +++ b/download_ffhq.py @@ -56,10 +56,10 @@ #---------------------------------------------------------------------------- -def download_file(session, file_spec, stats, chunk_size=128, num_attempts=10, base_directory=""): +def download_file(session, file_spec, stats, chunk_size=128, num_attempts=10, download_directory=""): file_path = file_spec['file_path'] file_url = file_spec['file_url'] - file_path = os.path.join(base_directory, file_path) + file_path = os.path.join(download_directory, file_path) file_dir = os.path.dirname(file_path) tmp_path = file_path + '.tmp.' + uuid.uuid4().hex if file_dir: @@ -385,7 +385,7 @@ def run_cmdline(argv): parser.add_argument('--timing_window', help='samples for estimating download eta (default: 50)', type=int, default=50, metavar='LEN') parser.add_argument('--chunk_size', help='chunk size for each download thread (default: 128)', type=int, default=128, metavar='KB') parser.add_argument('--num_attempts', help='number of download attempts per file (default: 10)', type=int, default=10, metavar='NUM') - parser.add_argument('--base_directory', help="directory to save the downloaded files (default: current folder)", default="") + parser.add_argument('--download_directory', help="directory to save the downloaded files (default: current folder)", default="") args = parser.parse_args() if not args.tasks: