Skip to content

fix: resolve ruler function/module name collision#587

Open
koriyoshi2041 wants to merge 1 commit intoOpenPipe:mainfrom
koriyoshi2041:fix/ruler-name-collision
Open

fix: resolve ruler function/module name collision#587
koriyoshi2041 wants to merge 1 commit intoOpenPipe:mainfrom
koriyoshi2041:fix/ruler-name-collision

Conversation

@koriyoshi2041
Copy link

Summary

Fixes #339.

  • Export DEFAULT_RUBRIC from art.rewards so users can access it via from art.rewards import DEFAULT_RUBRIC, bypassing the function/module name collision
  • Accept rubric=None in both ruler() and ruler_score_group(), resolving to DEFAULT_RUBRIC internally — this lets users reference the default without importing the constant
  • Both functions resolve None at their own entry point for defensive consistency

Background

art.rewards.__init__.py imports the ruler() function from ruler.py, which shadows the ruler module. This makes art.rewards.ruler.DEFAULT_RUBRIC (and any other module-level export) inaccessible:

from art.rewards import ruler
ruler.DEFAULT_RUBRIC  # AttributeError: 'function' object has no attribute 'DEFAULT_RUBRIC'

After this change

# Option 1: Import DEFAULT_RUBRIC directly
from art.rewards import DEFAULT_RUBRIC
custom_rubric = DEFAULT_RUBRIC + "\n- Prefer concise answers"

# Option 2: Pass None to use the default
await ruler_score_group(group, rubric=None)

Fully backward-compatible — existing callers passing a string are unaffected.

Test plan

  • Verify from art.rewards import DEFAULT_RUBRIC works
  • Verify ruler(message_lists, rubric=None) uses the default rubric
  • Verify ruler_score_group(group, rubric=None) uses the default rubric
  • Verify existing calls with explicit rubric="..." still work
  • uv run prek run --all-files passes

Export DEFAULT_RUBRIC from art.rewards to make it accessible despite the
name collision between the ruler() function and the ruler module. Also
accept rubric=None in ruler() and ruler_score_group() so callers can
reference the default without importing the constant.

Both functions resolve None to DEFAULT_RUBRIC defensively at their own
entry point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: art.rewards.ruler function and module collision

1 participant