File size: 3,080 Bytes
4ad9219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""在训练前以完整内容审计冻结统计聚类,局部核查另存且不能进入正式CI。"""
import argparse
import json
from pathlib import Path
import sys
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT));sys.path.insert(0,str(ROOT/'scripts'))
from download_assets import atomic,sha
from prepare_online_manifest import identity
from cgvm.benchmark_data import questions
from cgvm.source_clusters import dependency_clusters


def prepare(allow_partial=False):
    overlap_path=ROOT/'provenance/content_overlap_audit.json';overlap=json.loads(overlap_path.read_text())
    if not overlap['full_required_coverage'] and not allow_partial:
        raise ValueError('完整内容指纹未匹配完毕,不能冻结正式源依赖聚类')
    from audit_eval_identity import audit as audit_identity
    identity_path,identity_audit=audit_identity()
    known_parents=identity_audit['known_public_parent_by_eval_source']
    released={}
    for benchmark in ('ovobench','streamingbench'):
        for q in questions(benchmark):
            prefix='ovo/' if benchmark=='ovobench' else 'streaming/'
            label=identity(q['source_video']) if benchmark=='ovobench' else 'released_streaming:'+q['source_video']
            label=known_parents.get(prefix+q['source_video'],label)
            released[prefix+q['source_video']]=label
    inventory_path=ROOT/'provenance/eval_media_inventory.json'
    inventory=json.loads(inventory_path.read_text())
    hashes={key:inventory[key]['sha256'] for key in released}
    value=dependency_clusters(released,overlap['overlap_edges'],hashes)
    value.update(passed=bool(overlap['full_required_coverage']),partial=not overlap['full_required_coverage'],
        source_videos=len(released),eval_manifest_sha256=sha(ROOT/'manifests/eval_questions.jsonl'),
        content_overlap_report_sha256=sha(overlap_path),statistics_protocol_sha256=sha(ROOT/'configs/statistics.frozen.json'),
        eval_media_inventory_sha256=sha(inventory_path),
        exact_media_identity_audit_sha256=sha(identity_path),
        rule='normalized_ID_and_exact_media_SHA_metadata_union; all_existing_frozen_content_protocol_edges_no_additional_tuned_threshold',
        predictions_or_accuracy_read=False,
        boundary='dependency_clustering_can_merge_shared_intros_and_cannot_identify_all_nonoverlapping_parent_clips')
    name='eval_source_cluster_audit'+('.partial' if value['partial'] else '')+'.json'
    target=ROOT/'provenance'/name
    if target.exists() and not value['partial'] and json.loads(target.read_text())!=value:
        raise FileExistsError('不可覆盖不同的正式源依赖聚类')
    atomic(target,value)
    print(json.dumps({key:value[key] for key in ('passed','partial','source_videos','released_source_clusters','dependency_clusters','shared_sequence_pairs')}),flush=True)
    return target,value


if __name__=='__main__':
    parser=argparse.ArgumentParser();parser.add_argument('--allow-partial',action='store_true');args=parser.parse_args()
    prepare(args.allow_partial)