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

Single machine download script and downloaded files check #60

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions data_prep/arxiv/run_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ def run(self, input_file: str, tgt_dir: pathlib.Path, max_files=-1):
break

def __download_file(self, key, tgt_dir: pathlib.Path):
filename = pathlib.Path(tgt_dir, key)
print('\nDownloading s3://arxiv/{} t'
'o {}...'.format(key, pathlib.Path(tgt_dir, key)))

'o {}...'.format(key, filename))

if filename.exists():
print(f'File {filename} already exists, skipping download...')
return

print('\nDownloading s3://arxiv/{} to {}...'.format(key, filename))

try:
self.s3resource.meta.client.download_file(
Bucket='arxiv',
Expand Down
26 changes: 26 additions & 0 deletions data_prep/arxiv/scripts/arxiv-single-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# for download partitions
# for single machine download

set -e

# Depend on your CPU
WORKERS=8

export DATA_DIR="./data/arxiv"

# setup partitions
python run_download.py --aws_config aws_config.ini --workers $WORKERS --target_dir $DATA_DIR --setup

# Function to process a file
process_file() {
INPUT_FILE="$1"
echo "Processing input file is ${INPUT_FILE}"
python run_download.py --aws_config aws_config.ini --target_dir $DATA_DIR --input $INPUT_FILE
}

# Export the function to be used by xargs
export -f process_file

ls ${DATA_DIR}/partitions/*.txt | xargs -I {} -P ${WORKERS} -n 1 bash -c 'process_file "$@"' _ {}