taesiri commited on
Commit
7f8f3ca
·
1 Parent(s): b8e4077
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -45,7 +45,9 @@ def sync_with_hub():
45
  shutil.copytree(data_dir, backup_dir)
46
 
47
  # Clone/pull latest data from hub
48
- repo_url = f"https://huggingface.co/datasets/{DATASET_REPO}"
 
 
49
  hub_data_dir = Path("hub_data")
50
 
51
  if hub_data_dir.exists():
@@ -53,9 +55,12 @@ def sync_with_hub():
53
  print("Pulling latest changes...")
54
  repo = git.Repo(hub_data_dir)
55
  origin = repo.remotes.origin
 
 
 
56
  origin.pull()
57
  else:
58
- # Clone the repo
59
  print("Cloning repository...")
60
  git.Repo.clone_from(repo_url, hub_data_dir)
61
 
 
45
  shutil.copytree(data_dir, backup_dir)
46
 
47
  # Clone/pull latest data from hub
48
+ # Use token in the URL for authentication
49
+ token = os.environ["HF_TOKEN"]
50
+ repo_url = f"https://{token}@huggingface.co/datasets/{DATASET_REPO}"
51
  hub_data_dir = Path("hub_data")
52
 
53
  if hub_data_dir.exists():
 
55
  print("Pulling latest changes...")
56
  repo = git.Repo(hub_data_dir)
57
  origin = repo.remotes.origin
58
+ # Set the new URL with token
59
+ if "https://" in origin.url:
60
+ origin.set_url(repo_url)
61
  origin.pull()
62
  else:
63
+ # Clone the repo with token
64
  print("Cloning repository...")
65
  git.Repo.clone_from(repo_url, hub_data_dir)
66