mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-08 22:48:25 -05:00
hotfix: extract_dataset.py (#7029)
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
# extract asts from process replay artifacts
|
||||
import os, pickle
|
||||
from tinygrad.helpers import db_connection, getenv, VERSION
|
||||
import os
|
||||
from tinygrad.helpers import db_connection, VERSION
|
||||
from test.external.process_replay.process_replay import _pmap
|
||||
|
||||
PAGE_SIZE = 100
|
||||
RUN_ID = os.getenv("GITHUB_RUN_ID", "HEAD")
|
||||
TABLE_NAME = f"process_replay_{RUN_ID}_{getenv('GITHUB_RUN_ATTEMPT')}_{VERSION}"
|
||||
TABLE_NAME = f"kernel_process_replay_{VERSION}"
|
||||
LOGOPS = os.getenv("LOGOPS", "/tmp/sops")
|
||||
|
||||
def extract_ast(offset:int) -> bool:
|
||||
logops = open(LOGOPS, "a")
|
||||
conn = db_connection()
|
||||
for row in conn.execute(f"SELECT val FROM '{TABLE_NAME}' LIMIT ? OFFSET ?", (PAGE_SIZE, offset)).fetchall():
|
||||
logops.write(str(pickle.loads(row[0])[0]).replace("\n", "").replace(" ", "")+"\n")
|
||||
return False
|
||||
def extract_ast(*args) -> bool:
|
||||
open(LOGOPS, "a").write(str(args[0]).replace("\n", "").replace(" ", "")+"\n")
|
||||
return args[-1]
|
||||
|
||||
if __name__ == "__main__":
|
||||
conn = db_connection()
|
||||
row_count = conn.execute(f"SELECT COUNT(*) FROM '{TABLE_NAME}'").fetchone()[0]
|
||||
_pmap(row_count, extract_ast)
|
||||
_pmap("kernel", extract_ast)
|
||||
|
||||
Reference in New Issue
Block a user