File size: 1,134 Bytes
f7fef32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import argparse
import subprocess
from pathlib import Path


def main() -> None:
    parser = argparse.ArgumentParser(
        description=__doc__,
        # Preserves whitespace in the help text.
        formatter_class=argparse.RawTextHelpFormatter,
    )

    parser.add_argument(
        "--tag", type=str, required=True, help="The git tag for the release"
    )

    args = parser.parse_args()
    tag: str = args.tag

    try:
        subprocess.run(
            ["git", "rev-parse", "--verify", f"refs/tags/{tag}"],
            check=True,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )
    except subprocess.CalledProcessError:
        raise SystemExit(f"Error: Git tag '{tag}' does not exist.")

    repo_root = Path(__file__).parent.parent.resolve()

    command = f"gsutil cp -r {repo_root / "models"} gs://moz-model-hub/mozilla/static-embeddings/{tag}/"

    print(f"Uploading models")
    print(command)

    subprocess.run(
        command,
        shell=True,
        check=True,
    )

    print("All models have been uploaded successfully.")


if __name__ == "__main__":
    main()