class_docstr: Integration tests for horovod.runner.
class_docstr_tok: ["Integration","tests","for","horovod.runner","."]
code: def horovod_args(self, mode, controller, run_func=None, command=None):
      if mode == "local":
          local_hosts = ["localhost", "127.0.0.1"]
          remote_hosts = []
      elif mode == "remote":
          local_hosts = []
          remote_hosts = ["localhost", "127.0.0.1"]
      else:
          local_hosts = ["localhost"]
          remote_hosts = ["127.0.0.1"]
      hosts = local_hosts.copy()
      hosts.extend(remote_hosts)
  
      if remote_hosts:
          ssh_works = _check_all_hosts_ssh_successful(
              remote_hosts, fn_cache=None
          )
          if not ssh_works:
              self.skipTest(
                  "password-less ssh to {} is required for this test".format(
                      " and ".join(remote_hosts)
                  )
              )
  
      hargs = _HorovodArgs()
      hargs.num_proc = 4
      hargs.hosts = ",".join(["{}:2".format(host) for host in hosts])
      hargs.use_gloo = controller == "gloo"
      hargs.use_mpi = controller == "mpi"
      hargs.run_func = run_func
      hargs.command = [command] if command else None
      hargs.nics = []
      hargs.verbose = 2
      hargs.disable_cache = True
  
      stdout = io.StringIO()
      try:
          with capture(stdout=stdout):
              with mock.patch(
                  "horovod.runner.launch.network.filter_local_addresses",
                  side_effect=lambda hosts: [
                      host for host in hosts if host not in local_hosts
                  ],
              ), mock.patch(
                  "horovod.runner.gloo_run.network.get_local_host_addresses",
                  return_value=local_hosts,
              ), mock.patch(
                  "horovod.runner.gloo_run.network.resolve_host_address",
                  side_effect=lambda host: host,
              ), mock.patch(
                  "horovod.runner.mpi_run.os.execve"
              ) as exec:
                  yield hargs, exec
      finally:
          stdout = stdout.readlines()
          print("".join(stdout), file=sys.stdout)
  
      if mode == "local":
          self.assertIn("Remote host found: \n", stdout)
          self.assertIn(
              "All hosts are local, finding the interfaces with address 127.0.0.1\n",
              stdout,
          )
          self.assertEqual(
              1,
              len(
                  [
                      line
                      for line in stdout
                      if line.startswith("Local interface found ")
                  ]
              ),
          )
      elif mode == "mixed":
          self.assertIn("Remote host found: 127.0.0.1\n", stdout)
      elif mode == "remote":
          self.assertIn(
              "Remote host found: localhost 127.0.0.1\n", stdout
          )
      else:
          raise RuntimeError("unknown mode {}".format(mode))
  
      if mode in ["mixed", "remote"]:
          self.assertIn("Checking ssh on all remote hosts.\n", stdout)
          self.assertIn(
              "SSH was successful into all the remote hosts.\n", stdout
          )
          self.assertIn(
              "Testing interfaces on all the hosts.\n", stdout
          )
          self.assertIn("Launched horovod server.\n", stdout)
          self.assertEqual(
              2,
              len(
                  [
                      line
                      for line in stdout
                      if line.startswith(
                          "Launching horovod task function: "
                      )
                  ]
              ),
          )
          self.assertEqual(
              1,
              len(
                  [
                      line
                      for line in stdout
                      if line.startswith(
                          "Launching horovod task function: ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no 127.0.0.1 "
                      )
                  ]
              ),
              stdout,
          )
          if mode == "remote":
              self.assertEqual(
                  1,
                  len(
                      [
                          line
                          for line in stdout
                          if line.startswith(
                              "Launching horovod task function: ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no localhost "
                          )
                      ]
                  ),
              )
          else:
              self.assertEqual(
                  1,
                  len(
                      [
                          line
                          for line in stdout
                          if line.startswith(
                              "Launching horovod task function: "
                          )
                          and not line.startswith(
                              "Launching horovod task function: ssh"
                          )
                      ]
                  ),
              )
          self.assertIn(
              "Attempted to launch horovod task servers.\n", stdout
          )
          self.assertIn(
              "Waiting for the hosts to acknowledge.\n", stdout
          )
          self.assertIn(
              "Notified all the hosts that the registration is complete.\n",
              stdout,
          )
          self.assertIn(
              "Waiting for hosts to perform host-to-host interface checking.\n",
              stdout,
          )
          self.assertIn(
              "Host-to-host interface checking successful.\n", stdout
          )
          self.assertIn(
              "Interfaces on all the hosts were successfully checked.\n",
              stdout,
          )
          self.assertEqual(
              1,
              len(
                  [
                      line
                      for line in stdout
                      if line.startswith("Common interface found: ")
                  ]
              ),
          )
  
imports: import contextlib
  import io
  import itertools
  import os
  import sys
  import warnings
  import mock
  from parameterized import parameterized
  import pytest
  import unittest
  from horovod.common.util import gloo_built, mpi_built
  from horovod.runner.common.util import safe_shell_exec
  from horovod.runner import _HorovodArgs
  from horovod.runner.launch import _check_all_hosts_ssh_successful, _run
  from horovod.runner.mpi_run import mpi_available
  from common import capture
label_desc: Use image node_id 2 for calling the StaticRunTests obj's underlying member method code with example usage: obj.horovod_args(mode, controller, run_func, command) without return types