mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-29 19:06:23 +02:00
Create download_data.py
Need to run the script in the aflow/data path
This commit is contained in:
parent
c194415b35
commit
fe3fca514a
1 changed files with 36 additions and 0 deletions
36
examples/aflow/data/download_data.py
Normal file
36
examples/aflow/data/download_data.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import os
|
||||
import requests
|
||||
import tarfile
|
||||
from tqdm import tqdm
|
||||
|
||||
def download_file(url, filename):
|
||||
response = requests.get(url, stream=True)
|
||||
total_size = int(response.headers.get('content-length', 0))
|
||||
block_size = 1024
|
||||
progress_bar = tqdm(total=total_size, unit='iB', unit_scale=True)
|
||||
|
||||
with open(filename, 'wb') as file:
|
||||
for data in response.iter_content(block_size):
|
||||
size = file.write(data)
|
||||
progress_bar.update(size)
|
||||
progress_bar.close()
|
||||
|
||||
def extract_tar_gz(filename, extract_path):
|
||||
with tarfile.open(filename, 'r:gz') as tar:
|
||||
tar.extractall(path=extract_path)
|
||||
|
||||
url = "https://drive.google.com/uc?export=download&id=1tXp5cLw89egeKRwDuood2TPqoEWd8_C0"
|
||||
filename = "aflow_data.tar.gz"
|
||||
extract_path = "./"
|
||||
|
||||
print("Downloading data file...")
|
||||
download_file(url, filename)
|
||||
|
||||
print("Extracting data file...")
|
||||
extract_tar_gz(filename, extract_path)
|
||||
|
||||
print("Download and extraction completed.")
|
||||
|
||||
# Clean up the compressed file
|
||||
os.remove(filename)
|
||||
print(f"Removed {filename}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue