Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tune/wandb] Fix WandbTrainableMixin config for rllib trainables #22063

Merged
merged 3 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/ray/tune/integration/wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,6 @@ def __init__(self, config: Dict, *args, **kwargs):
"`class YourTrainable(WandbTrainableMixin)`."
)

super().__init__(config, *args, **kwargs)

_config = config.copy()

try:
Expand All @@ -540,6 +538,8 @@ def __init__(self, config: Dict, *args, **kwargs):
"containing at least a `project` specification."
)

super().__init__(_config, *args, **kwargs)

api_key_file = wandb_config.pop("api_key_file", None)
if api_key_file:
api_key_file = os.path.expanduser(api_key_file)
Expand Down
23 changes: 23 additions & 0 deletions python/ray/tune/tests/test_integration_wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,29 @@ def train_fn(config):
self.assertEqual(wrapped.wandb.kwargs["id"], trial.trial_id)
self.assertEqual(wrapped.wandb.kwargs["name"], trial.trial_name)

def testWandbMixinRllib(self):
"""Test compatibility with RLLib configuration dicts"""
# Local import to avoid tune dependency on rllib
try:
from ray.rllib.agents.ppo import PPOTrainer
except ImportError:
self.skipTest("ray[rllib] not available")
return

class WandbPPOTrainer(_MockWandbTrainableMixin, PPOTrainer):
pass

config = {
"env": "CartPole-v0",
"wandb": {
"project": "test_project",
"api_key": "1234",
},
}

# Test that trainer object can be initialized
WandbPPOTrainer(config)


if __name__ == "__main__":
import pytest
Expand Down