Skip to content

Commit

Permalink
build docker args with list.append
Browse files Browse the repository at this point in the history
instead of constructing new list objects every time the list has items
appended to it, use python's list mutator functions (append and extend)
  • Loading branch information
cg2v committed Dec 13, 2024
1 parent 92ae12f commit ce87fcf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions vmms/localDocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork):
os.getenv("DOCKER_TANGO_HOST_VOLUME_PATH"), instanceName
)
args = ["docker", "run", "--name", instanceName, "-v"]
args = args + ["%s:%s" % (volumePath, "/home/mount")]
args.append("%s:%s" % (volumePath, "/home/mount"))
if vm.cores:
args = args + [f"--cpus={vm.cores}"]
args.append(f"--cpus={vm.cores}")
if vm.memory:
args = args + ["-m", f"{vm.memory}m"]
args.extend(("-m", f"{vm.memory}m"))
if disableNetwork:
args = args + ["--network", "none"]
args = args + [vm.image]
args = args + ["sh", "-c"]
args.append("--network", "none")
args.append(vm.image)
args.extend(("sh", "-c"))

autodriverCmd = (
"autodriver -u %d -f %d -t %d -o %d autolab > output/feedback 2>&1"
Expand All @@ -176,11 +176,11 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork):
)
)

args = args + [
args.append(
'cp -r mount/* autolab/; su autolab -c "%s"; \
cp output/feedback mount/feedback'
% autodriverCmd
]
)

self.log.debug("Running job: %s" % str(args))
ret = timeout(args, runTimeout * 2)
Expand Down

0 comments on commit ce87fcf

Please sign in to comment.