Spaces:
Sleeping

PERDYPTO commited on
Commit
52bb87c
·
verified ·
1 Parent(s): 10693a5

Update hf_space.py

Browse files
Files changed (1) hide show
  1. hf_space.py +34 -1
hf_space.py CHANGED
@@ -32,6 +32,39 @@ RAM_REFILL_THRESHOLD = int(os.environ.get("RAM_REFILL_THRESHOLD", "100000"))
32
  DUCKDB_MEMORY_LIMIT = os.environ.get("DUCKDB_MEMORY_LIMIT", "5GB")
33
  DUCKDB_THREADS = os.environ.get("DUCKDB_THREADS", "2")
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  SCHEMA = """
36
  PRAGMA journal_mode=WAL;
37
  PRAGMA synchronous=NORMAL;
@@ -344,7 +377,7 @@ async def reset_metadata():
344
  with db_lock:
345
  print("[RESET] Dropping metadata table and resetting all jobs to pending...")
346
  db_conn.execute("DROP TABLE IF EXISTS metadata;")
347
- db_conn.execute(SCHEMA) # Recreates metadata with new columns
348
  db_conn.execute("UPDATE repo_ids SET status='pending', last_error=NULL, updated_at=?", (now(),))
349
  db_conn.commit()
350
 
 
32
  DUCKDB_MEMORY_LIMIT = os.environ.get("DUCKDB_MEMORY_LIMIT", "5GB")
33
  DUCKDB_THREADS = os.environ.get("DUCKDB_THREADS", "2")
34
 
35
+ # Schema for ONLY the metadata table (used for reset endpoint)
36
+ METADATA_TABLE_SCHEMA = """
37
+ CREATE TABLE IF NOT EXISTS metadata (
38
+ repo_id INTEGER PRIMARY KEY,
39
+ full_name TEXT,
40
+ description TEXT,
41
+ homepage_url TEXT,
42
+ stars INTEGER,
43
+ forks_count INTEGER,
44
+ watchers_count INTEGER,
45
+ open_issues INTEGER,
46
+ license TEXT,
47
+ license_name TEXT,
48
+ archived INTEGER,
49
+ disabled INTEGER,
50
+ is_fork INTEGER,
51
+ is_private INTEGER,
52
+ is_template INTEGER,
53
+ disk_usage_kb INTEGER,
54
+ primary_language TEXT,
55
+ default_branch TEXT,
56
+ topics_json TEXT,
57
+ created_at TEXT,
58
+ updated_at TEXT,
59
+ pushed_at TEXT,
60
+ languages_json TEXT,
61
+ python_bytes INTEGER,
62
+ total_lang_bytes INTEGER,
63
+ python_pct REAL,
64
+ fetched_at TEXT
65
+ );
66
+ """
67
+
68
  SCHEMA = """
69
  PRAGMA journal_mode=WAL;
70
  PRAGMA synchronous=NORMAL;
 
377
  with db_lock:
378
  print("[RESET] Dropping metadata table and resetting all jobs to pending...")
379
  db_conn.execute("DROP TABLE IF EXISTS metadata;")
380
+ db_conn.execute(METADATA_TABLE_SCHEMA) # Only recreates the metadata table
381
  db_conn.execute("UPDATE repo_ids SET status='pending', last_error=NULL, updated_at=?", (now(),))
382
  db_conn.commit()
383