radames commited on
Commit
fe95fdf
1 Parent(s): 8964ef4

enable scheduler

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -158,8 +158,8 @@ async def sync_data():
158
  print(model['id'], model)
159
  db.commit()
160
  print("Updating repository")
161
- # subprocess.Popen(
162
- # "git add . && git commit --amend -m 'update' && git push --force", cwd=DB_FOLDER, shell=True)
163
 
164
 
165
  app = FastAPI()
@@ -172,10 +172,10 @@ app.add_middleware(
172
  )
173
 
174
 
175
- @ app.get("/sync")
176
- async def sync(background_tasks: BackgroundTasks):
177
- background_tasks.add_task(sync_data)
178
- return "Synced data to huggingface datasets"
179
 
180
 
181
  MAX_PAGE_SIZE = 30
@@ -207,8 +207,8 @@ def read_root():
207
  return "Just a bot to sync data from diffusers gallery"
208
 
209
 
210
- # @app.on_event("startup")
211
- # @repeat_every(seconds=60 * 60 * 24, wait_first=False)
212
- # async def repeat_sync():
213
- # await sync_data()
214
- # return "Synced data to huggingface datasets"
 
158
  print(model['id'], model)
159
  db.commit()
160
  print("Updating repository")
161
+ subprocess.Popen(
162
+ "git add . && git commit --amend -m 'update' && git push --force", cwd=DB_FOLDER, shell=True)
163
 
164
 
165
  app = FastAPI()
 
172
  )
173
 
174
 
175
+ # @ app.get("/sync")
176
+ # async def sync(background_tasks: BackgroundTasks):
177
+ # background_tasks.add_task(sync_data)
178
+ # return "Synced data to huggingface datasets"
179
 
180
 
181
  MAX_PAGE_SIZE = 30
 
207
  return "Just a bot to sync data from diffusers gallery"
208
 
209
 
210
+ @app.on_event("startup")
211
+ @repeat_every(seconds=60 * 60 * 24, wait_first=True)
212
+ async def repeat_sync():
213
+ await sync_data()
214
+ return "Synced data to huggingface datasets"