from huggingface_hub import HfApi, HfFolder | |
import os | |
# Save your token | |
HfFolder.save_token('...') | |
api = HfApi() | |
# Local path of the folder containing the model files | |
local_folder_path = "./Dockerfiles" | |
# Define the destination path in the repository | |
repo_id = "NoQuest/LLmSave" | |
repo_type = "model" | |
print(f"Uploading {local_folder_path} to {repo_id}...") | |
# Get a list of files and their sizes | |
file_sizes = [] | |
for root, _, files in os.walk(local_folder_path): | |
for file in files: | |
file_path = os.path.join(root, file) | |
file_sizes.append((file_path, os.path.getsize(file_path))) | |
# Sort files by size (smallest to largest) | |
file_sizes.sort(key=lambda item: item[1]) | |
# Upload files in order of size | |
for file_path, size in file_sizes: | |
print(f"Adding file: {file_path} (Size: {size} bytes)") | |
api.upload_file( | |
path_or_fileobj=file_path, | |
path_in_repo=os.path.relpath(file_path, local_folder_path), | |
repo_id=repo_id, | |
repo_type=repo_type, | |
) | |
print("Upload complete!") | |
#user@r-noquest-qp-anmixtao-5pisb5tc-14d83-d7h2k:/data$ ls LLmSave/ | |
#Dockerfiles README.md models on_startup.sh | |