Datasets:
Refresh verified six-GPU manifest: 26 tuples
Browse files- pipeline/SIXGPU.md +14 -8
- pipeline/live_index.py +51 -0
- pipeline/pipeline.py +8 -4
- pipeline/sixgpu_publish.py +1 -1
- pipeline/sixgpu_run.py +5 -14
- pipeline/streaming.py +11 -7
- pipeline/verify_live.py +55 -0
- progress/sixgpu-status.json +23 -23
pipeline/SIXGPU.md
CHANGED
|
@@ -12,14 +12,16 @@ Each worker inherits one `CUDA_VISIBLE_DEVICES` and its own
|
|
| 12 |
the old single-GPU lock as fallback. Each GPU runs its own long-lived
|
| 13 |
DINO and DA3 worker, preserving the existing within-GPU overlap and checks.
|
| 14 |
|
| 15 |
-
The
|
| 16 |
-
old state directory.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
per-GPU summaries and quota reports; thresholds are never relaxed.
|
| 24 |
|
| 25 |
Downloads: 4/GPU (24 total). Uploads: 1/GPU (6 total).
|
|
@@ -34,6 +36,10 @@ unchanged; DA3 uses the GPU depth/NVENC path; no NPZ.
|
|
| 34 |
`progress/sixgpu-status.json` every five minutes from verified receipts.
|
| 35 |
Failures retry without deleting data. The manifest uses immutable video URLs.
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
Read `status.json`, `supervisor.log`, `index-*.log`, `gpu*-pilot.log`,
|
| 38 |
`gpu*-production.log`, `gpu*/summary.json`, and `manifest-local.log` under the
|
| 39 |
root-disk control directory (`supervisor-local.log` is the active supervisor log).
|
|
|
|
| 12 |
the old single-GPU lock as fallback. Each GPU runs its own long-lived
|
| 13 |
DINO and DA3 worker, preserving the existing within-GPU overlap and checks.
|
| 14 |
|
| 15 |
+
The prior verified tuples and rejects are imported without modifying the
|
| 16 |
+
old state directory. Three independent exact archive indexes build while
|
| 17 |
+
all six production shards run with `--incremental-index`. Each shard polls
|
| 18 |
+
committed catalogue entries every 15 seconds and processes a pair as soon as
|
| 19 |
+
both original and styled clips are available. It never waits for complete
|
| 20 |
+
indexes. Archive ordering can still leave GPUs idle until pairs are found.
|
| 21 |
+
The archive scans cover about 534.67 GiB and retain metadata only. Tar scanning
|
| 22 |
+
is sequential, including correct absolute offsets when resuming; a completed
|
| 23 |
+
prefetch is kept for consumption instead of re-requesting the same block.
|
| 24 |
+
The target is 100 verified distinct source clips per style. Candidate exhaustion or errors appear in
|
| 25 |
per-GPU summaries and quota reports; thresholds are never relaxed.
|
| 26 |
|
| 27 |
Downloads: 4/GPU (24 total). Uploads: 1/GPU (6 total).
|
|
|
|
| 36 |
`progress/sixgpu-status.json` every five minutes from verified receipts.
|
| 37 |
Failures retry without deleting data. The manifest uses immutable video URLs.
|
| 38 |
|
| 39 |
+
`verify_live.py` tests delayed pair readiness, completed quotas, duplicate-free
|
| 40 |
+
prefetch, exact archive member offsets, and resume at a committed tar boundary.
|
| 41 |
+
Its in-memory CPU benchmark is not an end-to-end performance claim.
|
| 42 |
+
|
| 43 |
Read `status.json`, `supervisor.log`, `index-*.log`, `gpu*-pilot.log`,
|
| 44 |
`gpu*-production.log`, `gpu*/summary.json`, and `manifest-local.log` under the
|
| 45 |
root-disk control directory (`supervisor-local.log` is the active supervisor log).
|
pipeline/live_index.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Yield bounded ready batches while independent exact indexes are growing."""
|
| 2 |
+
import json, sqlite3, time
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
CATEGORIES = ('source', 'global_style1', 'global_style2')
|
| 6 |
+
|
| 7 |
+
def available(root):
|
| 8 |
+
names, complete = set(), True
|
| 9 |
+
for category in CATEGORIES:
|
| 10 |
+
path = Path(root)/category/'catalog.sqlite'
|
| 11 |
+
if not path.exists():
|
| 12 |
+
complete = False
|
| 13 |
+
continue
|
| 14 |
+
db = sqlite3.connect(f'file:{path}?mode=ro', uri=True, timeout=30)
|
| 15 |
+
try:
|
| 16 |
+
# One read snapshot: never see uncommitted catalogue entries.
|
| 17 |
+
db.execute('BEGIN')
|
| 18 |
+
names.update(row[0] for row in db.execute('SELECT name FROM members'))
|
| 19 |
+
finished = db.execute('SELECT complete FROM checkpoints WHERE category=?', (category,)).fetchone()
|
| 20 |
+
complete = complete and finished == (1,)
|
| 21 |
+
finally:
|
| 22 |
+
db.close()
|
| 23 |
+
return names, complete
|
| 24 |
+
|
| 25 |
+
def batches(rows, root, window, quota, counts, poll=15):
|
| 26 |
+
pending = list(rows)
|
| 27 |
+
while pending:
|
| 28 |
+
current = counts()
|
| 29 |
+
pending = [r for r in pending if current.get(r['style_id'], 0) < quota]
|
| 30 |
+
if not pending:
|
| 31 |
+
return
|
| 32 |
+
names, complete = available(root)
|
| 33 |
+
ready, waiting = [], []
|
| 34 |
+
for row in pending:
|
| 35 |
+
if row['source_path'] in names and row['edited_path'] in names:
|
| 36 |
+
ready.append(row)
|
| 37 |
+
else:
|
| 38 |
+
waiting.append(row)
|
| 39 |
+
if ready:
|
| 40 |
+
print('LIVE_INDEX_READY', len(ready), 'waiting', len(waiting), flush=True)
|
| 41 |
+
for first in range(0, len(ready), window):
|
| 42 |
+
current = counts()
|
| 43 |
+
batch = [r for r in ready[first:first+window] if current.get(r['style_id'], 0) < quota]
|
| 44 |
+
if batch:
|
| 45 |
+
yield batch
|
| 46 |
+
pending = waiting
|
| 47 |
+
elif complete:
|
| 48 |
+
raise RuntimeError(f'{len(waiting)} remaining candidates missing from complete indexes')
|
| 49 |
+
else:
|
| 50 |
+
print('LIVE_INDEX_WAIT', len(pending), flush=True)
|
| 51 |
+
time.sleep(poll)
|
pipeline/pipeline.py
CHANGED
|
@@ -110,7 +110,11 @@ class Run:
|
|
| 110 |
with cf.ThreadPoolExecutor(a.download_workers) as pool:
|
| 111 |
loads=cf.ThreadPoolExecutor(2)
|
| 112 |
ff=loads.submit(Worker,'filter',self.state,not a.serial_gpu_stages,getattr(a,'video_backend','cuda'));df=loads.submit(Worker,'depth',self.state,not a.serial_gpu_stages,getattr(a,'video_backend','cuda'))
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
for uf in self.uploads:
|
| 115 |
if uf.done() and uf.exception() is not None:raise RuntimeError('Upload failed; retained local media and stopped downloads: '+str(uf.exception()))
|
| 116 |
if a.limit and accepted>=a.limit:break
|
|
@@ -120,7 +124,7 @@ class Run:
|
|
| 120 |
time.sleep(1)
|
| 121 |
current=self.counts()
|
| 122 |
if all(current.get(r['style_id'],0)>=a.per_style for r in allrows):break
|
| 123 |
-
batch=[r for r in
|
| 124 |
if not batch:continue
|
| 125 |
groups={};pending={}
|
| 126 |
for row in batch:
|
|
@@ -192,9 +196,9 @@ class Run:
|
|
| 192 |
return 0 if success and not self.metrics['errors'] else 2
|
| 193 |
|
| 194 |
def main():
|
| 195 |
-
p=argparse.ArgumentParser();p.add_argument('--index',choices=['source','global_style1','global_style2']);p.add_argument('--index-state',default='/workspace/styleedit-streaming-20261024/index');p.add_argument('--plan',default=str(BASE/'candidates.json'));p.add_argument('--state',default='/workspace/styleedit-streaming-20261024/state');p.add_argument('--scratch',default='/opt/styleedit-scratch');p.add_argument('--repo',default=DEST);p.add_argument('--limit',type=int,default=10);p.add_argument('--per-style',type=int,default=100);p.add_argument('--seed-ranges',action='store_true');p.add_argument('--video-backend',choices=['cpu','cuda'],default='cuda',help='CPU depth encoding or GPU-resident depth/NVENC device input; RGB decode stays CPU');p.add_argument('--serial-gpu-stages',action='store_true',help='Diagnostic baseline: serial stages and original core-v1 loop');p.add_argument('--window',type=int,default=30);p.add_argument('--download-workers',type=int,default=16);p.add_argument('--upload-workers',type=int,default=4);p.add_argument('--cleanup-seconds',type=int,default=60);p.add_argument('--scratch-gib',type=int,default=60);p.add_argument('--reserve-gib',type=int,default=25);a=p.parse_args()
|
| 196 |
if a.index:build_index(a.index,a.index_state);return 0
|
| 197 |
-
if not a.seed_ranges:
|
| 198 |
dbpath=Path(a.index_state)/'catalog.sqlite'
|
| 199 |
if not dbpath.exists():raise RuntimeError('Build exact archive indexes first; see README.md')
|
| 200 |
with sqlite3.connect(dbpath) as db:
|
|
|
|
| 110 |
with cf.ThreadPoolExecutor(a.download_workers) as pool:
|
| 111 |
loads=cf.ThreadPoolExecutor(2)
|
| 112 |
ff=loads.submit(Worker,'filter',self.state,not a.serial_gpu_stages,getattr(a,'video_backend','cuda'));df=loads.submit(Worker,'depth',self.state,not a.serial_gpu_stages,getattr(a,'video_backend','cuda'))
|
| 113 |
+
if getattr(a,'incremental_index',False):
|
| 114 |
+
from live_index import batches
|
| 115 |
+
windows=batches(rows,a.index_state,a.window,a.per_style,self.counts)
|
| 116 |
+
else:windows=(rows[first:first+a.window] for first in range(0,len(rows),a.window))
|
| 117 |
+
for ready_batch in windows:
|
| 118 |
for uf in self.uploads:
|
| 119 |
if uf.done() and uf.exception() is not None:raise RuntimeError('Upload failed; retained local media and stopped downloads: '+str(uf.exception()))
|
| 120 |
if a.limit and accepted>=a.limit:break
|
|
|
|
| 124 |
time.sleep(1)
|
| 125 |
current=self.counts()
|
| 126 |
if all(current.get(r['style_id'],0)>=a.per_style for r in allrows):break
|
| 127 |
+
batch=[r for r in ready_batch if current.get(r['style_id'],0)<a.per_style]
|
| 128 |
if not batch:continue
|
| 129 |
groups={};pending={}
|
| 130 |
for row in batch:
|
|
|
|
| 196 |
return 0 if success and not self.metrics['errors'] else 2
|
| 197 |
|
| 198 |
def main():
|
| 199 |
+
p=argparse.ArgumentParser();p.add_argument('--index',choices=['source','global_style1','global_style2']);p.add_argument('--index-state',default='/workspace/styleedit-streaming-20261024/index');p.add_argument('--plan',default=str(BASE/'candidates.json'));p.add_argument('--state',default='/workspace/styleedit-streaming-20261024/state');p.add_argument('--scratch',default='/opt/styleedit-scratch');p.add_argument('--repo',default=DEST);p.add_argument('--limit',type=int,default=10);p.add_argument('--per-style',type=int,default=100);p.add_argument('--seed-ranges',action='store_true');p.add_argument('--video-backend',choices=['cpu','cuda'],default='cuda',help='CPU depth encoding or GPU-resident depth/NVENC device input; RGB decode stays CPU');p.add_argument('--serial-gpu-stages',action='store_true',help='Diagnostic baseline: serial stages and original core-v1 loop');p.add_argument('--window',type=int,default=30);p.add_argument('--download-workers',type=int,default=16);p.add_argument('--upload-workers',type=int,default=4);p.add_argument('--cleanup-seconds',type=int,default=60);p.add_argument('--scratch-gib',type=int,default=60);p.add_argument('--reserve-gib',type=int,default=25);p.add_argument('--incremental-index',action='store_true',help='Process committed ready pairs while category indexes grow');a=p.parse_args()
|
| 200 |
if a.index:build_index(a.index,a.index_state);return 0
|
| 201 |
+
if not a.seed_ranges and not a.incremental_index:
|
| 202 |
dbpath=Path(a.index_state)/'catalog.sqlite'
|
| 203 |
if not dbpath.exists():raise RuntimeError('Build exact archive indexes first; see README.md')
|
| 204 |
with sqlite3.connect(dbpath) as db:
|
pipeline/sixgpu_publish.py
CHANGED
|
@@ -27,7 +27,7 @@ def publish():
|
|
| 27 |
ops=[CommitOperationAdd(path_in_repo='metadata.jsonl',path_or_fileobj=str(out))]
|
| 28 |
status=ROOT/'status.json'
|
| 29 |
if status.exists():ops.append(CommitOperationAdd(path_in_repo='progress/sixgpu-status.json',path_or_fileobj=str(status)))
|
| 30 |
-
for name in ['sixgpu_run.py','sixgpu_publish.py','workers.py','SIXGPU.md']:
|
| 31 |
ops.append(CommitOperationAdd(path_in_repo='pipeline/'+name,path_or_fileobj=str(APP/name)))
|
| 32 |
c=HfApi().create_commit(repo_id='faraway00/StyleEdit',repo_type='dataset',operations=ops,
|
| 33 |
commit_message=f'Refresh verified six-GPU manifest: {len(manifest)} tuples')
|
|
|
|
| 27 |
ops=[CommitOperationAdd(path_in_repo='metadata.jsonl',path_or_fileobj=str(out))]
|
| 28 |
status=ROOT/'status.json'
|
| 29 |
if status.exists():ops.append(CommitOperationAdd(path_in_repo='progress/sixgpu-status.json',path_or_fileobj=str(status)))
|
| 30 |
+
for name in ['sixgpu_run.py','sixgpu_publish.py','workers.py','SIXGPU.md','pipeline.py','streaming.py','live_index.py','verify_live.py']:
|
| 31 |
ops.append(CommitOperationAdd(path_in_repo='pipeline/'+name,path_or_fileobj=str(APP/name)))
|
| 32 |
c=HfApi().create_commit(repo_id='faraway00/StyleEdit',repo_type='dataset',operations=ops,
|
| 33 |
commit_message=f'Refresh verified six-GPU manifest: {len(manifest)} tuples')
|
pipeline/sixgpu_run.py
CHANGED
|
@@ -55,10 +55,10 @@ def prepare():
|
|
| 55 |
def processing(gpu, pilot=False):
|
| 56 |
return spawn([APP/'pipeline.py', '--plan', APP/f'{"pilot" if pilot else "plan"}-gpu{gpu}.json',
|
| 57 |
'--state', STATE/f'gpu{gpu}', '--scratch', f'/opt/styleedit-sixgpu-scratch/gpu{gpu}',
|
| 58 |
-
'--index-state',
|
| 59 |
'--window','6','--download-workers','4','--upload-workers','1',
|
| 60 |
'--scratch-gib','60','--reserve-gib','40','--cleanup-seconds','60',
|
| 61 |
-
*(['--seed-ranges'] if pilot else [])], ROOT/f'gpu{gpu}-{ "pilot" if pilot else "production"}.log', gpu)
|
| 62 |
|
| 63 |
def aggregate(stage, children):
|
| 64 |
counts = collections.Counter(); statuses = collections.Counter(); dirty = 0
|
|
@@ -107,23 +107,14 @@ def main():
|
|
| 107 |
else:
|
| 108 |
children['index-'+category]=spawn([APP/'pipeline.py','--index',category,'--index-state',path], ROOT/f'index-{category}.log')
|
| 109 |
save(ROOT/'index-pids.json',{cat:children['index-'+cat].pid for cat in ['source','global_style1','global_style2']})
|
| 110 |
-
for gpu in range(6):children[f'
|
| 111 |
while any(p.poll() is None for p in children.values()):
|
| 112 |
-
aggregate('
|
| 113 |
# Failed index is fatal; preserve all checkpoints and media.
|
| 114 |
failed=[k for k,p in children.items() if k.startswith('index-') and p.poll() not in (None,0)]
|
| 115 |
if failed: raise RuntimeError('Index failed; inspect logs: '+str(failed))
|
| 116 |
time.sleep(30)
|
| 117 |
-
aggregate('
|
| 118 |
-
# Pilot's quota deficit gives exit 2 by design. Upload/model errors are not safe to ignore.
|
| 119 |
-
for gpu in range(6):
|
| 120 |
-
summary=json.loads((STATE/f'gpu{gpu}'/'summary.json').read_text())
|
| 121 |
-
if summary['errors']:raise RuntimeError(f'Pilot GPU {gpu} errors: inspect summary before production')
|
| 122 |
-
index_merge()
|
| 123 |
-
children={f'gpu-{g}':processing(g) for g in range(6)}
|
| 124 |
-
while any(p.poll() is None for p in children.values()):
|
| 125 |
-
aggregate('production',children); time.sleep(30)
|
| 126 |
-
aggregate('complete' if all(p.returncode==0 for p in children.values()) else 'needs_attention',children)
|
| 127 |
print('SIX_GPU_FINISHED',flush=True)
|
| 128 |
|
| 129 |
class ExistingIndex:
|
|
|
|
| 55 |
def processing(gpu, pilot=False):
|
| 56 |
return spawn([APP/'pipeline.py', '--plan', APP/f'{"pilot" if pilot else "plan"}-gpu{gpu}.json',
|
| 57 |
'--state', STATE/f'gpu{gpu}', '--scratch', f'/opt/styleedit-sixgpu-scratch/gpu{gpu}',
|
| 58 |
+
'--index-state', ROOT/'indexes', '--limit','0','--per-style','100',
|
| 59 |
'--window','6','--download-workers','4','--upload-workers','1',
|
| 60 |
'--scratch-gib','60','--reserve-gib','40','--cleanup-seconds','60',
|
| 61 |
+
*(['--seed-ranges'] if pilot else ['--incremental-index'])], ROOT/f'gpu{gpu}-{ "pilot" if pilot else "production"}.log', gpu)
|
| 62 |
|
| 63 |
def aggregate(stage, children):
|
| 64 |
counts = collections.Counter(); statuses = collections.Counter(); dirty = 0
|
|
|
|
| 107 |
else:
|
| 108 |
children['index-'+category]=spawn([APP/'pipeline.py','--index',category,'--index-state',path], ROOT/f'index-{category}.log')
|
| 109 |
save(ROOT/'index-pids.json',{cat:children['index-'+cat].pid for cat in ['source','global_style1','global_style2']})
|
| 110 |
+
for gpu in range(6):children[f'gpu-{gpu}']=processing(gpu)
|
| 111 |
while any(p.poll() is None for p in children.values()):
|
| 112 |
+
aggregate('indexing_and_production',children)
|
| 113 |
# Failed index is fatal; preserve all checkpoints and media.
|
| 114 |
failed=[k for k,p in children.items() if k.startswith('index-') and p.poll() not in (None,0)]
|
| 115 |
if failed: raise RuntimeError('Index failed; inspect logs: '+str(failed))
|
| 116 |
time.sleep(30)
|
| 117 |
+
aggregate('complete' if all(p.poll()==0 for p in children.values()) else 'needs_attention',children)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
print('SIX_GPU_FINISHED',flush=True)
|
| 119 |
|
| 120 |
class ExistingIndex:
|
pipeline/streaming.py
CHANGED
|
@@ -50,7 +50,7 @@ class Remote(io.RawIOBase):
|
|
| 50 |
while len(self.cache)>2:self.cache.popitem(last=False)
|
| 51 |
data=self.cache[key];j=self.pos-key;take=min(n,len(data)-j);out.append(data[j:j+take]);self.pos+=take;n-=take
|
| 52 |
nxt=key+self.block
|
| 53 |
-
if nxt<self.size and nxt not in self.cache and (self.prefetch is None or self.prefetch[
|
| 54 |
self.prefetch=(nxt,self.pool.submit(get_range,self.category,nxt,min(self.block,self.size-nxt)))
|
| 55 |
return b''.join(out)
|
| 56 |
def close(self):
|
|
@@ -112,15 +112,16 @@ def build_index(category,state):
|
|
| 112 |
db.execute('INSERT OR REPLACE INTO checkpoints VALUES(?,?,?)',(category,at,int(complete)));db.commit()
|
| 113 |
atomic(checkpoint,{'category':category,'source_revision':REV,'uncompressed_offset':at,'members_this_session':count,'compressed_download_bytes':remote.downloaded,'complete':complete})
|
| 114 |
try:
|
| 115 |
-
#
|
| 116 |
-
|
|
|
|
| 117 |
while True:
|
| 118 |
m=tar.next()
|
| 119 |
if m is None:break
|
| 120 |
name=m.name.removeprefix('./')
|
| 121 |
if m.isfile() and name.endswith('.mp4') and 0<m.size<200*1024**2:
|
| 122 |
-
db.execute('INSERT OR IGNORE INTO members VALUES(?,?,?,?)',(category,name,m.offset_data,m.size));count+=1
|
| 123 |
-
last=tar.offset
|
| 124 |
if time.monotonic()-lastsave>60:
|
| 125 |
save(last);lastsave=time.monotonic();print('INDEX_PROGRESS',category,count,last,remote.downloaded,flush=True)
|
| 126 |
# Finish the gzip stream to check the CRC, with bounded buffers.
|
|
@@ -130,10 +131,13 @@ def build_index(category,state):
|
|
| 130 |
|
| 131 |
def indexed_download(row,side,destination,state):
|
| 132 |
import indexed_gzip
|
| 133 |
-
category=row[side+'_path'].split('/')[0]
|
|
|
|
|
|
|
|
|
|
| 134 |
match=db.execute('SELECT offset,size FROM members WHERE category=? AND name=?',(category,row[side+'_path'])).fetchone();db.close()
|
| 135 |
if not match:raise LookupError('Member not indexed: '+row[side+'_path'])
|
| 136 |
-
remote=Remote(category,archive_sizes()[category]);gz=indexed_gzip.IndexedGzipFile(fileobj=remote,spacing=32*1024**2,index_file=str(
|
| 137 |
try:
|
| 138 |
gz.seek(match[0]);data=gz.read(match[1])
|
| 139 |
if len(data)!=match[1]:raise EOFError('Partial indexed member')
|
|
|
|
| 50 |
while len(self.cache)>2:self.cache.popitem(last=False)
|
| 51 |
data=self.cache[key];j=self.pos-key;take=min(n,len(data)-j);out.append(data[j:j+take]);self.pos+=take;n-=take
|
| 52 |
nxt=key+self.block
|
| 53 |
+
if nxt<self.size and nxt not in self.cache and (self.prefetch is None or self.prefetch[0]!=nxt):
|
| 54 |
self.prefetch=(nxt,self.pool.submit(get_range,self.category,nxt,min(self.block,self.size-nxt)))
|
| 55 |
return b''.join(out)
|
| 56 |
def close(self):
|
|
|
|
| 112 |
db.execute('INSERT OR REPLACE INTO checkpoints VALUES(?,?,?)',(category,at,int(complete)));db.commit()
|
| 113 |
atomic(checkpoint,{'category':category,'source_revision':REV,'uncompressed_offset':at,'members_this_session':count,'compressed_download_bytes':remote.downloaded,'complete':complete})
|
| 114 |
try:
|
| 115 |
+
# Stream forward once. Random tar seeks repeatedly replay gzip dictionaries.
|
| 116 |
+
# Stream TarInfo offsets start at zero even when gzip resumes mid-archive.
|
| 117 |
+
tar=tarfile.open(fileobj=gzip,mode='r|')
|
| 118 |
while True:
|
| 119 |
m=tar.next()
|
| 120 |
if m is None:break
|
| 121 |
name=m.name.removeprefix('./')
|
| 122 |
if m.isfile() and name.endswith('.mp4') and 0<m.size<200*1024**2:
|
| 123 |
+
db.execute('INSERT OR IGNORE INTO members VALUES(?,?,?,?)',(category,name,offset+m.offset_data,m.size));count+=1
|
| 124 |
+
last=offset+tar.offset
|
| 125 |
if time.monotonic()-lastsave>60:
|
| 126 |
save(last);lastsave=time.monotonic();print('INDEX_PROGRESS',category,count,last,remote.downloaded,flush=True)
|
| 127 |
# Finish the gzip stream to check the CRC, with bounded buffers.
|
|
|
|
| 131 |
|
| 132 |
def indexed_download(row,side,destination,state):
|
| 133 |
import indexed_gzip
|
| 134 |
+
category=row[side+'_path'].split('/')[0]
|
| 135 |
+
state=Path(state)
|
| 136 |
+
if (state/category/'catalog.sqlite').exists():state=state/category
|
| 137 |
+
db=sqlite3.connect(f'file:{state}/catalog.sqlite?mode=ro',uri=True,timeout=30)
|
| 138 |
match=db.execute('SELECT offset,size FROM members WHERE category=? AND name=?',(category,row[side+'_path'])).fetchone();db.close()
|
| 139 |
if not match:raise LookupError('Member not indexed: '+row[side+'_path'])
|
| 140 |
+
remote=Remote(category,archive_sizes()[category]);gz=indexed_gzip.IndexedGzipFile(fileobj=remote,spacing=32*1024**2,index_file=str(state/(category+'.gzidx')))
|
| 141 |
try:
|
| 142 |
gz.seek(match[0]);data=gz.read(match[1])
|
| 143 |
if len(data)!=match[1]:raise EOFError('Partial indexed member')
|
pipeline/verify_live.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import collections,gzip,hashlib,importlib.util,io,json,os,sqlite3,tarfile,tempfile,time
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import indexed_gzip
|
| 4 |
+
import streaming,live_index
|
| 5 |
+
|
| 6 |
+
def catalog(root,cat,entries,complete=0):
|
| 7 |
+
p=root/cat;p.mkdir(parents=True,exist_ok=True)
|
| 8 |
+
c=sqlite3.connect(p/'catalog.sqlite');c.execute('CREATE TABLE IF NOT EXISTS members(category TEXT,name TEXT,offset INTEGER,size INTEGER,PRIMARY KEY(category,name))');c.execute('CREATE TABLE IF NOT EXISTS checkpoints(category TEXT PRIMARY KEY,offset INTEGER,complete INTEGER)')
|
| 9 |
+
c.executemany('INSERT OR REPLACE INTO members VALUES(?,?,?,?)',[(cat,x,0,1) for x in entries]);c.execute('INSERT OR REPLACE INTO checkpoints VALUES(?,?,?)',(cat,1,complete));c.commit();c.close()
|
| 10 |
+
|
| 11 |
+
with tempfile.TemporaryDirectory(prefix='live-index-check-') as td:
|
| 12 |
+
root=Path(td)
|
| 13 |
+
row={'id':'one','style_id':'a','source_path':'source/x.mp4','edited_path':'global_style1/x.mp4'}
|
| 14 |
+
catalog(root,'source',[row['source_path']]);catalog(root,'global_style1',[]);catalog(root,'global_style2',[])
|
| 15 |
+
names,complete=live_index.available(root);assert row['source_path'] in names and row['edited_path'] not in names and not complete
|
| 16 |
+
catalog(root,'global_style1',[row['edited_path']])
|
| 17 |
+
rows=[row,{**row,'id':'two','style_id':'b'}]
|
| 18 |
+
assert list(live_index.batches(rows,root,2,100,lambda:{'b':100}))==[[row]]
|
| 19 |
+
print('PASS live readiness and verified quota exclusion')
|
| 20 |
+
|
| 21 |
+
original_range=streaming.get_range;calls=[]
|
| 22 |
+
def fake_range(cat,start,length):calls.append(start);return bytes([start//1024%256])*length
|
| 23 |
+
streaming.get_range=fake_range
|
| 24 |
+
remote=streaming.Remote('test',4096,1024)
|
| 25 |
+
for _ in range(256):assert len(remote.read(16))==16
|
| 26 |
+
remote.close();assert collections.Counter(calls)=={0:1,1024:1,2048:1,3072:1},calls
|
| 27 |
+
streaming.get_range=original_range
|
| 28 |
+
print('PASS no duplicate prefetch for repeated reads within one block')
|
| 29 |
+
|
| 30 |
+
raw=io.BytesIO();expected={}
|
| 31 |
+
with tarfile.open(fileobj=raw,mode='w') as tar:
|
| 32 |
+
for i in range(128):
|
| 33 |
+
body=os.urandom(256*1024);name=f'source/test/{i}.mp4';expected[name]=body;m=tarfile.TarInfo(name);m.size=len(body);tar.addfile(m,io.BytesIO(body))
|
| 34 |
+
compressed=gzip.compress(raw.getvalue(),compresslevel=1)
|
| 35 |
+
class Memory(io.BytesIO):
|
| 36 |
+
def __init__(self,*args):super().__init__(compressed);self.downloaded=0
|
| 37 |
+
streaming.Remote=Memory;streaming.archive_sizes=lambda:{'source':len(compressed)}
|
| 38 |
+
spec=importlib.util.spec_from_file_location('old_stream','/opt/styleedit-streaming-20261024/streaming.py');old=importlib.util.module_from_spec(spec);spec.loader.exec_module(old);old.Remote=Memory;old.archive_sizes=streaming.archive_sizes
|
| 39 |
+
timings={}
|
| 40 |
+
for name,module in [('old',old),('new',streaming)]:
|
| 41 |
+
dest=root/name;t=time.monotonic();module.build_index('source',dest);timings[name]=time.monotonic()-t
|
| 42 |
+
c=sqlite3.connect(dest/'catalog.sqlite');members=c.execute('SELECT name,offset,size FROM members').fetchall();assert len(members)==128
|
| 43 |
+
for member,offset,size in members:assert raw.getvalue()[offset:offset+size]==expected[member]
|
| 44 |
+
assert c.execute('select complete from checkpoints').fetchone()==(1,);c.close()
|
| 45 |
+
print('PASS exact offsets; synthetic CPU scan seconds',timings,'speedup',timings['old']/timings['new'])
|
| 46 |
+
# Resume mid-archive using an exported exact gzip index and committed tar boundary.
|
| 47 |
+
with tarfile.open(fileobj=io.BytesIO(raw.getvalue()),mode='r:') as tar:members=list(tar)
|
| 48 |
+
boundary=members[32].offset;dest=root/'resume';dest.mkdir()
|
| 49 |
+
gz=indexed_gzip.IndexedGzipFile(fileobj=io.BytesIO(compressed),spacing=32*1024**2);gz.seek(boundary);gz.read(1);gz.export_index(filename=str(dest/'source.gzidx'));gz.close()
|
| 50 |
+
c=sqlite3.connect(dest/'catalog.sqlite');c.execute('CREATE TABLE members(category TEXT,name TEXT,offset INTEGER,size INTEGER,PRIMARY KEY(category,name))');c.execute('CREATE TABLE checkpoints(category TEXT PRIMARY KEY,offset INTEGER,complete INTEGER)');c.execute('INSERT INTO checkpoints VALUES(?,?,?)',('source',boundary,0));c.commit();c.close()
|
| 51 |
+
streaming.build_index('source',dest)
|
| 52 |
+
c=sqlite3.connect(dest/'catalog.sqlite');found=c.execute('SELECT name,offset,size FROM members').fetchall();assert len(found)==96
|
| 53 |
+
for name,offset,size in found:assert raw.getvalue()[offset:offset+size]==expected[name]
|
| 54 |
+
c.close();print('PASS resumed stream preserves absolute offsets and complete member bytes')
|
| 55 |
+
print('ALL_PASS')
|
progress/sixgpu-status.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
-
"utc": "2026-10-24T04:
|
| 3 |
-
"stage": "
|
| 4 |
"verified": 26,
|
| 5 |
"counts": {
|
| 6 |
"26b03a8ae47d": 1,
|
|
@@ -37,40 +37,40 @@
|
|
| 37 |
"verified_pending_cleanup": 0,
|
| 38 |
"processes": {
|
| 39 |
"index-source": {
|
| 40 |
-
"pid":
|
| 41 |
"returncode": null
|
| 42 |
},
|
| 43 |
"index-global_style1": {
|
| 44 |
-
"pid":
|
| 45 |
"returncode": null
|
| 46 |
},
|
| 47 |
"index-global_style2": {
|
| 48 |
-
"pid":
|
| 49 |
"returncode": null
|
| 50 |
},
|
| 51 |
-
"
|
| 52 |
-
"pid":
|
| 53 |
-
"returncode":
|
| 54 |
},
|
| 55 |
-
"
|
| 56 |
-
"pid":
|
| 57 |
-
"returncode":
|
| 58 |
},
|
| 59 |
-
"
|
| 60 |
-
"pid":
|
| 61 |
-
"returncode":
|
| 62 |
},
|
| 63 |
-
"
|
| 64 |
-
"pid":
|
| 65 |
-
"returncode":
|
| 66 |
},
|
| 67 |
-
"
|
| 68 |
-
"pid":
|
| 69 |
-
"returncode":
|
| 70 |
},
|
| 71 |
-
"
|
| 72 |
-
"pid":
|
| 73 |
-
"returncode":
|
| 74 |
}
|
| 75 |
}
|
| 76 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"utc": "2026-10-24T04:11:35Z",
|
| 3 |
+
"stage": "indexing_and_production",
|
| 4 |
"verified": 26,
|
| 5 |
"counts": {
|
| 6 |
"26b03a8ae47d": 1,
|
|
|
|
| 37 |
"verified_pending_cleanup": 0,
|
| 38 |
"processes": {
|
| 39 |
"index-source": {
|
| 40 |
+
"pid": 16190,
|
| 41 |
"returncode": null
|
| 42 |
},
|
| 43 |
"index-global_style1": {
|
| 44 |
+
"pid": 16191,
|
| 45 |
"returncode": null
|
| 46 |
},
|
| 47 |
"index-global_style2": {
|
| 48 |
+
"pid": 16192,
|
| 49 |
"returncode": null
|
| 50 |
},
|
| 51 |
+
"gpu-0": {
|
| 52 |
+
"pid": 16193,
|
| 53 |
+
"returncode": null
|
| 54 |
},
|
| 55 |
+
"gpu-1": {
|
| 56 |
+
"pid": 16194,
|
| 57 |
+
"returncode": null
|
| 58 |
},
|
| 59 |
+
"gpu-2": {
|
| 60 |
+
"pid": 16195,
|
| 61 |
+
"returncode": null
|
| 62 |
},
|
| 63 |
+
"gpu-3": {
|
| 64 |
+
"pid": 16196,
|
| 65 |
+
"returncode": null
|
| 66 |
},
|
| 67 |
+
"gpu-4": {
|
| 68 |
+
"pid": 16197,
|
| 69 |
+
"returncode": null
|
| 70 |
},
|
| 71 |
+
"gpu-5": {
|
| 72 |
+
"pid": 16198,
|
| 73 |
+
"returncode": null
|
| 74 |
}
|
| 75 |
}
|
| 76 |
}
|