PureVersation / check_sync.py
toecm's picture
Update check_sync.py
0651a98 verified
# This is a standalone reconciliation utility script that helps verify if the
# local fallback system actually worked and successfully pushed those temporary
# entries to the cloud backup. It checks the live sync status of the repository
from huggingface_hub import HfApi
from datetime import datetime
def check_dataset_sync(hf_token=None):
api = HfApi(token=hf_token)
repo_id = "toecm/PureChain_Dataset"
print(f"🔍 Checking sync status for cloud repository: {repo_id}\n")
try:
# 1. Check if the files actually exist in the cloud
files = api.list_repo_files(repo_id=repo_id, repo_type="dataset")
print("📁 Files currently synced in the cloud:")
for f in files:
if f.endswith('.csv') or f.endswith('.json'):
print(f" └─ {f}")
# 2. Check the most recent automated pushes (commits)
print("\n🕒 Recent Sync History:")
commits = api.list_repo_commits(repo_id=repo_id, repo_type="dataset")
# Display the last 3 pushes
for commit in commits[:3]:
# Formatting the timestamp for readability
time_str = commit.created_at.strftime("%Y-%m-%d %H:%M:%S")
print(f" [{time_str}] {commit.title}")
except Exception as e:
print(f"❌ Sync Check Failed: {e}")
print("Make sure the repository is created and your token has Read access.")
import os# This is a standalone reconciliation utility script that helps verify if the
# local fallback system actually worked and successfully pushed those temporary
# entries to the cloud backup. It checks the live sync status of the repository
from huggingface_hub import HfApi
from datetime import datetime
def check_dataset_sync(hf_token=None):
api = HfApi(token=hf_token)
repo_id = "toecm/PureChain_Dataset"
print(f"🔍 Checking sync status for cloud repository: {repo_id}\n")
try:
# 1. Check if the files actually exist in the cloud
files = api.list_repo_files(repo_id=repo_id, repo_type="dataset")
print("📁 Files currently synced in the cloud:")
for f in files:
if f.endswith('.csv') or f.endswith('.json'):
print(f" └─ {f}")
# 2. Check the most recent automated pushes (commits)
print("\n🕒 Recent Sync History:")
commits = api.list_repo_commits(repo_id=repo_id, repo_type="dataset")
# Display the last 3 pushes
for commit in commits[:3]:
# Formatting the timestamp for readability
time_str = commit.created_at.strftime("%Y-%m-%d %H:%M:%S")
print(f" [{time_str}] {commit.title}")
except Exception as e:
print(f"❌ Sync Check Failed: {e}")
print("Make sure the repository is created and your token has Read access.")
# Run the checker
check_dataset_sync("HF_TOKEN")
# Run the checker
check_dataset_sync(os.environ.get("HF_TOKEN"))