def get_env_name(model_dir):
  """
  Args:
    model_dir: str. Will be in the format model-name/env-name_run-date and might end in "/"
  Return:
    str with the env name as it appears in gym
  """
  len_date = 20
  if model_dir[-1] == "/":
    len_date += 1
  env = model_dir[:-20]
  s   = env.find("/")
  env = env[s+1:]
  s = env.find("NoFrameskip")
  if s > 0:
    env = env[:s]
  else:
    s = env.find("-v")
    env = env[:s]
  return env