Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
evanyeyeye committed Dec 8, 2023
1 parent 2e8a680 commit 9839624
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 4 additions & 0 deletions config.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class Config(object):
DOCKER_RM_TIMEOUT = 5
DOCKER_HOST_USER = ""

# Docker autograding container resource limits
DOCKER_CORES_LIMIT = None
DOCKER_MEMORY_LIMIT = None # in MB

# Maximum size for input files in bytes
MAX_INPUT_FILE_SIZE = 10 * 1024 * 1024 * 1024 # 10GB

Expand Down
24 changes: 9 additions & 15 deletions restful_tango/tangoREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,19 @@ def checkFileExists(self, directory, filename, fileMD5):
except IOError:
continue

def createTangoMachine(
self, image, vmms=Config.VMMS_NAME, vmObj={"cores": 1, "memory": 512}
):
def createTangoMachine(self, image, vmms=Config.VMMS_NAME, vmObj=None):
"""createTangoMachine - Creates a tango machine object from image"""
cores = Config.DOCKER_CORES_LIMIT
memory = Config.DOCKER_MEMORY_LIMIT
if vmObj and "cores" in vmObj and "memory" in vmObj:
cores = vmObj["cores"]
memory = vmObj["memory"]
return TangoMachine(
name=image,
vmms=vmms,
image="%s" % (image),
cores=vmObj["cores"],
memory=vmObj["memory"],
cores=cores,
memory=memory,
disk=None,
network=None,
)
Expand Down Expand Up @@ -153,16 +156,7 @@ def convertJobObj(self, dirName, jobObj):
input.append(handinfile)

# VM object
if "cores" in jobObj and "memory" in jobObj:
vm = self.createTangoMachine(
jobObj["image"],
vmObj={
"cores": jobObj["cores"],
"memory": jobObj["memory"],
},
)
else:
vm = self.createTangoMachine(jobObj["image"])
vm = self.createTangoMachine(jobObj["image"])

# for backward compatibility
accessKeyId = None
Expand Down
6 changes: 4 additions & 2 deletions vmms/localDocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ def runJob(self, vm, runTimeout, maxOutputFileSize):
)
args = ["docker", "run", "--name", instanceName, "-v"]
args = args + ["%s:%s" % (volumePath, "/home/mount")]
args = args + [f"--cpus={vm.cores}"]
args = args + ["-m", f"{vm.memory}m"]
if vm.cores:
args = args + [f"--cpus={vm.cores}"]
if vm.memory:
args = args + ["-m", f"{vm.memory}m"]
args = args + [vm.image]
args = args + ["sh", "-c"]

Expand Down

0 comments on commit 9839624

Please sign in to comment.