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()