Skip to content

Commit 8b5acb2

Browse files
committed
optimize codecov
1 parent 080a040 commit 8b5acb2

7 files changed

Lines changed: 94 additions & 4 deletions

File tree

codecov.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ coverage:
44
range: 60..90
55
round: down
66
ignore:
7-
- "dlrover/python/tests" # test codes
87
- "dlrover/python/rl/tests" # test codes
98
- "dlrover/trainer/tests" # test codes
109
- "dlrover/trainer/torch/flash_checkpoint/megatron_dist_ckpt.py"

dlrover/python/rl/common/constant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class RLMasterConstant(object):
1616
JOB_CONTEXT_STATE_KEY = "job-context"
17-
SCHEDULING_TIMEOUT_MIN_SECS = 30
17+
SCHEDULING_TIMEOUT_MIN_SECS = 60
1818
SCHEDULING_TIMEOUT_PER_ACTOR_SECS = 2
1919
SETUP_TIMEOUT_MIN_SECS = 10
2020
SETUP_TIMEOUT_PER_ACTOR_SECS = 1

dlrover/python/rl/master/scheduler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def __create_actor_by_vertex(
176176
num_cpus=vertex.resource.cpu,
177177
memory=vertex.resource.memory,
178178
num_gpus=vertex.resource.gpu,
179+
max_restarts=-1,
179180
runtime_env=self.__get_runtime_env(vertex),
180181
)
181182

dlrover/python/rl/tests/api/test_api.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,49 @@ def test_basic(self):
8888
self.assertEqual(len(rl_config["workload_group"]), 1)
8989

9090
def test_validation(self):
91+
# without node num
9192
with self.assertRaises(InvalidRLConfiguration):
9293
RLJobBuilder().build()
94+
95+
# without device per node
96+
with self.assertRaises(InvalidRLConfiguration):
9397
RLJobBuilder().node_num(1).build()
98+
99+
# invalid device type
100+
with self.assertRaises(InvalidRLConfiguration):
94101
RLJobBuilder().node_num(1).device_per_node(1).device_type(
95102
"mem"
96103
).build()
104+
105+
# without config
106+
with self.assertRaises(InvalidRLConfiguration):
97107
RLJobBuilder().node_num(1).device_per_node(1).build()
108+
109+
# without trainer
110+
with self.assertRaises(InvalidRLConfiguration):
98111
RLJobBuilder().node_num(1).device_per_node(1).config(
99112
{"k1": "v1"}
100113
).build()
114+
115+
# without actor
116+
with self.assertRaises(InvalidRLConfiguration):
101117
RLJobBuilder().node_num(1).device_per_node(1).config(
102118
{"k1": "v1"}
103119
).trainer("m0", "c0").build()
104120

121+
# invalid collocation
122+
with self.assertRaises(InvalidRLConfiguration):
123+
RLJobBuilder().node_num(1).device_per_node(1).config(
124+
{"k1": "v1"}
125+
).trainer("m0", "c0").actor("m1", "c1").rollout("m2", "c2").reward(
126+
"m3", "c3"
127+
).with_collocation(
128+
"actor", "rollout"
129+
).with_collocation(
130+
"rollout", "reward"
131+
).build()
132+
133+
# a minimum valid
105134
RLJobBuilder().node_num(1).device_per_node(1).config(
106135
{"k1": "v1"}
107136
).trainer("m0", "c0").actor("m1", "c1").build()

dlrover/python/rl/tests/master/test_graph.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
from dlrover.python.rl.common.constant import RLMasterConstant
2222
from dlrover.python.rl.common.enums import RLRoleType
2323
from dlrover.python.rl.common.rl_context import RLContext
24-
from dlrover.python.rl.master.graph import RLExecutionGraph
24+
from dlrover.python.rl.master.graph import (
25+
FunctionInfo,
26+
RLExecutionEdge,
27+
RLExecutionGraph,
28+
VertexInvocationMeta,
29+
)
2530
from dlrover.python.rl.master.scheduler import GroupOrderedScheduler
2631
from dlrover.python.rl.tests.test_class import TestActor, TestRollout
2732
from dlrover.python.rl.tests.test_data import TestData
@@ -53,6 +58,8 @@ def test_basic(self):
5358
self.assertEqual(len(graph.get_all_vertices()), 1 + 1 + 1 + 1)
5459
self.assertEqual(len(graph.name_vertex_mapping), 1 + 1 + 1 + 1)
5560
self.assertEqual(len(graph.name_actor_mapping), 0)
61+
# not used for now
62+
self.assertEqual(len(graph.execution_edges), 0)
5663

5764
actor_vertices = graph.get_vertices_by_role_type(RLRoleType.ACTOR)
5865
self.assertEqual(len(actor_vertices), 1)
@@ -69,6 +76,8 @@ def test_basic(self):
6976
self.assertEqual(rollout_vertex_0.rank, 0)
7077
self.assertEqual(rollout_vertex_0.world_size, 1)
7178

79+
self.assertIsNotNone(graph.get_unit_resource_by_role(RLRoleType.ACTOR))
80+
7281
now = int(time.time())
7382
rollout_vertex_0.update_runtime_info(
7483
create_time=now, hostname="test.com", restart_count=2
@@ -199,3 +208,28 @@ def test_serialization(self):
199208
vertex.pg_bundle_index,
200209
graph.name_vertex_mapping[name].pg_bundle_index,
201210
)
211+
212+
def test_vertex_invocation_meta(self):
213+
def test_input():
214+
pass
215+
216+
function_info = FunctionInfo("test", test_input)
217+
self.assertIsNotNone(function_info)
218+
self.assertEqual(function_info.name, "test")
219+
220+
vertex_invocation_meta = VertexInvocationMeta(
221+
{function_info.name: function_info}
222+
)
223+
self.assertIsNotNone(vertex_invocation_meta)
224+
self.assertEqual(
225+
vertex_invocation_meta.get_func("test"), function_info
226+
)
227+
228+
def test_edge_basic(self):
229+
edge = RLExecutionEdge(0, RLRoleType.ACTOR, RLRoleType.ROLLOUT, "test")
230+
self.assertIsNotNone(edge)
231+
self.assertEqual(edge.index, 0)
232+
self.assertEqual(edge.from_role, RLRoleType.ACTOR)
233+
self.assertEqual(edge.to_role, RLRoleType.ROLLOUT)
234+
self.assertEqual(edge.invocation_name, "test")
235+
self.assertIsNone(edge.async_group)

dlrover/python/rl/tests/trainer/test_trainer.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
import unittest
14+
from unittest import mock
1415

1516
from dlrover.python.rl.common.enums import RLRoleType
1617
from dlrover.python.rl.tests.test_class import (
1718
TestActor,
1819
TestInteractiveTrainer,
20+
TestRollout,
1921
)
2022
from dlrover.python.rl.trainer.trainer import RoleGroupProxy
2123

@@ -57,7 +59,32 @@ def test_role_group_proxy(self):
5759
self.assertTrue(role_group._can_shard_invocation())
5860
with self.assertRaises(AttributeError):
5961
role_group.test0()
62+
with self.assertRaises(AttributeError):
6063
role_group.test1()
64+
with self.assertRaises(AttributeError):
6165
role_group.test2()
66+
with self.assertRaises(AttributeError):
6267
role_group.test3()
68+
with self.assertRaises(AttributeError):
6369
role_group.test4()
70+
71+
trainer = TestInteractiveTrainer(
72+
{RLRoleType.ACTOR: [], RLRoleType.ROLLOUT: []},
73+
{
74+
RLRoleType.ACTOR: (TestActor, 1),
75+
RLRoleType.ROLLOUT: (TestRollout, 1),
76+
},
77+
{},
78+
)
79+
self.assertIsNotNone(trainer)
80+
81+
trainer.RG_ACTOR._actor_handles = mock.MagicMock(
82+
return_value=[mock.Mock()]
83+
)
84+
trainer.RG_ACTOR.test0()
85+
trainer.RG_ACTOR.test1()
86+
trainer.RG_ACTOR.test2()
87+
with self.assertRaises(Exception):
88+
trainer.RG_ACTOR.test3()
89+
with self.assertRaises(Exception):
90+
trainer.RG_ACTOR.test4()

dlrover/python/util/common_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def get_methods_by_class(clz: type, with_protect=False):
193193

194194
result = []
195195
for name, method in inspect.getmembers(clz):
196-
if not inspect.isfunction(method):
196+
if not inspect.ismethod(method) and not inspect.isfunction(method):
197197
continue
198198
if not with_protect and name.startswith("_"):
199199
continue

0 commit comments

Comments
 (0)