clientlaunch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/usr/bin/env python3
  2. import argparse
  3. import os
  4. import shlex
  5. import subprocess
  6. import sys
  7. import threading
  8. import yaml
  9. sys.path.insert(0, os.getcwd())
  10. sys.path.insert(1, './../App/')
  11. import mkconfig
  12. # The default manifest file
  13. MANIFEST = "./../App/manifest.yaml"
  14. # The default pubkeys file
  15. PUBKEYS = "./../App/pubkeys.yaml"
  16. # The client binary
  17. CLIENTS = "./clients"
  18. # Client thread allocation
  19. prefix = "numactl -C36-39,76-79 "
  20. #prefix = ""
  21. def launch(config, cmd, threads, lgfile):
  22. cmdline = ''
  23. cmdline += prefix + CLIENTS + " -t " + str(threads) + ""
  24. stdout_file = subprocess.PIPE
  25. if(lgfile):
  26. stdout_file = open(lgfile, "a+")
  27. proc = subprocess.Popen(shlex.split(cmdline) + cmd,
  28. stdin=subprocess.PIPE, stdout=stdout_file,
  29. stderr=subprocess.STDOUT, bufsize=0)
  30. print(cmdline)
  31. proc.stdin.write(config.encode('utf-8'))
  32. if(lgfile):
  33. proc.wait()
  34. stdout_file.close()
  35. else:
  36. while True:
  37. line = proc.stdout.readline()
  38. if not line:
  39. break
  40. print(line.decode('utf-8'), end='', flush=True)
  41. if __name__ == "__main__":
  42. print("In clientlaunch")
  43. aparse = argparse.ArgumentParser(
  44. description='Launch CLIENTS'
  45. )
  46. aparse.add_argument('-m', default=MANIFEST,
  47. help='manifest.yaml file')
  48. aparse.add_argument('-p', default=PUBKEYS,
  49. help='pubkeys.yaml file')
  50. aparse.add_argument('-t', default=1,
  51. help='number of threads')
  52. aparse.add_argument('-z', default=None,
  53. help='override message size')
  54. aparse.add_argument('-u', default=None,
  55. help='override max number of users')
  56. aparse.add_argument('-B', default=None,
  57. help='override max number of outgoing private messages per user per epoch')
  58. aparse.add_argument('-b', default=None,
  59. help='override max number of incoming private messages per user per epoch')
  60. aparse.add_argument('-C', default=None,
  61. help='override max number of outgoing public messages per user per epoch')
  62. aparse.add_argument('-c', default=None,
  63. help='override max number of incoming public messages per user per epoch')
  64. aparse.add_argument('-l', default=None,
  65. help='log file to store client simulator log for an experiment')
  66. aparse.add_argument('-n', nargs='*', help='nodes to include')
  67. aparse.add_argument('cmd', nargs='*', help='experiment to run')
  68. args = aparse.parse_args()
  69. with open(args.m) as mf:
  70. manifest = yaml.safe_load(mf)
  71. params_overrides = {
  72. 'msg_size': args.z,
  73. 'user_count': args.u,
  74. 'priv_out': args.B,
  75. 'priv_in': args.b,
  76. 'pub_out': args.C,
  77. 'pub_in': args.c,
  78. }
  79. config = mkconfig.create_json(args.m, args.p, args.n, params_overrides)
  80. # There must not be any newlines in the config json string
  81. if "\n" in config:
  82. print("Error: config.json must not contain embedded newlines")
  83. sys.exit(1)
  84. # Now add a trailing newline
  85. config += "\n"
  86. launch(config, args.cmd, args.t, args.l)