def do_test_mpi_run_env_override(self, sysenv, argenv, env_var, expected): if not mpi_available(): self.skipTest("MPI is not available") cmd = ['cmd'] settings = self.minimal_settings def mpi_impl_flags(tcp, env=None): return ["--mock-mpi-impl-flags"], ["--mock-mpi-binding-args"] with mock.patch("horovod.runner.mpi_run._get_mpi_implementation_flags", side_effect=mpi_impl_flags),\ mock.patch("horovod.runner.mpi_run.safe_shell_exec.execute", return_value=0) as execute,\ override_env(sysenv): mpi_run(settings, None, argenv, cmd) # assert the env variable in the execute's env self.assertIn('env', execute.call_args.kwargs) self.assertEqual(execute.call_args.kwargs['env'].get(env_var), expected)
def test_host_hash(self): hash = host_hash() # host_hash should consider CONTAINER_ID environment variable with override_env({'CONTAINER_ID': 'a container id'}): self.assertNotEqual(host_hash(), hash) self.assertEqual(host_hash(), hash)