Skip to content

Commit d5570c4

Browse files
authored
[mics][fix] Deprecate legacy _default_compute_score API and fix ray utils test (#1729)
### Checklist Before Starting - [x] Search for similar PR(s). ### What does this PR do? Handle comments after #1397 being merged: 1. Add back `_default_compute_score` API and mark it as deprecated; 2. Fix a broken ci test `ray_utils_test` on `parallel_put`; ### Checklist Before Submitting - [x] Read the [Contribute Guide](https://github.com/volcengine/verl?tab=readme-ov-file#contribution-guide). - [x] Apply [pre-commit checks](https://github.com/volcengine/verl?tab=readme-ov-file#code-linting-and-formatting). - [ ] Add `[BREAKING]` to the PR title if it breaks any API. - [ ] Update the documentation about your changes in the [docs](https://github.com/volcengine/verl/tree/main/docs). - [ ] Add CI test(s) if necessary. --------- Signed-off-by: Hongpeng Guo <[email protected]>
1 parent 16a13d8 commit d5570c4

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

tests/ray_cpu/test_ray_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def test_parallel_put_basic(init_ray):
3636

3737
def test_parallel_put_empty(init_ray):
3838
data = []
39-
refs = parallel_put(data)
40-
assert len(refs) == 0
39+
with pytest.raises(AssertionError):
40+
_ = parallel_put(data)
4141

4242

4343
def test_parallel_put_workers(init_ray):

verl/utils/ray_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def parallel_put(data_list: List[Any], max_workers: Optional[int] = None):
3434
List[ray.ObjectRef]: A list of Ray object references corresponding to the input data_list,
3535
maintaining the original order.
3636
"""
37+
assert len(data_list) > 0, "data_list must not be empty"
3738

3839
def put_data(index, data):
3940
return index, ray.put(data)

verl/utils/reward_score/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# limitations under the License.
1414
# from . import gsm8k, math, prime_math, prime_code
1515

16+
from verl.utils.import_utils import deprecated
17+
1618

1719
def default_compute_score(data_source, solution_str, ground_truth, extra_info=None, sandbox_fusion_url=None, concurrent_semaphore=None):
1820
"""Compute the score for a given solution based on the data source.
@@ -88,4 +90,12 @@ def default_compute_score(data_source, solution_str, ground_truth, extra_info=No
8890
return float(res[0])
8991

9092

93+
@deprecated("verl.utils.reward_score.default_compute_score")
94+
def _default_compute_score(data_source, solution_str, ground_truth, extra_info=None, sandbox_fusion_url=None, concurrent_semaphore=None):
95+
"""
96+
Legacy function API to be deprecated. Please use `default_compute_score` instead.
97+
"""
98+
return default_compute_score(data_source, solution_str, ground_truth, extra_info, sandbox_fusion_url, concurrent_semaphore)
99+
100+
91101
__all__ = ["default_compute_score"]

0 commit comments

Comments
 (0)