Upload src/download_from_hf.py with huggingface_hub
Browse files- src/download_from_hf.py +5 -6
src/download_from_hf.py
CHANGED
|
@@ -12,7 +12,6 @@ def download_from_huggingface(repo_name, token):
|
|
| 12 |
# Create necessary directories
|
| 13 |
os.makedirs('cbow/checkpoints', exist_ok=True)
|
| 14 |
os.makedirs('checkpoints', exist_ok=True)
|
| 15 |
-
os.makedirs('vocabulary', exist_ok=True)
|
| 16 |
os.makedirs('data', exist_ok=True)
|
| 17 |
os.makedirs('config', exist_ok=True)
|
| 18 |
os.makedirs('src', exist_ok=True)
|
|
@@ -65,18 +64,18 @@ def download_from_huggingface(repo_name, token):
|
|
| 65 |
except Exception as e:
|
| 66 |
print(f"Error downloading {data_file}: {e}")
|
| 67 |
|
| 68 |
-
# Download
|
| 69 |
try:
|
| 70 |
-
|
| 71 |
repo_id=repo_name,
|
| 72 |
repo_type="model",
|
| 73 |
token=token,
|
| 74 |
local_dir="cbow",
|
| 75 |
-
allow_patterns="
|
| 76 |
)
|
| 77 |
-
print("Downloaded
|
| 78 |
except Exception as e:
|
| 79 |
-
print(f"Error downloading
|
| 80 |
|
| 81 |
# Download configuration files
|
| 82 |
config_files = ['sweep.yaml', 'requirements.txt']
|
|
|
|
| 12 |
# Create necessary directories
|
| 13 |
os.makedirs('cbow/checkpoints', exist_ok=True)
|
| 14 |
os.makedirs('checkpoints', exist_ok=True)
|
|
|
|
| 15 |
os.makedirs('data', exist_ok=True)
|
| 16 |
os.makedirs('config', exist_ok=True)
|
| 17 |
os.makedirs('src', exist_ok=True)
|
|
|
|
| 64 |
except Exception as e:
|
| 65 |
print(f"Error downloading {data_file}: {e}")
|
| 66 |
|
| 67 |
+
# Download all tokenizer files from cbow directory
|
| 68 |
try:
|
| 69 |
+
cbow_files = snapshot_download(
|
| 70 |
repo_id=repo_name,
|
| 71 |
repo_type="model",
|
| 72 |
token=token,
|
| 73 |
local_dir="cbow",
|
| 74 |
+
allow_patterns="cbow/*.pkl"
|
| 75 |
)
|
| 76 |
+
print("Downloaded CBOW tokenizer files")
|
| 77 |
except Exception as e:
|
| 78 |
+
print(f"Error downloading CBOW tokenizer files: {e}")
|
| 79 |
|
| 80 |
# Download configuration files
|
| 81 |
config_files = ['sweep.yaml', 'requirements.txt']
|