Skip to content

Commit

Permalink
Merge pull request #1455 from rdeviti/tidy-output
Browse files Browse the repository at this point in the history
tidy output for remote execution
  • Loading branch information
mkskeller authored Jul 25, 2024
2 parents a3837c5 + 88418ab commit f43dc3e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
31 changes: 29 additions & 2 deletions Compiler/compilerLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ def build_option_parser(self):
dest="hostfile",
help="hosts to execute with",
)
parser.add_option(
"-t",
"--tidy_output",
action="store_true",
dest="tidy_output",
help="make output prints tidy and grouped by party (note: delays the prints)",
)
else:
parser.add_option(
"-E",
Expand Down Expand Up @@ -618,6 +625,12 @@ def run_with_error(i):

import threading
import random
import io

def run_and_capture_outputs(outputs, fn, i):
out = fn(i)
outputs[i] = out

threads = []
for i in range(len(hosts)):
threads.append(threading.Thread(target=run_with_error, args=(i,)))
Expand All @@ -628,6 +641,14 @@ def run_with_error(i):

# execution
threads = []

# tidy up output prints
hide_option = False
if self.options.tidy_output:
outputs = []
for i in range(len(connections)):
outputs += [""]
hide_option = True
# random port numbers to avoid conflict
port = 10000 + random.randrange(40000)
if '@' in hostnames[0]:
Expand All @@ -642,9 +663,15 @@ def run_with_error(i):
run = lambda i: connections[i].run(
"cd %s; ./%s -p %d %s -h %s -pn %d %s" % \
(destinations[i], vm, i, self.prog.name, party0, port,
' '.join(args + N)))
threads.append(threading.Thread(target=run, args=(i,)))
' '.join(args + N)), hide=hide_option)
if self.options.tidy_output:
threads.append(threading.Thread(target=run_and_capture_outputs, args=(outputs, run, i,)))
else:
threads.append(threading.Thread(target=run, args=(i,)))
for thread in threads:
thread.start()
for thread in threads:
thread.join()
if self.options.tidy_output:
for out in outputs:
print(out)
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,15 @@ There are three ways of running computation:
```

If <path> does not start with `/` (only one `/` after the
hostname), the path with be relative to the home directory of the
hostname), the path will be relative to the home directory of the
user. Otherwise (`//` after the hostname it will be relative to the
root directory.

It is assumed that the SSH login is possible without password.

Adding the compiler option `-t` (`--tidy_output`) groups the output prints by
party; however, it delays the outputs until the execution is finished.

Even with the integrated execution it is important to keep in mind
that there are two different phases, the compilation and the run-time
phase. Any secret data is only available in the second phase, when the
Expand Down

0 comments on commit f43dc3e

Please sign in to comment.