def test_attributes_from_environment_variables():
    """Test that the LSF environment takes the attributes from the environment variables."""
    env = LSFEnvironment()
    assert env.creates_children()
    assert env.master_address() == "10.10.10.0"
    assert env.master_port() == 10234
    assert env.world_size() == 4
    assert env.global_rank() == 3
    assert env.local_rank() == 1
    env.set_global_rank(100)
    assert env.global_rank() == 3
    env.set_world_size(100)
    assert env.world_size() == 4
    assert LSFEnvironment.is_using_lsf()
Exemplo n.º 2
0
def test_attributes_from_environment_variables():
    """Test that the LSF environment takes the attributes from the environment variables."""
    env = LSFEnvironment()
    assert env.creates_processes_externally
    assert env.main_address == "10.10.10.0"
    assert env.main_port == 10234
    assert env.world_size() == 4
    assert env.global_rank() == 3
    assert env.local_rank() == 1
    env.set_global_rank(100)
    assert env.global_rank() == 3
    env.set_world_size(100)
    assert env.world_size() == 4
    assert LSFEnvironment.detect()
def test_attributes_from_environment_variables(tmp_path):
    """Test that the LSF environment takes the attributes from the environment variables."""
    environ = {
        "LSB_DJOB_RANKFILE": _make_rankfile(tmp_path),
        "LSB_JOBID": "1234",
        "JSM_NAMESPACE_SIZE": "4",
        "JSM_NAMESPACE_RANK": "3",
        "JSM_NAMESPACE_LOCAL_RANK": "1",
    }
    with mock.patch.dict(os.environ,
                         environ), mock.patch("socket.gethostname",
                                              return_value="10.10.10.2"):
        env = LSFEnvironment()
        assert env.creates_processes_externally
        assert env.main_address == "10.10.10.0"
        assert env.main_port == 10234
        assert env.world_size() == 4
        assert env.global_rank() == 3
        assert env.local_rank() == 1
        env.set_global_rank(100)
        assert env.global_rank() == 3
        env.set_world_size(100)
        assert env.world_size() == 4
        assert LSFEnvironment.detect()