# Ray example - custom evaluation function fails

**URL:** <https://discuss.ray.io/t/ray-example-custom-evaluation-function-fails/15994>\
**Category:** RLlib\
**Created:** [October 14, 2024, 5:12am UTC](https://discuss.ray.io/t/ray-example-custom-evaluation-function-fails/15994 "2024-10-14T05:12:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbk80](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/dbk80/32/1822_2.png) [@dbk80](https://discuss.ray.io/u/dbk80)\
**Post date:** [October 14, 2024, 5:12am UTC](https://discuss.ray.io/t/ray-example-custom-evaluation-function-fails/15994/1 "2024-10-14T05:12:58Z")

</div>

Hi,

After upgrading to Ray 2.36.0, my custom evaluation function is failing. To troubleshoot, I tested the custom evaluation function from the documentation, but it also fails with the (same) following error:

`TypeError: custom_eval_function() missing 2 required positional arguments: 'algorithm' and 'eval_workers'`

(the error originates from ray/rllib/algorithms/algorithm.py:1082)

Does this imply that the custom evaluation function can not take any arguments in ray 2.36? Is there an updated example that I could use for inspiration?

Below is a script to reproduce the issue:

```auto
from ray.rllib.examples.evaluation.custom_evaluation import custom_eval_function
from ray.tune.registry import get_trainable_cls
from ray.rllib.examples.envs.classes.simple_corridor import SimpleCorridor
from ray.rllib.algorithms.algorithm_config import AlgorithmConfig

evaluation_parallel_to_training = True 
base_config = (
        get_trainable_cls("PPO")
        .get_default_config()
        .environment(
            SimpleCorridor,
            env_config={"corridor_length": 5},
        )
        .framework(framework='tf2')
        .evaluation(
            custom_evaluation_function=custom_eval_function,
            evaluation_num_env_runners=2,
            evaluation_interval=1,
            evaluation_duration="auto" if evaluation_parallel_to_training else 10,
            evaluation_parallel_to_training=evaluation_parallel_to_training,
            evaluation_config=AlgorithmConfig.overrides(
                env_config={"corridor_length": 7},
                metrics_num_episodes_for_smoothing=5,
                evaluation_duration_unit='timesteps'
            ),
        )
    )
algo = base_config.build()

for _ in range(10):
        result = algo.train()

```

Environment details:  
python 3.11  
ray 2.36.0  
tensorflow 2.15.1
