nouamanetazi HF staff commited on
Commit
d0af8be
1 Parent(s): 858d6d7
Files changed (1) hide show
  1. app/init.py +16 -11
app/init.py CHANGED
@@ -8,17 +8,22 @@ scheduler = None
8
 
9
  if SYNC_DB:
10
  print("Syncing DB...")
11
- download_db()
12
- # Sync local DB with remote repo every 5 minute (only if a change is detected)
13
- print(f"Scheduler created: {DB_DATASET_ID} -> {DB_PATH}")
14
- scheduler = CommitScheduler(
15
- repo_id=DB_DATASET_ID,
16
- repo_type="dataset",
17
- folder_path=Path(DB_PATH).parent,
18
- every=5,
19
- allow_patterns=DB_NAME,
20
- token=os.getenv('HF_TOKEN')
21
- )
 
 
 
 
 
22
  else:
23
  print("Creating DB...")
24
  create_db()
 
8
 
9
  if SYNC_DB:
10
  print("Syncing DB...")
11
+ try:
12
+ download_db()
13
+ # Sync local DB with remote repo every 5 minute (only if a change is detected)
14
+ print(f"Scheduler created: {DB_DATASET_ID} -> {DB_PATH}")
15
+ scheduler = CommitScheduler(
16
+ repo_id=DB_DATASET_ID,
17
+ repo_type="dataset",
18
+ folder_path=Path(DB_PATH).parent,
19
+ every=5,
20
+ allow_patterns=DB_NAME,
21
+ token=os.getenv('HF_TOKEN')
22
+ )
23
+ except Exception as e:
24
+ print(f"Error syncing DB: {e}")
25
+ print("Creating DB...")
26
+ create_db()
27
  else:
28
  print("Creating DB...")
29
  create_db()