Skip to content

Conversation

@ClemensSchwarke
Copy link
Collaborator

@ClemensSchwarke ClemensSchwarke commented Dec 3, 2025

Allows to pass custom modules and functions without having to modify the library. This adresses #135

Idate96 and others added 2 commits December 3, 2025 14:57
support direct class passing for policy/algorithm

* feat(runner): support direct class passing for policy/algorithm

Add _resolve_class() helper to OnPolicyRunner that resolves class_name
from multiple formats:
- Direct class objects (type) - enables passing custom classes directly
- Simple names ("ActorCritic") - existing eval behavior preserved
- Qualified names ("module:Class" or "module.Class") - uses importlib

This enables downstream projects to define custom actor-critic models
without modifying rsl_rl. Fully backwards-compatible.

Example usage:
  from my_project.models import MyPolicy
  runner_cfg["policy"]["class_name"] = MyPolicy  # Pass class directly

* Refactor class resolution into generalized resolve_callable utility

Address PR feedback from @cschwarke:
- Move _resolve_class from OnPolicyRunner to utils.py as resolve_callable
- Support nested attributes (e.g., "module:Outer.Inner", "module.Outer.Inner")
- Generalize to replace string_to_callable (now deprecated)
- Look up simple names like "PPO" in rsl_rl.algorithms/modules
- Add comprehensive test suite (23 tests)

Supported formats:
- Direct callable: pass class/function directly
- Colon format: "module.path:Attr.Nested" (explicit, recommended)
- Dot format: "module.path.ClassName" (progressive module splitting)
- Simple name: "PPO", "ActorCritic" (rsl_rl package lookup)

* Merge origin/main-rsl into feature/direct-class-passing

Resolve conflicts to integrate main-rsl updates with resolve_callable feature.

* fix tests, add to distillation runner, remove string_to_callable


Approved-by: Clemens Schwarke
@ClemensSchwarke ClemensSchwarke changed the title Support direct class passing. Support direct class passing Dec 3, 2025
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.

2 participants