code: def is_reward_reached(
      csv_path, p_valid_params, start_time, time_limit
  ):
      """
      Check the result of the experiment, by collecting all the Evaluation Reward
      and average should be bigger than the min reward threshold.
      :param csv_path: csv file  (results)
      :param p_valid_params: experiment test params
      :param start_time: start time of the test
      :param time_limit: timeout of the test
      :return: |Bool| true if reached the reward minimum
      """
      win_size = 10
      last_num_episodes = 0
      csv = None
      reward_reached = False
      reward_str = "Evaluation Reward"
  
      while csv is None or (
          csv[csv.columns[0]].values[-1]
          < p_valid_params.max_episodes_to_achieve_reward
          and time.time() - start_time < time_limit
      ):
          try:
              csv = pd.read_csv(csv_path)
          except:
              # sometimes the csv is being written at the same time we are
              # trying to read it. no problem -> try again
              continue
  
          if reward_str not in csv.keys():
              continue
  
          rewards = csv[reward_str].values
          rewards = rewards[~np.isnan(rewards)]
  
          if len(rewards) >= 1:
              averaged_rewards = np.convolve(
                  rewards,
                  np.ones(min(len(rewards), win_size)) / win_size,
                  mode="valid",
              )
          else:
              time.sleep(1)
              continue
  
          if csv[csv.columns[0]].shape[0] - last_num_episodes <= 0:
              continue
  
          last_num_episodes = csv[csv.columns[0]].values[-1]
  
          # check if reward is enough
          if np.any(
              averaged_rewards >= p_valid_params.min_reward_threshold
          ):
              reward_reached = True
              break
          time.sleep(1)
  
      return reward_reached
  
file_path: coach/rl_coach/tests/utils/args_utils.py
imports: import os
  import signal
  import time
  import pandas
  import numpy
  import pytest
  from rl_coach.tests.utils.test_utils import get_csv_path, get_files_from_dir, find_string_in_logs
  from rl_coach.tests.utils.definitions import Definitions
label_desc: Use image node_id 6 for calling a global function with example usage: is_reward_reached(csv_path, p_valid_params, start_time, time_limit) and returns: reward_reached