forked from pytorch/serve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_upload_release.py
63 lines (57 loc) · 2.02 KB
/
build_upload_release.py
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
57
58
59
60
61
62
63
import os
import sys
from argparse import ArgumentParser
# To help discover local modules
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
sys.path.append(REPO_ROOT)
from ts_scripts.utils import check_ts_version, try_and_handle
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(
"--organization",
type=str,
default="pytorch",
help="The name of the Dockerhub organization where the images will be pushed",
)
parser.add_argument(
"--dry_run",
action="store_true",
help="dry_run will print the commands that will be run without running them",
)
parser.add_argument(
"--cleanup",
action="store_true",
help="Delete all built docker images",
)
args = parser.parse_args()
dry_run = args.dry_run
organization = args.organization
# Upload pytorch/torchserve docker binaries
try_and_handle(f"./build_image.sh -t {organization}/torchserve:latest", dry_run)
try_and_handle(
f"./build_image.sh -g -cv cu121 -t {organization}/torchserve:latest-gpu",
dry_run,
)
try_and_handle(
f"docker tag {organization}/torchserve:latest {organization}/torchserve:latest-cpu",
dry_run,
)
try_and_handle(
f"docker tag {organization}/torchserve:latest {organization}/torchserve:{check_ts_version()}-cpu",
dry_run,
)
try_and_handle(
f"docker tag {organization}/torchserve:latest-gpu {organization}/torchserve:{check_ts_version()}-gpu",
dry_run,
)
for image in [
f"{organization}/torchserve:latest",
f"{organization}/torchserve:latest-cpu",
f"{organization}/torchserve:latest-gpu",
f"{organization}/torchserve:{check_ts_version()}-cpu",
f"{organization}/torchserve:{check_ts_version()}-gpu",
]:
try_and_handle(f"docker push {image}", dry_run)
# Cleanup built images
if args.cleanup:
try_and_handle(f"docker system prune --all --volumes -f", dry_run)