Datasets:
Refresh verified six-GPU manifest: 142 tuples
Browse files- README.md +3 -3
- pipeline/local_media.py +144 -0
- pipeline/manifest_guard.py +5 -0
- pipeline/pipeline.py +14 -10
- pipeline/reconcile_remote.py +61 -0
- pipeline/root_supervisor.py +105 -0
- pipeline/sixgpu_publish.py +11 -1
- progress/sixgpu-status.json +58 -23
README.md
CHANGED
|
@@ -32,7 +32,7 @@ dataset_info:
|
|
| 32 |
|
| 33 |
Tuples: original video, original-video depth, style video, and the unchanged editing instruction.
|
| 34 |
|
| 35 |
-
Current verified tuples: **
|
| 36 |
|
| 37 |
Source: [QingyanBai/Ditto-1M](https://huggingface.co/datasets/QingyanBai/Ditto-1M), revision `aac1417418d8f7e77d4e257d5620c36b2c3a00e8`. Attribution: Qingyan Bai et al., *Ditto: Scaling Instruction-Based Video Editing with a High-Quality Synthetic Dataset*. Source license CC BY-NC-SA 4.0 is retained for this derivative dataset. The original media are unmodified. Depth was estimated using [depth-anything/DA3-LARGE](https://huggingface.co/depth-anything/DA3-LARGE).
|
| 38 |
|
|
@@ -52,9 +52,9 @@ Current worker explicitly reports an error for variable-frame-rate clips, >160-f
|
|
| 52 |
|
| 53 |
`data/<style_id>/<id>/{source.mp4,depth.mp4,edited.mp4,depth.json,filter.json,record.json}`. Each sample is committed atomically, then all remote file sizes and SHA256 values are verified at the immutable commit. Only verified samples count toward quotas and become eligible for local deletion. Immutable media URLs and original instructions are in `metadata.jsonl`.
|
| 54 |
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
## Measured pilot
|
| 60 |
|
|
|
|
| 32 |
|
| 33 |
Tuples: original video, original-video depth, style video, and the unchanged editing instruction.
|
| 34 |
|
| 35 |
+
Current verified tuples: **142**. Target: 8,400 accepted tuples; processing is ongoing.
|
| 36 |
|
| 37 |
Source: [QingyanBai/Ditto-1M](https://huggingface.co/datasets/QingyanBai/Ditto-1M), revision `aac1417418d8f7e77d4e257d5620c36b2c3a00e8`. Attribution: Qingyan Bai et al., *Ditto: Scaling Instruction-Based Video Editing with a High-Quality Synthetic Dataset*. Source license CC BY-NC-SA 4.0 is retained for this derivative dataset. The original media are unmodified. Depth was estimated using [depth-anything/DA3-LARGE](https://huggingface.co/depth-anything/DA3-LARGE).
|
| 38 |
|
|
|
|
| 52 |
|
| 53 |
`data/<style_id>/<id>/{source.mp4,depth.mp4,edited.mp4,depth.json,filter.json,record.json}`. Each sample is committed atomically, then all remote file sizes and SHA256 values are verified at the immutable commit. Only verified samples count toward quotas and become eligible for local deletion. Immutable media URLs and original instructions are in `metadata.jsonl`.
|
| 54 |
|
| 55 |
+
Source archives are downloaded, SHA256-verified, and extracted on the Pod root disk before processing. Six GPU workers filter full videos and generate DA3 depth; accepted tuples are uploaded asynchronously and verified at immutable commits before processing scratch is removed. Source archives and extracted input videos remain on the root disk. SQLite runs locally; standalone database snapshots and verification receipts persist on the network volume.
|
| 56 |
|
| 57 |
+
Historical pilot and range-index benchmarks are retained for provenance. The current root-disk pipeline downloads the source, global_style1 and global_style2 split archives at the fixed source revision, then reads extracted files directly. On startup it reconciles missing local checkpoints from the remote verified manifest; publication rejects any manifest that would omit existing remote samples.
|
| 58 |
|
| 59 |
## Measured pilot
|
| 60 |
|
pipeline/local_media.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Root-disk split archives, bounded resumable downloads and safe extraction."""
|
| 2 |
+
import concurrent.futures as cf
|
| 3 |
+
import fcntl
|
| 4 |
+
import hashlib
|
| 5 |
+
import io
|
| 6 |
+
import json
|
| 7 |
+
import os
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import shutil
|
| 10 |
+
import sqlite3
|
| 11 |
+
import tarfile
|
| 12 |
+
import threading
|
| 13 |
+
import time
|
| 14 |
+
|
| 15 |
+
REPO = 'QingyanBai/Ditto-1M'
|
| 16 |
+
REV = 'aac1417418d8f7e77d4e257d5620c36b2c3a00e8'
|
| 17 |
+
ROOT = Path('/opt/styleedit-root-20261025')
|
| 18 |
+
CATEGORIES = ['source', 'global_style1', 'global_style2']
|
| 19 |
+
|
| 20 |
+
def local_download(row, side, destination, root):
|
| 21 |
+
root = Path(root).resolve()
|
| 22 |
+
source = (root / row[side+'_path']).resolve()
|
| 23 |
+
if root not in source.parents:
|
| 24 |
+
raise ValueError('Media path escapes root')
|
| 25 |
+
if not source.is_file() or not 0 < source.stat().st_size < 200*1024**2:
|
| 26 |
+
raise ValueError('Missing or invalid extracted media: '+str(source))
|
| 27 |
+
destination = Path(destination)
|
| 28 |
+
shutil.copyfile(source, destination)
|
| 29 |
+
return {'local_bytes': source.stat().st_size, 'downloaded_bytes': 0}
|
| 30 |
+
|
| 31 |
+
class SplitReader(io.RawIOBase):
|
| 32 |
+
def __init__(self, parts):
|
| 33 |
+
self.parts = iter(parts)
|
| 34 |
+
self.current = None
|
| 35 |
+
def readable(self): return True
|
| 36 |
+
def readinto(self, buffer):
|
| 37 |
+
while True:
|
| 38 |
+
if self.current is None:
|
| 39 |
+
try: self.current = open(next(self.parts), 'rb')
|
| 40 |
+
except StopIteration: return 0
|
| 41 |
+
count = self.current.readinto(buffer)
|
| 42 |
+
if count: return count
|
| 43 |
+
self.current.close(); self.current = None
|
| 44 |
+
def close(self):
|
| 45 |
+
if self.current: self.current.close()
|
| 46 |
+
super().close()
|
| 47 |
+
|
| 48 |
+
def extract_archive(parts, root, progress=None, reserve_bytes=50*1024**3):
|
| 49 |
+
root = Path(root).resolve(); root.mkdir(parents=True, exist_ok=True)
|
| 50 |
+
count = size = 0
|
| 51 |
+
with SplitReader(parts) as raw, io.BufferedReader(raw, 4*1024**2) as stream:
|
| 52 |
+
with tarfile.open(fileobj=stream, mode='r|gz') as archive:
|
| 53 |
+
for member in archive:
|
| 54 |
+
path = (root/member.name).resolve()
|
| 55 |
+
if root not in path.parents and path != root:
|
| 56 |
+
raise ValueError('Unsafe archive path: '+member.name)
|
| 57 |
+
if member.isdir(): continue
|
| 58 |
+
if not member.isfile(): raise ValueError('Unsupported archive member: '+member.name)
|
| 59 |
+
if shutil.disk_usage(root).free < member.size + reserve_bytes:
|
| 60 |
+
raise RuntimeError('Root disk reserve reached; no input deleted')
|
| 61 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 62 |
+
# Atomic rename prevents processing a partially extracted video.
|
| 63 |
+
temporary = path.with_name(path.name+'.extracting')
|
| 64 |
+
with archive.extractfile(member) as source, temporary.open('wb') as output:
|
| 65 |
+
shutil.copyfileobj(source, output, 4*1024**2)
|
| 66 |
+
if temporary.stat().st_size != member.size: raise EOFError(member.name)
|
| 67 |
+
os.replace(temporary, path)
|
| 68 |
+
count += 1; size += member.size
|
| 69 |
+
if progress and count % 500 == 0: progress(count, size)
|
| 70 |
+
# Drain gzip so its trailer/CRC is checked even after tar end markers.
|
| 71 |
+
# tarfile's gzip stream has already read through all members; compressed
|
| 72 |
+
# SHA256 verification is also performed before extraction.
|
| 73 |
+
return {'files':count, 'bytes':size}
|
| 74 |
+
|
| 75 |
+
def download_all():
|
| 76 |
+
import requests
|
| 77 |
+
ROOT.mkdir(parents=True, exist_ok=True)
|
| 78 |
+
run_lock=(ROOT/'download.lock').open('a')
|
| 79 |
+
fcntl.flock(run_lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
| 80 |
+
manifest_path = ROOT/'archive-manifest.json'
|
| 81 |
+
if manifest_path.exists(): entries = json.loads(manifest_path.read_text())
|
| 82 |
+
else:
|
| 83 |
+
response = requests.get(f'https://huggingface.co/api/datasets/{REPO}/tree/{REV}', params={'recursive':'true','limit':1000}, timeout=60)
|
| 84 |
+
response.raise_for_status()
|
| 85 |
+
entries = [r for r in response.json() if any(r['path'].startswith('videos/'+c+'/') for c in CATEGORIES) and r['type']=='file']
|
| 86 |
+
if not entries or any(not r.get('lfs',{}).get('oid') for r in entries):
|
| 87 |
+
raise RuntimeError('Archive SHA256 metadata unavailable')
|
| 88 |
+
manifest_path.write_text(json.dumps(entries, indent=2))
|
| 89 |
+
db = sqlite3.connect(ROOT/'downloads.sqlite', check_same_thread=False)
|
| 90 |
+
db.execute('CREATE TABLE IF NOT EXISTS chunks(path TEXT,start INTEGER,size INTEGER,PRIMARY KEY(path,start))'); db.commit()
|
| 91 |
+
lock = threading.Lock(); block = 32*1024**2
|
| 92 |
+
completed = [0]; started=time.monotonic()
|
| 93 |
+
def chunk(entry, target, start, length):
|
| 94 |
+
with lock:
|
| 95 |
+
if db.execute('SELECT 1 FROM chunks WHERE path=? AND start=? AND size=?',(entry['path'],start,length)).fetchone(): return
|
| 96 |
+
for attempt in range(8):
|
| 97 |
+
try:
|
| 98 |
+
end=start+length-1
|
| 99 |
+
url=f'https://huggingface.co/datasets/{REPO}/resolve/{REV}/{entry["path"]}'
|
| 100 |
+
response=requests.get(url,params={'styleedit_block':f'{start}-{end}'},headers={'Range':f'bytes={start}-{end}'},timeout=(30,180))
|
| 101 |
+
response.raise_for_status()
|
| 102 |
+
if response.status_code != 206 or response.headers.get('Content-Range') != f'bytes {start}-{end}/{entry["size"]}':
|
| 103 |
+
raise ValueError('Mismatched HTTP byte range')
|
| 104 |
+
if len(response.content)!=length: raise EOFError('Incomplete chunk')
|
| 105 |
+
with target.open('r+b', buffering=0) as out:
|
| 106 |
+
out.seek(start); out.write(response.content); os.fsync(out.fileno())
|
| 107 |
+
with lock:
|
| 108 |
+
db.execute('INSERT OR REPLACE INTO chunks VALUES(?,?,?)',(entry['path'],start,length));db.commit();completed[0]+=length
|
| 109 |
+
return
|
| 110 |
+
except Exception as error:
|
| 111 |
+
if attempt==7: raise
|
| 112 |
+
print('DOWNLOAD_RETRY',entry['path'],start,type(error).__name__,flush=True)
|
| 113 |
+
time.sleep(min(60,2**attempt))
|
| 114 |
+
for category in CATEGORIES:
|
| 115 |
+
marker=ROOT/(category+'.extracted.json')
|
| 116 |
+
if marker.exists(): continue
|
| 117 |
+
files=sorted((e for e in entries if e['path'].startswith('videos/'+category+'/')),key=lambda e:e['path'])
|
| 118 |
+
parts=[]
|
| 119 |
+
for entry in files:
|
| 120 |
+
target=ROOT/'archives'/entry['path'];target.parent.mkdir(parents=True,exist_ok=True);parts.append(target)
|
| 121 |
+
verified=target.with_name(target.name+'.verified')
|
| 122 |
+
if verified.exists() and target.exists() and target.stat().st_size==entry['size']: continue
|
| 123 |
+
if not target.exists():
|
| 124 |
+
with lock: db.execute('DELETE FROM chunks WHERE path=?',(entry['path'],));db.commit()
|
| 125 |
+
with target.open('wb') as out: out.truncate(entry['size'])
|
| 126 |
+
print('DOWNLOAD_START',entry['path'],entry['size'],flush=True)
|
| 127 |
+
with cf.ThreadPoolExecutor(16) as pool:
|
| 128 |
+
futures=[pool.submit(chunk,entry,target,s,min(block,entry['size']-s)) for s in range(0,entry['size'],block)]
|
| 129 |
+
for index,future in enumerate(cf.as_completed(futures),1):
|
| 130 |
+
future.result()
|
| 131 |
+
if index%64==0: print('DOWNLOAD_PROGRESS',entry['path'],index,len(futures),'MiB/s',round(completed[0]/1024**2/max(1,time.monotonic()-started),1),flush=True)
|
| 132 |
+
digest=hashlib.sha256()
|
| 133 |
+
with target.open('rb') as source:
|
| 134 |
+
for data in iter(lambda:source.read(16*1024**2),b''): digest.update(data)
|
| 135 |
+
if digest.hexdigest()!=entry['lfs']['oid']:
|
| 136 |
+
with lock: db.execute('DELETE FROM chunks WHERE path=?',(entry['path'],));db.commit()
|
| 137 |
+
raise ValueError('Archive SHA256 mismatch: '+entry['path'])
|
| 138 |
+
verified.write_text(digest.hexdigest());print('ARCHIVE_VERIFIED',entry['path'],flush=True)
|
| 139 |
+
print('EXTRACT_START',category,flush=True)
|
| 140 |
+
result=extract_archive(parts,ROOT/'media',lambda n,b:print('EXTRACT_PROGRESS',category,n,b,flush=True))
|
| 141 |
+
marker.write_text(json.dumps(result));print('EXTRACT_COMPLETE',category,result,flush=True)
|
| 142 |
+
db.close()
|
| 143 |
+
|
| 144 |
+
if __name__ == '__main__': download_all()
|
pipeline/manifest_guard.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Never replace a remote manifest with an incomplete local checkpoint."""
|
| 2 |
+
def ensure_superset(local_ids, remote_ids):
|
| 3 |
+
missing=set(remote_ids)-set(local_ids)
|
| 4 |
+
if missing:
|
| 5 |
+
raise RuntimeError(f'Local checkpoint misses {len(missing)} remote verified samples; reconcile before publishing')
|
pipeline/pipeline.py
CHANGED
|
@@ -35,6 +35,9 @@ class Run:
|
|
| 35 |
with self.db_lock:
|
| 36 |
old=self.db.execute('SELECT cleaned FROM jobs WHERE id=?',(row['id'],)).fetchone()
|
| 37 |
self.db.execute('INSERT OR REPLACE INTO jobs(id,style_id,source,status,record,verified_at,cleaned) VALUES(?,?,?,?,?,?,?)',(row['id'],row['style_id'],row['source_path'],status,json.dumps(record or row),verified,old[0] if old else 0));self.db.commit()
|
|
|
|
|
|
|
|
|
|
| 38 |
def counts(self):
|
| 39 |
with self.db_lock:return dict(self.db.execute("SELECT style_id,count(*) FROM jobs WHERE status='verified' GROUP BY style_id"))
|
| 40 |
def cleanup(self):
|
|
@@ -62,6 +65,7 @@ class Run:
|
|
| 62 |
api=HfApi()
|
| 63 |
for attempt in range(5):
|
| 64 |
try:
|
|
|
|
| 65 |
commit=api.create_commit(repo_id=self.a.repo,repo_type='dataset',operations=[CommitOperationAdd(path_in_repo=prefix+'/'+name,path_or_fileobj=str(d/name)) for name in files],commit_message='Add verified Ditto + DA3 tuple '+row['id'])
|
| 66 |
infos=api.get_paths_info(self.a.repo,[prefix+'/'+name for name in files],repo_type='dataset',revision=commit.oid)
|
| 67 |
byname={v.path:v for v in infos}
|
|
@@ -80,7 +84,8 @@ class Run:
|
|
| 80 |
if hashlib.sha256(r.content).hexdigest()!=expected['sha256']:raise ValueError('Remote small-file SHA mismatch')
|
| 81 |
receipt={'commit':commit.oid,'verification':'all file sizes and SHA256, LFS SHA256 or actual bytes','seconds':time.monotonic()-t,'record':record}
|
| 82 |
atomic(self.state/'receipts'/(row['id']+'.json'),receipt);self.record(row,'verified',receipt,time.time());self.metrics['upload'].append(receipt['seconds']);print('UPLOAD_VERIFIED',row['id'],round(receipt['seconds'],2),flush=True);return receipt
|
| 83 |
-
except Exception:
|
|
|
|
| 84 |
if attempt==4:raise
|
| 85 |
time.sleep(min(30,2**attempt))
|
| 86 |
def process_depth(self,row,d,filtered,worker):
|
|
@@ -110,11 +115,7 @@ 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 |
-
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,7 +125,7 @@ class Run:
|
|
| 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
|
| 128 |
if not batch:continue
|
| 129 |
groups={};pending={}
|
| 130 |
for row in batch:
|
|
@@ -132,6 +133,9 @@ class Run:
|
|
| 132 |
for side in ['source','edited']:
|
| 133 |
if a.seed_ranges:
|
| 134 |
loc=row['locators'][side];key=(loc['category'],loc['kind'],loc['start'],loc['length']);g=groups.setdefault(key,{'locator':loc,'targets':{}});g['targets'].setdefault(loc['member'],[]).append(str(d/(side+'.mp4')))
|
|
|
|
|
|
|
|
|
|
| 135 |
else:pending[row['id'],side]=pool.submit(indexed_download,row,side,str(d/(side+'.mp4')),a.index_state)
|
| 136 |
if a.seed_ranges:
|
| 137 |
futures={k:pool.submit(seed_download,v['locator'],v['targets']) for k,v in groups.items()}
|
|
@@ -186,7 +190,7 @@ class Run:
|
|
| 186 |
if filterworker:filterworker.close()
|
| 187 |
if depthworker:depthworker.close()
|
| 188 |
self.stop.set();cleaner.join(timeout=5);self.clean_once()
|
| 189 |
-
self.metrics.update(run_id=self.runid,wall_seconds=time.monotonic()-self.started,accepted_for_upload=accepted,verified_counts=self.counts(),new_verified=sum(f.done() and f.exception() is None for f in self.uploads),gpu=(filterworker.ready['gpu'] if filterworker else 'unavailable'),model_startup={'filter':filterworker.ready if filterworker else None,'depth':depthworker.ready if depthworker else None},execution_profile='serial' if a.serial_gpu_stages else 'overlap-v1',video_backend=getattr(a,'video_backend','cuda'),scope='pilot seeded fresh HF ranges' if a.seed_ranges else 'exact indexed full corpus')
|
| 190 |
with self.db_lock:self.metrics['state_counts']=dict(self.db.execute('SELECT status,count(*) FROM jobs GROUP BY status'));self.metrics['verified_not_cleaned']=self.db.execute("SELECT count(*) FROM jobs WHERE status='verified' AND cleaned=0").fetchone()[0]
|
| 191 |
atomic(self.state/('benchmark-'+self.runid+'.json'),self.metrics);atomic(self.state/'summary.json',self.metrics)
|
| 192 |
print('RUN_COMPLETE',json.dumps({k:v for k,v in self.metrics.items() if k not in ['filter','depth','download_groups']}),flush=True)
|
|
@@ -196,9 +200,9 @@ class Run:
|
|
| 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('--
|
| 200 |
if a.index:build_index(a.index,a.index_state);return 0
|
| 201 |
-
if not a.seed_ranges and not a
|
| 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:
|
|
|
|
| 35 |
with self.db_lock:
|
| 36 |
old=self.db.execute('SELECT cleaned FROM jobs WHERE id=?',(row['id'],)).fetchone()
|
| 37 |
self.db.execute('INSERT OR REPLACE INTO jobs(id,style_id,source,status,record,verified_at,cleaned) VALUES(?,?,?,?,?,?,?)',(row['id'],row['style_id'],row['source_path'],status,json.dumps(record or row),verified,old[0] if old else 0));self.db.commit()
|
| 38 |
+
if status in ('verified','reject') and str(self.state).startswith('/opt/styleedit-sixgpu-recovered/'):
|
| 39 |
+
from recovery_state import snapshot_state
|
| 40 |
+
snapshot_state(self.state)
|
| 41 |
def counts(self):
|
| 42 |
with self.db_lock:return dict(self.db.execute("SELECT style_id,count(*) FROM jobs WHERE status='verified' GROUP BY style_id"))
|
| 43 |
def cleanup(self):
|
|
|
|
| 65 |
api=HfApi()
|
| 66 |
for attempt in range(5):
|
| 67 |
try:
|
| 68 |
+
print('UPLOAD_START',row['id'],'attempt',attempt+1,flush=True)
|
| 69 |
commit=api.create_commit(repo_id=self.a.repo,repo_type='dataset',operations=[CommitOperationAdd(path_in_repo=prefix+'/'+name,path_or_fileobj=str(d/name)) for name in files],commit_message='Add verified Ditto + DA3 tuple '+row['id'])
|
| 70 |
infos=api.get_paths_info(self.a.repo,[prefix+'/'+name for name in files],repo_type='dataset',revision=commit.oid)
|
| 71 |
byname={v.path:v for v in infos}
|
|
|
|
| 84 |
if hashlib.sha256(r.content).hexdigest()!=expected['sha256']:raise ValueError('Remote small-file SHA mismatch')
|
| 85 |
receipt={'commit':commit.oid,'verification':'all file sizes and SHA256, LFS SHA256 or actual bytes','seconds':time.monotonic()-t,'record':record}
|
| 86 |
atomic(self.state/'receipts'/(row['id']+'.json'),receipt);self.record(row,'verified',receipt,time.time());self.metrics['upload'].append(receipt['seconds']);print('UPLOAD_VERIFIED',row['id'],round(receipt['seconds'],2),flush=True);return receipt
|
| 87 |
+
except Exception as exc:
|
| 88 |
+
print('UPLOAD_RETRY',row['id'],type(exc).__name__,getattr(getattr(exc,'response',None),'status_code',None),flush=True)
|
| 89 |
if attempt==4:raise
|
| 90 |
time.sleep(min(30,2**attempt))
|
| 91 |
def process_depth(self,row,d,filtered,worker):
|
|
|
|
| 115 |
with cf.ThreadPoolExecutor(a.download_workers) as pool:
|
| 116 |
loads=cf.ThreadPoolExecutor(2)
|
| 117 |
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'))
|
| 118 |
+
for first in range(0,len(rows),a.window):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
for uf in self.uploads:
|
| 120 |
if uf.done() and uf.exception() is not None:raise RuntimeError('Upload failed; retained local media and stopped downloads: '+str(uf.exception()))
|
| 121 |
if a.limit and accepted>=a.limit:break
|
|
|
|
| 125 |
time.sleep(1)
|
| 126 |
current=self.counts()
|
| 127 |
if all(current.get(r['style_id'],0)>=a.per_style for r in allrows):break
|
| 128 |
+
batch=[r for r in rows[first:first+a.window] if current.get(r['style_id'],0)<a.per_style]
|
| 129 |
if not batch:continue
|
| 130 |
groups={};pending={}
|
| 131 |
for row in batch:
|
|
|
|
| 133 |
for side in ['source','edited']:
|
| 134 |
if a.seed_ranges:
|
| 135 |
loc=row['locators'][side];key=(loc['category'],loc['kind'],loc['start'],loc['length']);g=groups.setdefault(key,{'locator':loc,'targets':{}});g['targets'].setdefault(loc['member'],[]).append(str(d/(side+'.mp4')))
|
| 136 |
+
elif getattr(a,'local_media_root',None):
|
| 137 |
+
from local_media import local_download
|
| 138 |
+
pending[row['id'],side]=pool.submit(local_download,row,side,str(d/(side+'.mp4')),a.local_media_root)
|
| 139 |
else:pending[row['id'],side]=pool.submit(indexed_download,row,side,str(d/(side+'.mp4')),a.index_state)
|
| 140 |
if a.seed_ranges:
|
| 141 |
futures={k:pool.submit(seed_download,v['locator'],v['targets']) for k,v in groups.items()}
|
|
|
|
| 190 |
if filterworker:filterworker.close()
|
| 191 |
if depthworker:depthworker.close()
|
| 192 |
self.stop.set();cleaner.join(timeout=5);self.clean_once()
|
| 193 |
+
self.metrics.update(run_id=self.runid,wall_seconds=time.monotonic()-self.started,accepted_for_upload=accepted,verified_counts=self.counts(),new_verified=sum(f.done() and f.exception() is None for f in self.uploads),gpu=(filterworker.ready['gpu'] if filterworker else 'unavailable'),model_startup={'filter':filterworker.ready if filterworker else None,'depth':depthworker.ready if depthworker else None},execution_profile='serial' if a.serial_gpu_stages else 'overlap-v1',video_backend=getattr(a,'video_backend','cuda'),scope='root-disk extracted corpus' if getattr(a,'local_media_root',None) else 'pilot seeded fresh HF ranges' if a.seed_ranges else 'exact indexed full corpus')
|
| 194 |
with self.db_lock:self.metrics['state_counts']=dict(self.db.execute('SELECT status,count(*) FROM jobs GROUP BY status'));self.metrics['verified_not_cleaned']=self.db.execute("SELECT count(*) FROM jobs WHERE status='verified' AND cleaned=0").fetchone()[0]
|
| 195 |
atomic(self.state/('benchmark-'+self.runid+'.json'),self.metrics);atomic(self.state/'summary.json',self.metrics)
|
| 196 |
print('RUN_COMPLETE',json.dumps({k:v for k,v in self.metrics.items() if k not in ['filter','depth','download_groups']}),flush=True)
|
|
|
|
| 200 |
return 0 if success and not self.metrics['errors'] else 2
|
| 201 |
|
| 202 |
def main():
|
| 203 |
+
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('--local-media-root',help='Read source and edited videos extracted on the root disk');a=p.parse_args()
|
| 204 |
if a.index:build_index(a.index,a.index_state);return 0
|
| 205 |
+
if not a.seed_ranges and not getattr(a,'local_media_root',None):
|
| 206 |
dbpath=Path(a.index_state)/'catalog.sqlite'
|
| 207 |
if not dbpath.exists():raise RuntimeError('Build exact archive indexes first; see README.md')
|
| 208 |
with sqlite3.connect(dbpath) as db:
|
pipeline/reconcile_remote.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Recover missing verified state from HF's immutable manifest and media."""
|
| 2 |
+
import concurrent.futures as cf
|
| 3 |
+
import hashlib
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
import sqlite3
|
| 8 |
+
import sys
|
| 9 |
+
import time
|
| 10 |
+
from urllib.parse import urlparse
|
| 11 |
+
|
| 12 |
+
APP=Path('/opt/styleedit-streaming-20261024')
|
| 13 |
+
ROOT=Path('/opt/styleedit-root-20261025')
|
| 14 |
+
STATE=Path('/opt/styleedit-sixgpu-recovered')
|
| 15 |
+
sys.path.insert(0,str(APP))
|
| 16 |
+
|
| 17 |
+
def reconcile():
|
| 18 |
+
import requests
|
| 19 |
+
from huggingface_hub import HfApi,get_token,hf_hub_url
|
| 20 |
+
headers={'Authorization':'Bearer '+get_token()}
|
| 21 |
+
response=requests.get(hf_hub_url('faraway00/StyleEdit','metadata.jsonl',repo_type='dataset'),headers=headers,timeout=90)
|
| 22 |
+
response.raise_for_status();rows=[json.loads(x) for x in response.content.splitlines() if x.strip()]
|
| 23 |
+
existing=set()
|
| 24 |
+
for gpu in range(6):
|
| 25 |
+
with sqlite3.connect(STATE/f'gpu{gpu}'/'jobs.sqlite') as db:
|
| 26 |
+
existing.update(r[0] for r in db.execute("SELECT id FROM jobs WHERE status='verified'"))
|
| 27 |
+
missing=[r for r in rows if r['id'] not in existing]
|
| 28 |
+
if not missing:
|
| 29 |
+
print('REMOTE_CHECKPOINT_CONSISTENT',len(rows),flush=True);return
|
| 30 |
+
assignment={s:i%6 for i,s in enumerate(sorted({r['style_id'] for r in json.loads((APP/'candidates.json').read_text())}))}
|
| 31 |
+
def retrieve(row):
|
| 32 |
+
url=row['provenance'];parsed=urlparse(url)
|
| 33 |
+
if parsed.hostname!='huggingface.co' or not parsed.path.startswith('/datasets/faraway00/StyleEdit/resolve/'):
|
| 34 |
+
raise ValueError('Unexpected provenance origin')
|
| 35 |
+
response=requests.get(url,headers=headers,timeout=90);response.raise_for_status();record=json.loads(response.content)
|
| 36 |
+
if record['id']!=row['id'] or record['style_id']!=row['style_id']:raise ValueError('Record identity mismatch')
|
| 37 |
+
commit=url.split('/resolve/')[1].split('/')[0];prefix='data/'+record['style_id']+'/'+record['id']
|
| 38 |
+
files=dict(record['files']);files['record.json']={'bytes':len(response.content),'sha256':hashlib.sha256(response.content).hexdigest()}
|
| 39 |
+
infos={v.path:v for v in HfApi().get_paths_info('faraway00/StyleEdit',[prefix+'/'+name for name in files],repo_type='dataset',revision=commit)}
|
| 40 |
+
for name,expected in files.items():
|
| 41 |
+
info=infos[prefix+'/'+name]
|
| 42 |
+
if info.size!=expected['bytes']:raise ValueError('Recovered remote size mismatch')
|
| 43 |
+
lfs=getattr(info,'lfs',None)
|
| 44 |
+
if lfs:
|
| 45 |
+
digest=lfs.sha256 if hasattr(lfs,'sha256') else lfs['sha256']
|
| 46 |
+
else:
|
| 47 |
+
content=requests.get(hf_hub_url('faraway00/StyleEdit',prefix+'/'+name,repo_type='dataset',revision=commit),headers=headers,timeout=90);content.raise_for_status();digest=hashlib.sha256(content.content).hexdigest()
|
| 48 |
+
if digest!=expected['sha256']:raise ValueError('Recovered remote SHA256 mismatch')
|
| 49 |
+
record['files']=files
|
| 50 |
+
return {'commit':commit,'record':record,'verification':'all file sizes and SHA256 verified at immutable commit during remote recovery','seconds':0}
|
| 51 |
+
with cf.ThreadPoolExecutor(8) as pool:receipts=list(pool.map(retrieve,missing))
|
| 52 |
+
for receipt in receipts:
|
| 53 |
+
r=receipt['record'];directory=STATE/f"gpu{assignment[r['style_id']]}";(directory/'receipts').mkdir(exist_ok=True)
|
| 54 |
+
temporary=directory/'receipts'/(r['id']+'.tmp');temporary.write_text(json.dumps(receipt));os.replace(temporary,temporary.with_suffix('.json'))
|
| 55 |
+
with sqlite3.connect(directory/'jobs.sqlite') as db:
|
| 56 |
+
db.execute('INSERT OR REPLACE INTO jobs VALUES(?,?,?,?,?,?,?)',(r['id'],r['style_id'],r['source_path'],'verified',json.dumps(receipt),time.time(),1));db.commit()
|
| 57 |
+
from recovery_state import snapshot_state
|
| 58 |
+
for gpu in range(6):snapshot_state(STATE/f'gpu{gpu}')
|
| 59 |
+
print('REMOTE_CHECKPOINT_RECOVERED',len(receipts),flush=True)
|
| 60 |
+
|
| 61 |
+
if __name__=='__main__':reconcile()
|
pipeline/root_supervisor.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Resume six GPU shards from durable receipts after root-disk extraction."""
|
| 2 |
+
import collections
|
| 3 |
+
import fcntl
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
import sqlite3
|
| 8 |
+
import subprocess
|
| 9 |
+
import sys
|
| 10 |
+
import time
|
| 11 |
+
|
| 12 |
+
ROOT=Path('/opt/styleedit-root-20261025')
|
| 13 |
+
APP=Path('/opt/styleedit-streaming-20261024')
|
| 14 |
+
STATE=Path('/opt/styleedit-sixgpu-recovered')
|
| 15 |
+
PERSIST=Path('/workspace/styleedit-streaming-20261024/root-disk-20261025')
|
| 16 |
+
DOWNLOADER=None
|
| 17 |
+
DOWNLOAD_RETRIES=0
|
| 18 |
+
os.environ.update(HF_TOKEN_PATH='/root/.styleedit-hf-token',PYTHONPATH='/opt/depth-anything-3-code/src',HF_HUB_DISABLE_PROGRESS_BARS='1',OMP_NUM_THREADS='4',OPENBLAS_NUM_THREADS='2')
|
| 19 |
+
sys.path.insert(0,str(APP))
|
| 20 |
+
|
| 21 |
+
def atomic(path,value):
|
| 22 |
+
path=Path(path);path.parent.mkdir(parents=True,exist_ok=True)
|
| 23 |
+
temp=path.with_name(path.name+'.tmp');temp.write_text(json.dumps(value,indent=2));os.replace(temp,path)
|
| 24 |
+
|
| 25 |
+
def status(stage,children):
|
| 26 |
+
global DOWNLOADER,DOWNLOAD_RETRIES
|
| 27 |
+
if DOWNLOADER is not None and DOWNLOADER.poll() not in (None,0):
|
| 28 |
+
if DOWNLOAD_RETRIES>=3: raise RuntimeError('Archive download/extraction failed repeatedly; see download.log')
|
| 29 |
+
DOWNLOAD_RETRIES+=1;DOWNLOADER=start_download()
|
| 30 |
+
counts=collections.Counter();states=collections.Counter()
|
| 31 |
+
for gpu in range(6):
|
| 32 |
+
path=STATE/f'gpu{gpu}'/'jobs.sqlite'
|
| 33 |
+
if path.exists():
|
| 34 |
+
with sqlite3.connect(path,timeout=30) as db:
|
| 35 |
+
counts.update(dict(db.execute("SELECT style_id,count(*) FROM jobs WHERE status='verified' GROUP BY style_id")))
|
| 36 |
+
states.update(dict(db.execute('SELECT status,count(*) FROM jobs GROUP BY status')))
|
| 37 |
+
result={'utc':time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime()),'stage':stage,'verified':sum(counts.values()),'counts':dict(counts),'statuses':dict(states),'root_free_bytes':__import__('shutil').disk_usage(ROOT).free,'archives_extracted':[c for c in ['source','global_style1','global_style2'] if (ROOT/(c+'.extracted.json')).exists()],'processes':{str(k):{'pid':v.pid,'returncode':v.poll()} for k,v in children.items()}}
|
| 38 |
+
with sqlite3.connect(ROOT/'downloads.sqlite',timeout=30) as db:
|
| 39 |
+
result['archive_download_bytes']=db.execute('SELECT coalesce(sum(size),0) FROM chunks').fetchone()[0]
|
| 40 |
+
atomic(ROOT/'status.json',result);atomic(STATE/'status.json',result)
|
| 41 |
+
try: atomic(PERSIST/'status.json',result)
|
| 42 |
+
except OSError as error: print('DURABLE_STATUS_RETRY',type(error).__name__,flush=True)
|
| 43 |
+
return result
|
| 44 |
+
|
| 45 |
+
def start_download():
|
| 46 |
+
with (ROOT/'download.log').open('a') as log:
|
| 47 |
+
child=subprocess.Popen([sys.executable,'-u',str(APP/'local_media.py')],stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
|
| 48 |
+
atomic(ROOT/'download-process.json',{'pid':child.pid})
|
| 49 |
+
return child
|
| 50 |
+
|
| 51 |
+
def start(gpu,stage):
|
| 52 |
+
env=dict(os.environ,CUDA_VISIBLE_DEVICES=str(gpu),STYLEEDIT_GPU_LOCK=f'/opt/styleedit-gpu-{gpu}.lock')
|
| 53 |
+
args=[sys.executable,'-u',str(APP/'pipeline.py'),'--local-media-root',str(ROOT/'media'),'--plan',str(ROOT/f'{stage}-gpu{gpu}.json'),'--state',str(STATE/f'gpu{gpu}'),'--scratch',f'/opt/styleedit-sixgpu-scratch/gpu{gpu}','--limit','0','--per-style','100','--window','6','--download-workers','4','--upload-workers','1','--scratch-gib','60','--reserve-gib','50']
|
| 54 |
+
with (ROOT/f'{stage}-gpu{gpu}.log').open('a') as log:
|
| 55 |
+
return subprocess.Popen(args,env=env,stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
|
| 56 |
+
|
| 57 |
+
def main():
|
| 58 |
+
global DOWNLOADER
|
| 59 |
+
ROOT.mkdir(exist_ok=True)
|
| 60 |
+
lock=(ROOT/'supervisor.lock').open('a');fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
| 61 |
+
DOWNLOADER=start_download()
|
| 62 |
+
while not (ROOT/'RESTORED').exists():
|
| 63 |
+
status('restoring_runtime',{});time.sleep(20)
|
| 64 |
+
from huggingface_hub import HfApi
|
| 65 |
+
api=HfApi();print('AUTH_OK',api.whoami()['name'],flush=True);api.auth_check('faraway00/StyleEdit',repo_type='dataset')
|
| 66 |
+
from reconcile_remote import reconcile
|
| 67 |
+
reconcile()
|
| 68 |
+
rows=json.loads((APP/'candidates.json').read_text());assignment={s:i%6 for i,s in enumerate(sorted({r['style_id'] for r in rows}))}
|
| 69 |
+
for gpu in range(6):
|
| 70 |
+
with sqlite3.connect(STATE/f'gpu{gpu}'/'jobs.sqlite') as db:
|
| 71 |
+
if db.execute('PRAGMA quick_check').fetchone()!=('ok',):raise RuntimeError('Damaged recovered database')
|
| 72 |
+
for (sid,) in db.execute("SELECT style_id FROM jobs WHERE status='verified'"):
|
| 73 |
+
if assignment[sid]!=gpu:raise RuntimeError('Recovered style assignment changed')
|
| 74 |
+
shard=[r for r in rows if assignment[r['style_id']]==gpu]
|
| 75 |
+
atomic(ROOT/f'all-gpu{gpu}.json',shard)
|
| 76 |
+
atomic(ROOT/f'global_style1-gpu{gpu}.json',[r for r in shard if r['edited_path'].startswith('global_style1/')])
|
| 77 |
+
import sixgpu_publish
|
| 78 |
+
last_publish=0
|
| 79 |
+
for stage,required in [('global_style1',['source','global_style1']),('all',['source','global_style1','global_style2'])]:
|
| 80 |
+
while not all((ROOT/(c+'.extracted.json')).exists() for c in required):
|
| 81 |
+
status('downloading_extracting_'+stage,{})
|
| 82 |
+
if time.monotonic()-last_publish>300:
|
| 83 |
+
try: sixgpu_publish.publish();last_publish=time.monotonic()
|
| 84 |
+
except Exception as error:print('MANIFEST_RETRY',type(error).__name__,str(error)[:200],flush=True)
|
| 85 |
+
time.sleep(30)
|
| 86 |
+
children={g:start(g,stage) for g in range(6)}
|
| 87 |
+
while any(p.poll() is None for p in children.values()):
|
| 88 |
+
status('processing_'+stage,children)
|
| 89 |
+
if time.monotonic()-last_publish>300:
|
| 90 |
+
try: sixgpu_publish.publish();last_publish=time.monotonic()
|
| 91 |
+
except Exception as error:print('MANIFEST_RETRY',type(error).__name__,str(error)[:200],flush=True)
|
| 92 |
+
time.sleep(30)
|
| 93 |
+
for gpu,child in children.items():
|
| 94 |
+
summary=json.loads((STATE/f'gpu{gpu}'/'summary.json').read_text())
|
| 95 |
+
if summary['errors'] or child.returncode not in (0,2):raise RuntimeError(f'GPU {gpu} failed; outputs preserved, inspect {stage}-gpu{gpu}.log')
|
| 96 |
+
sixgpu_publish.publish()
|
| 97 |
+
complete=all(json.loads((STATE/f'gpu{g}'/'quota-report.json').read_text())['complete'] for g in range(6))
|
| 98 |
+
status('complete' if complete else 'candidate_pool_exhausted',{})
|
| 99 |
+
print('ROOT_PIPELINE_FINISHED',complete,flush=True)
|
| 100 |
+
|
| 101 |
+
if __name__=='__main__':
|
| 102 |
+
try:main()
|
| 103 |
+
except Exception as error:
|
| 104 |
+
atomic(ROOT/'failure.json',{'utc':time.strftime('%Y-%m-%dT%H:%M:%SZ',time.gmtime()),'error':str(error)})
|
| 105 |
+
raise
|
pipeline/sixgpu_publish.py
CHANGED
|
@@ -22,13 +22,23 @@ def publish():
|
|
| 22 |
if not manifest:return
|
| 23 |
manifest.sort(key=lambda r:r['id'])
|
| 24 |
assert len({r['id'] for r in manifest})==len(manifest)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
out=Path('/opt/styleedit-sixgpu-manifest.jsonl')
|
| 26 |
out.write_text(''.join(json.dumps(r,ensure_ascii=False)+'\n' for r in manifest))
|
| 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']:
|
| 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')
|
| 34 |
(ROOT/'manifest-published.json').write_text(json.dumps({'commit':c.oid,'tuples':len(manifest),'time':time.time()}))
|
|
|
|
| 22 |
if not manifest:return
|
| 23 |
manifest.sort(key=lambda r:r['id'])
|
| 24 |
assert len({r['id'] for r in manifest})==len(manifest)
|
| 25 |
+
import requests
|
| 26 |
+
from huggingface_hub import hf_hub_url,get_token
|
| 27 |
+
from manifest_guard import ensure_superset
|
| 28 |
+
remote=requests.get(hf_hub_url('faraway00/StyleEdit','metadata.jsonl',repo_type='dataset'),headers={'Authorization':'Bearer '+get_token()},timeout=60)
|
| 29 |
+
remote.raise_for_status()
|
| 30 |
+
ensure_superset({r['id'] for r in manifest},{json.loads(line)['id'] for line in remote.text.splitlines() if line.strip()})
|
| 31 |
out=Path('/opt/styleedit-sixgpu-manifest.jsonl')
|
| 32 |
out.write_text(''.join(json.dumps(r,ensure_ascii=False)+'\n' for r in manifest))
|
| 33 |
ops=[CommitOperationAdd(path_in_repo='metadata.jsonl',path_or_fileobj=str(out))]
|
| 34 |
status=ROOT/'status.json'
|
| 35 |
if status.exists():ops.append(CommitOperationAdd(path_in_repo='progress/sixgpu-status.json',path_or_fileobj=str(status)))
|
| 36 |
+
for name in ['sixgpu_run.py','sixgpu_publish.py','workers.py','pipeline.py','local_media.py','root_supervisor.py','reconcile_remote.py','manifest_guard.py']:
|
| 37 |
ops.append(CommitOperationAdd(path_in_repo='pipeline/'+name,path_or_fileobj=str(APP/name)))
|
| 38 |
+
template=Path('/opt/styleedit-root-20261025/dataset-card-template.md')
|
| 39 |
+
if template.exists():
|
| 40 |
+
card=template.read_text().replace('{{verified_tuples}}',str(len(manifest)))
|
| 41 |
+
ops.append(CommitOperationAdd(path_in_repo='README.md',path_or_fileobj=card.encode()))
|
| 42 |
c=HfApi().create_commit(repo_id='faraway00/StyleEdit',repo_type='dataset',operations=ops,
|
| 43 |
commit_message=f'Refresh verified six-GPU manifest: {len(manifest)} tuples')
|
| 44 |
(ROOT/'manifest-published.json').write_text(json.dumps({'commit':c.oid,'tuples':len(manifest),'time':time.time()}))
|
progress/sixgpu-status.json
CHANGED
|
@@ -1,41 +1,76 @@
|
|
| 1 |
{
|
| 2 |
-
"utc": "2026-10-25T04:
|
| 3 |
"stage": "downloading_extracting_global_style1",
|
| 4 |
-
"verified":
|
| 5 |
"counts": {
|
| 6 |
-
"
|
| 7 |
-
"
|
| 8 |
-
"
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
"0972e1eed1b3": 1,
|
| 17 |
-
"182ecc60160c":
|
| 18 |
-
"305681c6a53f":
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
"cace0fd21b19": 1,
|
| 20 |
"ec2035ada05d": 1,
|
| 21 |
-
"
|
|
|
|
| 22 |
"18af27ddab58": 1,
|
|
|
|
| 23 |
"52545659e5cb": 1,
|
| 24 |
"5dff93f3a267": 1,
|
| 25 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
"0fee9b184beb": 1,
|
| 27 |
-
"194290896821":
|
|
|
|
|
|
|
| 28 |
"526f7f26e7a6": 1,
|
| 29 |
-
"
|
| 30 |
-
"
|
| 31 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
},
|
| 33 |
"statuses": {
|
| 34 |
"reject": 4,
|
| 35 |
-
"verified":
|
| 36 |
},
|
| 37 |
-
"root_free_bytes":
|
| 38 |
"archives_extracted": [],
|
| 39 |
"processes": {},
|
| 40 |
-
"archive_download_bytes":
|
| 41 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"utc": "2026-10-25T04:57:57Z",
|
| 3 |
"stage": "downloading_extracting_global_style1",
|
| 4 |
+
"verified": 142,
|
| 5 |
"counts": {
|
| 6 |
+
"00e5f0752aae": 1,
|
| 7 |
+
"10ae00528692": 1,
|
| 8 |
+
"26b03a8ae47d": 2,
|
| 9 |
+
"4744afcbd909": 4,
|
| 10 |
+
"5501b7377488": 4,
|
| 11 |
+
"6ea8adbc0823": 3,
|
| 12 |
+
"817d0d364240": 1,
|
| 13 |
+
"baf401925b12": 3,
|
| 14 |
+
"d2bef4453db8": 2,
|
| 15 |
+
"ef610916460f": 2,
|
| 16 |
+
"0423a6080620": 2,
|
| 17 |
+
"2cb8a9c29e3c": 3,
|
| 18 |
+
"3ac416bb5d5d": 3,
|
| 19 |
+
"4d36d1bce511": 1,
|
| 20 |
+
"6f448a5d5b0b": 1,
|
| 21 |
+
"81b0039d0562": 2,
|
| 22 |
+
"9b955dbb5c1b": 4,
|
| 23 |
+
"aceae18cfd54": 4,
|
| 24 |
+
"c3c090430cbb": 2,
|
| 25 |
+
"f67cd2014f0f": 2,
|
| 26 |
+
"09229cb3538e": 3,
|
| 27 |
+
"3ec4685a5ca4": 1,
|
| 28 |
+
"593b6d061243": 4,
|
| 29 |
+
"9fd740550a13": 2,
|
| 30 |
+
"b4b7ccdb3223": 1,
|
| 31 |
+
"c44e535bbe8e": 2,
|
| 32 |
+
"da3f08c0ab94": 1,
|
| 33 |
+
"e4157f8b450b": 6,
|
| 34 |
+
"f67ebc7f1288": 2,
|
| 35 |
"0972e1eed1b3": 1,
|
| 36 |
+
"182ecc60160c": 3,
|
| 37 |
+
"305681c6a53f": 2,
|
| 38 |
+
"43ab900339a0": 1,
|
| 39 |
+
"522b61489406": 1,
|
| 40 |
+
"a55078c730d6": 1,
|
| 41 |
+
"b4c4c14310ba": 1,
|
| 42 |
"cace0fd21b19": 1,
|
| 43 |
"ec2035ada05d": 1,
|
| 44 |
+
"f990050311bc": 13,
|
| 45 |
+
"0bee0e7e6dc5": 2,
|
| 46 |
"18af27ddab58": 1,
|
| 47 |
+
"33286a1a191b": 1,
|
| 48 |
"52545659e5cb": 1,
|
| 49 |
"5dff93f3a267": 1,
|
| 50 |
+
"7ac8d62ccfb2": 1,
|
| 51 |
+
"85246a0d9ced": 3,
|
| 52 |
+
"a56ad3f24408": 1,
|
| 53 |
+
"b5c8be681334": 1,
|
| 54 |
+
"ce16eed69d0e": 12,
|
| 55 |
"0fee9b184beb": 1,
|
| 56 |
+
"194290896821": 4,
|
| 57 |
+
"36f7a34ae77c": 1,
|
| 58 |
+
"453daa7e1ef3": 2,
|
| 59 |
"526f7f26e7a6": 1,
|
| 60 |
+
"810c3bcf0812": 1,
|
| 61 |
+
"8f84dd32762c": 4,
|
| 62 |
+
"a78ae8b77085": 2,
|
| 63 |
+
"b7eb902e7b22": 1,
|
| 64 |
+
"cfdb284d6b07": 3,
|
| 65 |
+
"ee3d28fd4cc8": 3,
|
| 66 |
+
"ff3dbf0e95b5": 1
|
| 67 |
},
|
| 68 |
"statuses": {
|
| 69 |
"reject": 4,
|
| 70 |
+
"verified": 142
|
| 71 |
},
|
| 72 |
+
"root_free_bytes": 2113136685056,
|
| 73 |
"archives_extracted": [],
|
| 74 |
"processes": {},
|
| 75 |
+
"archive_download_bytes": 29024583680
|
| 76 |
}
|