class_docstr: This class represents a single execution of a model with a given set of hyper-parameters. It takes care of
  of managing the model process and standardizing the results.
class_docstr_tok: ["This","class","represents","a","single","execution","of","a","model","with","a","given","set","of","hyper-parameters",".","It","takes","care","of","of","managing","the","model","process","and","standardizing","the","results","."]
docstr: This function starts a subprocess to execute a model.
  
  :return: The subprocess.Popen object representing the subprocess. Also stored in self.process
docstr_tok: ["This","function","starts","a","subprocess","to","execute","a","model",".",":","return",":","The","subprocess.Popen","object","representing","the","subprocess",".","Also","stored","in","self.process"]
code: def startSubprocess(self):
      """
      This function starts a subprocess to execute a model.
  
      :return: The subprocess.Popen object representing the subprocess. Also stored in self.process
      """
      if self.config["type"] == "python_function":
          process = subprocess.Popen(
              ["python3", "-c", self.createPythonFunctionScript()],
              stdout=subprocess.PIPE,
              stderr=subprocess.STDOUT,
          )
          atexit.register(lambda: process.kill())
  
          # Set process affinities - hypermax in one, the model in the rest. Prevents them from causing cache conflicts.
          # if psutil.cpu_count() > 2:
          #     processUtil = psutil.Process(process.pid)
          #     processUtil.cpu_affinity([k for k in range(psutil.cpu_count())])
          # processUtil = psutil.Process(os.getpid())
          # processUtil.cpu_affinity([psutil.cpu_count() - 1])
  
          self.process = process
          self.startTime = datetime.datetime.now()
          return process
      elif self.config["type"] == "remote":
          host = self.config["hosts"][
              self.worker_n % len(self.config["hosts"])
          ]
  
          # First synchronize files to the host.
          if "rsync" in self.config:
              fromDirectory = self.config["rsync"]["from"]
              if fromDirectory[-1] != "/":
                  fromDirectory = (
                      fromDirectory + "/"
                  )  # We ensure a trailing slash. Without it, rsync will behave differently.
  
              try:
                  subprocess.run(
                      [
                          "rsync",
                          "-rac",
                          fromDirectory,
                          host + ":" + self.config["rsync"]["to"],
                      ]
                  )
              except OSError as e:
                  if (
                      e.errno == os.errno.ENOENT
                  ):  # Rsync doesn't exist, use the slower scp command.
                      subprocess.run(
                          [
                              "scp",
                              "-r",
                              fromDirectory,
                              host + ":" + self.config["rsync"]["to"],
                          ]
                      )
                  else:
                      raise
  
          process = subprocess.Popen(
              ["ssh", host, self.config["command"]],
              stdout=subprocess.PIPE,
              stderr=subprocess.STDOUT,
              stdin=subprocess.PIPE,
          )
          atexit.register(lambda: process.kill())
  
          newParams = dict(self.parameters)
          newParams["$scriptToken"] = self.generateScriptToken()
  
          process.stdin.write(
              bytes(json.dumps(newParams) + "\n\n", "utf8")
          )
          process.stdin.flush()
  
          self.process = process
          self.startTime = datetime.datetime.now()
          return process
  
file_path: hypermax/hypermax/execution.py
imports: import subprocess
  import json
  import atexit
  import jsonschema
  import psutil
  import sys
  import random
  import time
  import datetime
  import os
label_desc: Use image node_id 5 for calling the Execution obj's underlying member method code with example usage: obj.startSubprocess() and returns: process, process