Beispiel #1
0
def DEFINE_integerlist(name, default, help, on_nonincreasing=None,
                       flag_values=FLAGS, **kwargs):
  """Register a flag whose value must be an integer list."""

  parser = IntegerListParser(on_nonincreasing=on_nonincreasing)
  serializer = IntegerListSerializer()

  flags.DEFINE(parser, name, default, help, flag_values, serializer, **kwargs)
Beispiel #2
0
def DEFINE_yaml(name, default, help, flag_values=flags.FLAGS, **kwargs):
  """Register a flag whose value is a YAML expression.

  Args:
    name: string. The name of the flag.
    default: object. The default value of the flag.
    help: string. A help message for the user.
    flag_values: the gflags.FlagValues object to define the flag in.
    kwargs: extra arguments to pass to gflags.DEFINE().
  """

  parser = YAMLParser()
  serializer = YAMLSerializer()

  flags.DEFINE(parser, name, default, help, flag_values, serializer, **kwargs)
Beispiel #3
0
def DEFINE_units(name, default, help, convertible_to,
                 flag_values=flags.FLAGS, **kwargs):
  """Register a flag whose value is a units expression.

  Args:
    name: string. The name of the flag.
    default: units.Quantity. The default value.
    help: string. A help message for the user.
    convertible_to: Either an individual unit specification or a series of unit
        specifications, where each unit specification is either a string (e.g.
        'byte') or a units.Unit. The flag value must be convertible to at least
        one of the specified Units to be considered valid.
    flag_values: the gflags.FlagValues object to define the flag in.
  """
  parser = UnitsParser(convertible_to=convertible_to)
  serializer = UnitsSerializer()
  flags.DEFINE(parser, name, default, help, flag_values, serializer, **kwargs)
def DEFINE_units(name, default, help, convertible_to=None,
                 flag_values=flags.FLAGS, **kwargs):
  """Register a flag whose value is a units expression.

  Args:
    name: string. The name of the flag.
    default: perfkitbenchmarker.UNIT_REGISTRY.Quantity. The default value.
    help: string. A help message for the user.
    convertible_to: perfkitbenchmarker.UNIT_REGISTRY.Unit or None. If
      a unit is provided, the input must be convertible to this unit
      to be considered valid.
    flag_values: the gflags.FlagValues object to define the flag in.
  """

  parser = UnitsParser(convertible_to=convertible_to)
  serializer = UnitsSerializer()

  flags.DEFINE(parser, name, default, help, flag_values, serializer, **kwargs)
def _DefineMemorySizeFlag(name, default, help, flag_values=FLAGS, **kwargs):
    flags.DEFINE(_MEMORY_SIZE_PARSER, name, default, help, flag_values,
                 _UNITS_SERIALIZER, **kwargs)
Beispiel #6
0
                'Unable to parse {0}. Unrecognized stages were found: {1}'.
                format(repr(argument), ', '.join(sorted(invalid_items))))

        if _ALL in stage_list:
            if len(stage_list) > 1:
                raise ValueError(
                    "Unable to parse {0}. If 'all' stages are specified, individual "
                    "stages cannot also be specified.".format(repr(argument)))
            return list(STAGES)

        previous_stage = stage_list[0]
        for stage in itertools.islice(stage_list, 1, None):
            expected_stage = _NEXT_STAGE.get(previous_stage)
            if not expected_stage:
                raise ValueError(
                    "Unable to parse {0}. '{1}' should be the last "
                    "stage.".format(repr(argument), previous_stage))
            if stage != expected_stage:
                raise ValueError(
                    "Unable to parse {0}. The stage after '{1}' should be '{2}', not "
                    "'{3}'.".format(repr(argument), previous_stage,
                                    expected_stage, stage))
            previous_stage = stage

        return stage_list


flags.DEFINE(RunStageParser(), 'run_stage', STAGES,
             "The stage or stages of perfkitbenchmarker to run.", flags.FLAGS,
             flags.ListSerializer(','))