def _GetBenchmarkSpec(benchmark_config, benchmark_name, benchmark_uid):
  """Creates a BenchmarkSpec or loads one from a file.

  During the provision stage, creates a BenchmarkSpec from the provided
  configuration. During any later stage, loads the BenchmarkSpec that was
  created during the provision stage from a file.

  Args:
    benchmark_config: BenchmarkConfigSpec. The benchmark configuration to use
        while running the current stage.
    benchmark_name: string. Name of the benchmark.
    benchmark_uid: string. Identifies a specific run of a benchmark.

  Returns:
    The created or loaded BenchmarkSpec.
  """
  if stages.PROVISION in FLAGS.run_stage:
    return benchmark_spec.BenchmarkSpec(benchmark_config, benchmark_name,
                                        benchmark_uid)
  else:
    try:
      return benchmark_spec.BenchmarkSpec.GetSpecFromFile(benchmark_uid,
                                                          benchmark_config)
    except __HOLE__:
      if FLAGS.run_stage == [stages.PREPARE]:
        logging.error(
            'We were unable to load the BenchmarkSpec. This may be related '
            'to two additional run stages which have recently been added. '
            'Please make sure to run the stage "provision" before "prepare". '
            'Similarly, make sure to run "teardown" after "cleanup".')
      raise
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/pkb.py/_GetBenchmarkSpec