Spaces:
Runtime error
Runtime error
enable sync every 24h
Browse files
app.py
CHANGED
@@ -20,9 +20,9 @@ import boto3
|
|
20 |
|
21 |
from db import Database
|
22 |
|
23 |
-
AWS_ACCESS_KEY_ID = os.getenv('
|
24 |
-
AWS_SECRET_KEY = os.getenv('
|
25 |
-
AWS_S3_BUCKET_NAME = os.getenv('
|
26 |
|
27 |
|
28 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
@@ -176,11 +176,13 @@ async def sync_data():
|
|
176 |
"class": classifier
|
177 |
})])
|
178 |
db.commit()
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
184 |
|
185 |
app = FastAPI()
|
186 |
app.add_middleware(
|
@@ -228,8 +230,8 @@ def read_root():
|
|
228 |
return "Just a bot to sync data from diffusers gallery"
|
229 |
|
230 |
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
|
|
20 |
|
21 |
from db import Database
|
22 |
|
23 |
+
AWS_ACCESS_KEY_ID = os.getenv('MY_AWS_ACCESS_KEY_ID')
|
24 |
+
AWS_SECRET_KEY = os.getenv('MY_AWS_SECRET_KEY')
|
25 |
+
AWS_S3_BUCKET_NAME = os.getenv('MY_AWS_S3_BUCKET_NAME')
|
26 |
|
27 |
|
28 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
|
176 |
"class": classifier
|
177 |
})])
|
178 |
db.commit()
|
179 |
+
|
180 |
+
if(len(models) > 0):
|
181 |
+
print("Updating repository")
|
182 |
+
subprocess.Popen(
|
183 |
+
"git add . && git commit --amend -m 'update' && git push --force", cwd=DB_FOLDER, shell=True)
|
184 |
+
else:
|
185 |
+
print("No new models found")
|
186 |
|
187 |
app = FastAPI()
|
188 |
app.add_middleware(
|
|
|
230 |
return "Just a bot to sync data from diffusers gallery"
|
231 |
|
232 |
|
233 |
+
@app.on_event("startup")
|
234 |
+
@repeat_every(seconds=60 * 60 * 24, wait_first=False)
|
235 |
+
async def repeat_sync():
|
236 |
+
await sync_data()
|
237 |
+
return "Synced data to huggingface datasets"
|