File size: 1,577 Bytes
dfb774a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
54
55
56
#!/usr/bin/env python3
# Copyright 2026 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

"""Refresh author-owned asset locks and catalog metadata with the installed SDK."""

import argparse
import subprocess
import sys
from pathlib import Path


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        "--cache", type=Path, help="reuse downloaded assets in this Loom cache"
    )
    args = parser.parse_args()
    root = Path(__file__).absolute().parent
    cards = sorted(root.glob("model/*/model.json"))
    if not cards:
        parser.error("no model/*/model.json files found beside this script")
    for card in cards:
        command = [
            sys.executable,
            "-m",
            "loom.model.fetch_main",
            str(card),
            "--update-lock",
            "--all-variants",
            "--no-input",
        ]
        if args.cache is not None:
            command.append("--cache=" + str(args.cache.absolute()))
        subprocess.run(command, check=True)
    subprocess.run(
        [
            sys.executable,
            "-m",
            "loom.model.catalog",
            "--output=" + str(root / "catalog.json"),
            *[
                "--card=" + card.relative_to(root).as_posix() + "=" + str(card)
                for card in cards
            ],
        ],
        check=True,
    )


if __name__ == "__main__":
    main()