code: def main():
      parser = argparse.ArgumentParser()
      parser.add_argument(
          "-p",
          "--preset",
          "--presets",
          help="(string) Name of preset(s) to run (comma separated, as configured in presets.py)",
          default=None,
          type=str,
      )
      parser.add_argument(
          "-ip",
          "--ignore_presets",
          help="(string) Name of preset(s) to ignore (comma separated, and as configured in presets.py)",
          default=None,
          type=str,
      )
      parser.add_argument(
          "-v",
          "--verbose",
          help="(flag) display verbose logs in the event of an error",
          action="store_true",
      )
      parser.add_argument(
          "--stop_after_first_failure",
          help="(flag) stop executing tests after the first error",
          action="store_true",
      )
      parser.add_argument(
          "-ow",
          "--overwrite",
          help="(flag) overwrite old trace with new ones in trace testing mode",
          action="store_true",
      )
      parser.add_argument(
          "-prl",
          "--parallel",
          help="(flag) run tests in parallel",
          action="store_true",
      )
      parser.add_argument(
          "-ut",
          "--update_traces",
          help="(flag) update traces on repository",
          action="store_true",
      )
      parser.add_argument(
          "-mt",
          "--max_threads",
          help="(int) maximum number of threads to run in parallel",
          default=multiprocessing.cpu_count() - 2,
          type=int,
      )
      parser.add_argument(
          "-i",
          "--image",
          help="(string) Name of the testing image",
          type=str,
          default=None,
      )
      parser.add_argument(
          "-mb",
          "--memory_backend",
          help="(string) Name of the memory backend",
          type=str,
          default="redispubsub",
      )
      parser.add_argument(
          "-e",
          "--endpoint",
          help="(string) Name of the s3 endpoint",
          type=str,
          default="s3.amazonaws.com",
      )
      parser.add_argument(
          "-cr",
          "--creds_file",
          help="(string) Path of the s3 creds file",
          type=str,
          default=".aws_creds",
      )
      parser.add_argument(
          "-b",
          "--bucket",
          help="(string) Name of the bucket for s3",
          type=str,
          default=None,
      )
  
      args = parser.parse_args()
  
      if args.update_traces:
          if not args.bucket:
              print("bucket_name required for s3")
              exit(1)
          if not os.environ.get(
              "AWS_ACCESS_KEY_ID"
          ) or not os.environ.get("AWS_SECRET_ACCESS_KEY"):
              print(
                  "AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY env vars need to be set"
              )
              exit(1)
  
          config_file = "./tmp.cred"
          generate_config(
              args.image,
              args.memory_backend,
              args.endpoint,
              args.bucket,
              args.creds_file,
              config_file,
          )
  
      if not args.parallel:
          args.max_threads = 1
  
      if args.preset is not None:
          presets_lists = args.preset.split(",")
      else:
          presets_lists = [
              f[:-3]
              for f in os.listdir(os.path.join("rl_coach", "presets"))
              if f[-3:] == ".py" and not f == "__init__.py"
          ]
  
      fail_count = 0
      test_count = 0
  
      if args.ignore_presets is not None:
          presets_to_ignore = args.ignore_presets.split(",")
      else:
          presets_to_ignore = []
  
      for idx, preset_name in enumerate(sorted(presets_lists)):
          if args.stop_after_first_failure and fail_count > 0:
              break
          if preset_name not in presets_to_ignore:
              try:
                  preset = import_module(
                      "rl_coach.presets.{}".format(preset_name)
                  )
              except:
                  screen.error(
                      "Failed to load preset <{}>".format(preset_name),
                      crash=False,
                  )
                  fail_count += 1
                  test_count += 1
                  continue
  
              preset_validation_params = (
                  preset.graph_manager.preset_validation_params
              )
              num_env_steps = (
                  preset_validation_params.trace_max_env_steps
              )
              if preset_validation_params.test_using_a_trace_test:
                  if preset_validation_params.trace_test_levels:
                      for (
                          level
                      ) in preset_validation_params.trace_test_levels:
                          test_count += 1
                          test_path, log_file, p = run_trace_based_test(
                              preset_name, num_env_steps, level
                          )
                          processes.append((test_path, log_file, p))
                          test_passed = wait_and_check(args, processes)
                          if (
                              test_passed is not None
                              and not test_passed
                          ):
                              fail_count += 1
                  else:
                      test_count += 1
                      test_path, log_file, p = run_trace_based_test(
                          preset_name, num_env_steps
                      )
                      processes.append((test_path, log_file, p))
                      test_passed = wait_and_check(args, processes)
                      if test_passed is not None and not test_passed:
                          fail_count += 1
  
      while len(processes) > 0:
          test_passed = wait_and_check(args, processes, force=True)
          if test_passed is not None and not test_passed:
              fail_count += 1
  
      screen.separator()
      if fail_count == 0:
          screen.success(
              " Summary: "
              + str(test_count)
              + "/"
              + str(test_count)
              + " tests passed successfully"
          )
      else:
          screen.error(
              " Summary: "
              + str(test_count - fail_count)
              + "/"
              + str(test_count)
              + " tests passed successfully",
              crash=False,
          )
  
      # check fail counts just if update traces is not activated!
      if not args.update_traces:
          assert fail_count == 0
  
imports: import argparse
  import glob
  import os
  import shutil
  import subprocess
  import multiprocessing
  import sys
  import signal
  import pandas
  import time
  from configparser import ConfigParser
  from importlib import import_module
  from os import path
  from rl_coach.logger import screen
label_desc: Use image node_id 7 for calling a global function with example usage: main() without return types