Skip to content

Commit

Permalink
Add cli support for build naming
Browse files Browse the repository at this point in the history
  • Loading branch information
evanyeyeye committed Jan 31, 2024
1 parent 8c6122c commit 61fbb0e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions clients/tango-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@
parser.add_argument("--pool", action="store_true", help=pool_help)
prealloc_help = "Create a pool of instances spawned from a specific image. Must specify key with -k. Modify defaults with --image (autograding_image), --num (2), --vmms (localDocker), --cores (1), and --memory (512)."
parser.add_argument("--prealloc", action="store_true", help=prealloc_help)
build_help = (
"Build a docker image. Must specify key with -k and filename with --filename."
)
build_help = "Build a docker image. Must specify key with -k, image filename with --filename, and image name with --imageName."
parser.add_argument("--build", action="store_true", help=build_help)

parser.add_argument(
Expand All @@ -81,6 +79,7 @@
parser.add_argument(
"--image", default="", help='VM image name (default "autograding_image")'
)
parser.add_argument("--imageName", help="Name for new VM image to be built")
parser.add_argument(
"--infiles",
nargs="+",
Expand Down Expand Up @@ -159,6 +158,13 @@ def checkDeadjobs():
return 0


def checkImageName():
if args.imageName is None:
print("Image name must be specified with --imageName")
return -1
return 0


_tango_protocol = "http"

# open
Expand Down Expand Up @@ -496,15 +502,17 @@ def file_to_dict(file):

def tango_build():
try:
res = checkKey() + checkFilename()
res = checkKey() + checkFilename() + checkImageName()
if res != 0:
raise Exception("Invalid usage: [build] " + build_help)

f = open(args.filename, "rb")
header = {"imageName": args.imageName}
response = requests.post(
"%s://%s:%d/build/%s/"
% (_tango_protocol, args.server, args.port, args.key),
data=f.read(),
headers=header,
)
print("Sent request to %s:%d/build/%s/" % (args.server, args.port, args.key))
print(response.text)
Expand Down

0 comments on commit 61fbb0e

Please sign in to comment.