File size: 1,970 Bytes
24aaa76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""r5eval: scoring code of round R5 (experiment J11). No network, no model code.

Everything here is computed from prediction TSVs, manifests, side files of the generator and detector page files.
Frozen inputs (vendored, sha256 checked at import, see frozen.py):
  frozen/scorelib_j2.py     J2 scoring library: norm(), strip_wrappers(), align(), has_loop() (sha256 ae7457a0...)
  frozen/postproc_vlma.py   the fixed post-processing script of the VLM arms (sha256 8b85e10f...; the original file: 77653dee...)

Two hashes. code_sha256() covers the SCORING modules only (what turns predictions into score files); it is part of the incremental key of the
scorer and is written into every score file and verdict. report_code_sha256() covers the REPORTING modules (report cards, verdict, selection,
summary); changing them never forces a re-score. A module belongs to exactly one list below.
"""
import hashlib
import os

VERSION = "r5eval-1.1.0"
_DIR = os.path.dirname(os.path.abspath(__file__))

REPORTING_MODULES = ("cards.py", "verdictlib.py", "verdictgather.py", "selection.py", "summary.py")


def _hash(include):
    h = hashlib.sha256()
    for root, dirs, files in os.walk(_DIR):
        dirs.sort()
        for f in sorted(files):
            if (f.endswith(".py") or f.endswith(".tsv")) and include(os.path.relpath(os.path.join(root, f), _DIR)):
                p = os.path.join(root, f)
                h.update(os.path.relpath(p, _DIR).encode("utf-8"))
                with open(p, "rb") as fh:
                    h.update(fh.read())
    return h.hexdigest()


def code_sha256():
    """sha256 over the scoring modules (every .py and .tsv of the package except the reporting modules). Part of the incremental key of the scorer."""
    return _hash(lambda rel: rel not in REPORTING_MODULES)


def report_code_sha256():
    """sha256 over the reporting modules (report cards, verdict, selection, summary)."""
    return _hash(lambda rel: rel in REPORTING_MODULES)