Rulga commited on
Commit
e141a67
Β·
1 Parent(s): 3011262

feat: add debug logging for syncing with Hugging Face dataset

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -239,15 +239,19 @@ def check_directory_permissions(directory):
239
  def sync_with_hf(local_path, repo_path, commit_message):
240
  """Sync local files with Hugging Face dataset"""
241
  try:
 
242
  api = HfApi()
243
 
244
- # Create repo if it doesn't exist
245
  try:
246
  api.repo_info(repo_id=DATASET_REPO, repo_type="dataset")
 
247
  except RepositoryNotFoundError:
 
248
  create_repo(DATASET_REPO, repo_type="dataset", token=HF_TOKEN)
249
 
250
  # Upload directory content
 
251
  api.upload_folder(
252
  folder_path=local_path,
253
  path_in_repo=repo_path,
@@ -257,10 +261,12 @@ def sync_with_hf(local_path, repo_path, commit_message):
257
  token=HF_TOKEN
258
  )
259
  st.toast(f"βœ… Synchronized with Hugging Face: {repo_path}", icon="πŸ€—")
 
260
 
261
  except Exception as e:
262
  error_msg = f"Failed to sync with Hugging Face: {str(e)}"
263
  st.error(error_msg)
 
264
  raise Exception(error_msg)
265
 
266
  def force_save_vector_store(vector_store):
 
239
  def sync_with_hf(local_path, repo_path, commit_message):
240
  """Sync local files with Hugging Face dataset"""
241
  try:
242
+ st.write(f"DEBUG: Starting sync with HF for {repo_path}")
243
  api = HfApi()
244
 
245
+ # Ensure the repository exists
246
  try:
247
  api.repo_info(repo_id=DATASET_REPO, repo_type="dataset")
248
+ st.write("DEBUG: Repository exists")
249
  except RepositoryNotFoundError:
250
+ st.write("DEBUG: Creating new repository")
251
  create_repo(DATASET_REPO, repo_type="dataset", token=HF_TOKEN)
252
 
253
  # Upload directory content
254
+ st.write(f"DEBUG: Uploading folder {local_path} to {repo_path}")
255
  api.upload_folder(
256
  folder_path=local_path,
257
  path_in_repo=repo_path,
 
261
  token=HF_TOKEN
262
  )
263
  st.toast(f"βœ… Synchronized with Hugging Face: {repo_path}", icon="πŸ€—")
264
+ st.write("DEBUG: Sync completed successfully")
265
 
266
  except Exception as e:
267
  error_msg = f"Failed to sync with Hugging Face: {str(e)}"
268
  st.error(error_msg)
269
+ st.write(f"DEBUG: Sync error details: {str(e)}")
270
  raise Exception(error_msg)
271
 
272
  def force_save_vector_store(vector_store):