Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
enable scheduler
Browse files
app.py
CHANGED
@@ -158,8 +158,8 @@ async def sync_data():
|
|
158 |
print(model['id'], model)
|
159 |
db.commit()
|
160 |
print("Updating repository")
|
161 |
-
|
162 |
-
|
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 |
-
|
178 |
-
|
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 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
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"
|