Hi,
I am using a custom callback that works fine when I train an RL model without using tune:
config = ppo.PPOConfig(
).environment(MyCustomEnv, env_config=env_config, disable_env_checking=True
).training(
model={
'custom_model': model_class_name,
'custom_model_config': custom_model_config
},
).framework(eager_tracing=True, framework=framework
).resources(num_gpus=1, num_cpus_per_worker=1, num_cpus_per_learner_worker=2,
).rollouts(enable_connectors=False, num_rollout_workers=2).callbacks(MyCallbacks
).reporting(keep_per_episode_custom_metrics=True)
algo = config.build()
num_iterations = 2
for _ in range(num_iterations):
result = algo.train()
However, when I try to use tune. Namely:
tuner = tune.Tuner(
"PPO",
run_config=air.RunConfig(
storage_path=run_path,
stop={
"training_iteration": num_iterations,
},
# callbacks=[MyCallbacks],
),
param_space=config,
)
result = tuner.fit()
The custom callback is ignored. As stated above, the custom callback works fine when tune is not used.
If I try to include the custom callback also in my air.RunConfig
by commenting out the line above, I receive the following error:
AttributeError: type object 'MyCallbacks' has no attribute 'setup'
I also tried the following variation: callbacks=[MyCallbacks()]
. This leads to the same error.
My current ray version is 2.5.1 (pip install ray[default,rllib]==2.5.1
)