def add_benchmark_parser_arguments()

in perfzero/lib/perfzero/perfzero_config.py [0:0]


def add_benchmark_parser_arguments(parser):
  """Add arguments to the parser used by the benchmark.py."""
  parser.add_argument(
      '--use_cached_site_packages',
      action='store_true',
      help='If set, skip git pull for dependent git repositories if it already exists in path_to_perfzero/${workspace}/site-packages'
      )
  parser.add_argument(
      '--gcs_downloads',
      default=None,
      type=str,
      help='This flag is deprecated. Use the flag --data_downloads instead')
  parser.add_argument(
      '--git_repos',
      default=None,
      type=str,
      help='''A string representing git repositories to checkout. The format is url_1;branch_1;hash_1,url_2;branch_2;hash_2,...
      Git repositories will be checked-out under directory path_to_perfzero/${workspace}/site-packages,
      where ${workspace} either defaults to 'workspace', or takes the value of the flag --workspace.
      branch and hash can be skipped if user wants to use the head of the master branch,
      which shortens the format to url_1,url_2,...
      ''')
  parser.add_argument(
      '--benchmark_num_trials',
      default=1,
      type=int,
      help='''Configures number of times to run each benchmark method
      after setup completion.''')
  parser.add_argument(
      '--benchmark_methods',
      action='append',
      default=[],
      type=str,
      help='''This string specifies the benchmark_method to be executed. The flag can be specified multiple times in which case
      the union of methods matched by these flags will be executed. The format can be module_path.class_name.method_name in which
      case the corresponding method is executed. The format can also be module_path.class_name.filter:regex_pattern, in which case all methods
      of the given class whose method name matches the given regular expression are executed.
      ''')
  parser.add_argument(
      '--ml_framework_build_label',
      default=None,
      type=str,
      help='A string that identified the machine learning framework build, e.g. nightly-gpu-build'
      )
  parser.add_argument(
      '--execution_label',
      default=None,
      type=str,
      help='A string that identified the benchmark execution type, e.g. test, prod'
      )
  parser.add_argument(
      '--platform_name',
      default=None,
      type=str,
      help='A string that identified the computing platform, e.g. gcp, aws'
      )
  parser.add_argument(
      '--system_name',
      default=None,
      type=str,
      help='A string that identified the hardware system, e.g. n1-standard-64-8xV100'
      )
  parser.add_argument(
      '--output_gcs_url',
      default=None,
      type=str,
      help='''If specified, log files generated by the benchmark execution will be uploaded to output_gcs_url/${execution_id},
      where ${execution_id} is a string that generated by PerfZero which uniquely identifies the execution of one benchmark method
      ''')
  parser.add_argument(
      '--scratch_gcs_url',
      default=None,
      type=str,
      help='''If specified, intermediate files like model outputs will be stored in scratch_gcs_url/${execution_id}, where
      ${execution_id} is a string that is generated by PerfZero which uniquely identifies the execution of one benchmark method.
      If not specified, intermediate files will be stored in a local folder on the host.
      ''')
  parser.add_argument(
      '--bigquery_project_name',
      default=None,
      type=str,
      help='''If both --bigquery_project_name and --bigquery_dataset_table_name are specified, for each benchmark method, the benchmark
      summary will be uploaded to the specified bigquery table whose schema is defined in perfzero/scripts/create_big_table.txt.
      The value of each field can in turn be a json-formatted string. See README.md for example output.
      ''')
  parser.add_argument(
      '--bigquery_dataset_table_name',
      default=None,
      type=str,
      help='''If both --bigquery_project_name and --bigquery_dataset_table_name are specified, for each benchmark method, the benchmark
      summary will be uploaded to the specified bigquery table whose schema is defined in perfzero/scripts/create_big_table.txt.
      The value of each field can in turn be a json-formatted string. See README.md for example output.
      ''')
  parser.add_argument(
      '--python_path',
      default=None,
      type=str,
      help='''A string of format path_1,path_2,... For each ${path} specified in the string,
      path_to_perfzero/${workspace}/site-packages/${path} will be added to python path so that libraies downloaded by --git_repos can
      be loaded and executed.
      ''')
  parser.add_argument(
      '--workspace',
      default='workspace',
      type=str,
      help='''The log files, gcloud key file and git repositories will be generated and downloaded under the
      directory path_to_perfzero/${workspace}
      ''')
  parser.add_argument(
      '--root_data_dir',
      default='/data',
      type=str,
      help='The directory which should contain the dataset required by the becnhmark method.'
      )
  parser.add_argument(
      '--data_downloads',
      default=None,
      type=str,
      help='''A string of format url_1;relative_path_1,url_2;relative_path_2,...
      Data will be copied from ${url} to ${root_data_dir}/${relative_path}. ${relative_path} can be skipped if it is the same as the
      base name of the url, which shortens the format to url_1,url_2,... ${root_data_dir} is specified by the flag --root_data_dir.
      File will be de-compressed in ${root_data_dir} if its name ends with 'gz'. Only url prefixed with gcs, http or https are supported.
      Each url can start with file://, gcs://, http:// or https://.
      ''')
  parser.add_argument(
      '--gcloud_key_file_url',
      default='gs://tf-performance/auth_tokens/benchmark_upload_gce.json',
      type=str,
      help='''The gcloud key file url. When specified, it will be downloaded to the
      directory specified by the flag --workspace. Each url can start with file://, gcs://, http:// or https://.
      The key file will then be activated and used as gcloud authentication credential.
      ''')
  parser.add_argument(
      '--debug',
      action='store_true',
      help='If set, use debug level logging. Otherwise, use info level logging'
      )
  parser.add_argument(
      '--profiler_enabled_time',
      default=None,
      type=str,
      help='''A string of format begin_time_1:end_time_1,begin_time_2:end_time_2,.... PerfZero will start to collect profiler
      data ${begin_time} sec after benchmark method execution starts. The data collection continues for ${end_time - begin_time}
      sec or until the benchmark method execution finishes, whichever occurs first. If ${end_time} is not explicitly
      specified, it is assumed to be MAX_LONG.
      ''')
  parser.add_argument(
      '--execution_id',
      default=None,
      type=str,
      help='A string that uniquely identifies the benchmark execution.')
  parser.add_argument(
      '--result_upload_methods',
      default=None,
      type=str,
      help='A comma separated list of class.method values to upload results.')
  parser.add_argument(
      '--tpu_parameters',
      default=None,
      type=str,
      help='''A json dictionary of cloud tpu parameters. The format must look like the following:
      {"name": "my-tpu-name", project": "my-gcp-project-id", "zone": "europe-west4-a", "size": "v3-8", "version": "nightly-2.x"}
      It can have an optional key value pair "version_id" -> "nightly version" to change the tpu version id.
      Example "version_id": "2.4.0-dev20200728".
      ''')
  parser.add_argument(
      '--perfzero_constructor_args',
      nargs='*',
      default='',
      type=str,
      help='''A json dictionary of additional args to pass to the perfzero
           constructor.'''
  )
  parser.add_argument(
    '--benchmark_class_type',
     default=None,
     type=str,
     help='''The benchmark class type. If none, assumed perfzero_benchmark. Set to "tf_benchmark"
           for tf.test.Benchmark benchmarks.''')