def test_attributes_from_environment_variables(): """ Test that the default cluster environment takes the attributes from the environment variables. """ env = LightningEnvironment() assert env.master_address() == "1.2.3.4" assert env.master_port() == 500 assert env.world_size() is None assert env.local_rank() == 2 assert env.node_rank() == 3
def test_default_attributes(): """ Test the default attributes when no environment variables are set. """ env = LightningEnvironment() assert not env.creates_children() assert env.master_address() == "127.0.0.1" assert isinstance(env.master_port(), int) assert env.world_size() == 1 assert env.local_rank() == 0 assert env.node_rank() == 0
def test_attributes_from_environment_variables(): """Test that the default cluster environment takes the attributes from the environment variables.""" env = LightningEnvironment() assert env.main_address == "1.2.3.4" assert env.main_port == 500 assert env.world_size() == 1 assert env.global_rank() == 0 assert env.local_rank() == 2 assert env.node_rank() == 3 env.set_global_rank(100) assert env.global_rank() == 100 env.set_world_size(100) assert env.world_size() == 100
def test_node_rank_from_group_rank(): """ Test that the GROUP_RANK substitutes NODE_RANK. """ env = LightningEnvironment() assert "NODE_RANK" not in os.environ assert env.node_rank() == 1