File size: 1,557 Bytes
977b06e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Build the matched-random control by permuting residual masses per trajectory."""

from __future__ import annotations

import argparse
import json
from pathlib import Path

from starVLA.dataloader.infoflow_sampler import ValidAnchorManifest
from starVLA.dataloader.temporal_proposal import TemporalProposal
from starVLA.scoring.matched_random import build_matched_random_proposal


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("--manifest", type=Path, required=True)
    parser.add_argument("--residual-proposal", type=Path, required=True)
    parser.add_argument("--output", type=Path, required=True)
    parser.add_argument("--permutation-seed", type=int, required=True)
    args = parser.parse_args()

    manifest = ValidAnchorManifest.load(args.manifest)
    residual = TemporalProposal.load(args.residual_proposal, manifest)
    matched = build_matched_random_proposal(
        manifest=manifest,
        residual_proposal=residual,
        permutation_seed=args.permutation_seed,
    )
    matched.save(args.output)
    print(
        json.dumps(
            {
                "status": "complete",
                "manifest_sha256": manifest.sha256,
                "source_proposal_sha256": residual.sha256,
                "matched_random_proposal_sha256": matched.sha256,
                "permutation_seed": args.permutation_seed,
                "output": str(args.output.resolve()),
            },
            indent=2,
            sort_keys=True,
        )
    )


if __name__ == "__main__":
    main()