Spaces:
Sleeping
Sleeping
Commit
·
02d193f
1
Parent(s):
40daf13
add email and naem for git commit
Browse files- app.py +6 -0
- src/database.py +13 -3
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
"""App for the IconEval interface."""
|
| 2 |
|
| 3 |
import os
|
|
|
|
| 4 |
from argparse import Namespace
|
| 5 |
|
| 6 |
from src.eval_server import app_main
|
|
@@ -17,6 +18,11 @@ ROUND_ID = 'r1'
|
|
| 17 |
AUTO_ALLO_NUM = int(os.environ['AUTO_ALLO_NUM'])
|
| 18 |
AUTO_COMMIT = int(os.environ.get('AUTO_COMMIT', '10'))
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
args = Namespace(
|
| 21 |
db_path=DB_PATH,
|
| 22 |
round_id=ROUND_ID,
|
|
|
|
| 1 |
"""App for the IconEval interface."""
|
| 2 |
|
| 3 |
import os
|
| 4 |
+
import subprocess
|
| 5 |
from argparse import Namespace
|
| 6 |
|
| 7 |
from src.eval_server import app_main
|
|
|
|
| 18 |
AUTO_ALLO_NUM = int(os.environ['AUTO_ALLO_NUM'])
|
| 19 |
AUTO_COMMIT = int(os.environ.get('AUTO_COMMIT', '10'))
|
| 20 |
|
| 21 |
+
USER_EMAIL = os.getenv('USER_EMAIL', '[email protected]')
|
| 22 |
+
USER_NAME = os.getenv('USER_NAME', 'Janeding')
|
| 23 |
+
subprocess.run(['git', 'config', '--global', 'user.email', USER_EMAIL], check=True)
|
| 24 |
+
subprocess.run(['git', 'config', '--global', 'user.name', USER_NAME], check=True)
|
| 25 |
+
|
| 26 |
args = Namespace(
|
| 27 |
db_path=DB_PATH,
|
| 28 |
round_id=ROUND_ID,
|
src/database.py
CHANGED
|
@@ -138,9 +138,19 @@ class DB:
|
|
| 138 |
return
|
| 139 |
|
| 140 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
ts = _get_time_now()
|
| 142 |
-
|
| 143 |
-
subprocess.run(['git', '
|
| 144 |
-
subprocess.run(['git', '
|
|
|
|
|
|
|
|
|
|
| 145 |
except Exception as e:
|
| 146 |
raise RuntimeError(f'Failed to commit and push the database: {e}')
|
|
|
|
| 138 |
return
|
| 139 |
|
| 140 |
try:
|
| 141 |
+
repo_root = subprocess.run(
|
| 142 |
+
['git', 'rev-parse', '--show-toplevel'],
|
| 143 |
+
check=True,
|
| 144 |
+
capture_output=True,
|
| 145 |
+
text=True,
|
| 146 |
+
).stdout.strip()
|
| 147 |
+
|
| 148 |
ts = _get_time_now()
|
| 149 |
+
db_rel = os.path.relpath(self.db_path, repo_root)
|
| 150 |
+
subprocess.run(['git', 'add', db_rel], check=True, cwd=repo_root)
|
| 151 |
+
diff = subprocess.run(['git', 'diff', '--cached', '--quiet'], check=False, cwd=repo_root)
|
| 152 |
+
if diff.returncode != 0:
|
| 153 |
+
subprocess.run(['git', 'commit', '-m', f'update db {ts}'], check=True, cwd=repo_root)
|
| 154 |
+
subprocess.run(['git', 'push', 'origin', 'main'], check=True, cwd=repo_root)
|
| 155 |
except Exception as e:
|
| 156 |
raise RuntimeError(f'Failed to commit and push the database: {e}')
|