(experiment, knobs, exp_data, track='stable')
return ExperimentIsBucket(experiment, exp_data, mach_uuid)
Determine the status and source of a given experiment.

  Take into account all ways that a given experiment may be enabled and allow
  the client to determine why a given experiment has a particular status.

  Experiments at 100% are always on.
  If the machine is set to ignore experiments, it will ignore any experiments
  not at 100%.
  If the machine is set to always apply experiments, the experiment will be on.
  If the machine is in an explicitly enabled track, the experiment will be on.
  If the machine is manually opted in or out, that option is applied.
  Otherwise the bucket algorithm is applied.

  Args:
    experiment: a string identifier for a given experiment.
    knobs: knobs for a host (in dict form)
    exp_data: a dict containing experiment data (yaml.load(...))
    track: a string of the machine's release track
  Returns:
    an object with three attributes, status, source, and rollout_percent
Determine the status and source of a given experiment.
Determine the status and source of a given experiment .
def GetExperimentStatus(experiment, knobs, exp_data, track='stable'):
  """Determine the status and source of a given experiment.

  Take into account all ways that a given experiment may be enabled and allow
  the client to determine why a given experiment has a particular status.

  Experiments at 100% are always on.
  If the machine is set to ignore experiments, it will ignore any experiments
  not at 100%.
  If the machine is set to always apply experiments, the experiment will be on.
  If the machine is in an explicitly enabled track, the experiment will be on.
  If the machine is manually opted in or out, that option is applied.
  Otherwise the bucket algorithm is applied.

  Args:
    experiment: a string identifier for a given experiment.
    knobs: knobs for a host (in dict form)
    exp_data: a dict containing experiment data (yaml.load(...))
    track: a string of the machine's release track
  Returns:
    an object with three attributes, status, source, and rollout_percent
  """
  ReturnEarly = lambda ret: ret.source is not None  # pylint: disable=g-bad-name

  ret = type('obj', (object,), {})
  ret.status = DISABLED
  ret.source = None
  ret.rollout_percent = float(exp_data.get(experiment, {}).get(PERCENT_KEY, -1))

  if ret.rollout_percent == 100:
    logging.debug('Experiment %s is at 100%%, enabling', experiment)
    ret.status = ENABLED
    ret.source = ALWAYS
    return ret

  auto_knob = knobs.get(EXPERIMENTS_KNOB, 'recommended')
  if auto_knob == ALWAYS:
    ret.status = ENABLED
    ret.source = ALWAYS
  elif auto_knob == NEVER:
    ret.status = DISABLED
    ret.source = ALWAYS
  if ReturnEarly(ret): return ret

  manual_on_knob = knobs.get(MANUAL_ON_KNOB, [])
  manual_off_knob = knobs.get(MANUAL_OFF_KNOB, [])
  if experiment in manual_on_knob:
    ret.status = ENABLED
    ret.source = MANUAL
  elif experiment in manual_off_knob:
    ret.status = DISABLED
    ret.source = MANUAL
  if ReturnEarly(ret): return ret

  enable_unstable = exp_data.get(experiment, {}).get(ENABLE_UNSTABLE, False)
  enable_testing = exp_data.get(experiment, {}).get(ENABLE_TESTING, False)
  if ((track == 'testing' and enable_testing) or
      (track == 'unstable' and (enable_unstable or enable_testing))):
    ret.status = ENABLED
    ret.source = ALWAYS
  if ReturnEarly(ret): return ret

  try:
    mach_uuid = FetchUUID()
  except ExperimentsError, e:
    raise MissingUUID(e)
  logging.debug('Found uuid %s', mach_uuid)
  return ExperimentIsBucket(experiment, exp_data, mach_uuid)
def GetExperimentStatus ( experiment , knobs , exp_data , track = 'stable' ) : ReturnEarly = lambda ret : ret . source is not None # pylint: disable=g-bad-name ret = type ( 'obj' , ( object , ) , { } ) ret . status = DISABLED ret . source = None ret . rollout_percent = float ( exp_data . get ( experiment , { } ) . get ( PERCENT_KEY , - 1 ) ) if ret . rollout_percent == 100 : logging . debug ( 'Experiment %s is at 100%%, enabling' , experiment ) ret . status = ENABLED ret . source = ALWAYS return ret auto_knob = knobs . get ( EXPERIMENTS_KNOB , 'recommended' ) if auto_knob == ALWAYS : ret . status = ENABLED ret . source = ALWAYS elif auto_knob == NEVER : ret . status = DISABLED ret . source = ALWAYS if ReturnEarly ( ret ) : return ret manual_on_knob = knobs . get ( MANUAL_ON_KNOB , [ ] ) manual_off_knob = knobs . get ( MANUAL_OFF_KNOB , [ ] ) if experiment in manual_on_knob : ret . status = ENABLED ret . source = MANUAL elif experiment in manual_off_knob : ret . status = DISABLED ret . source = MANUAL if ReturnEarly ( ret ) : return ret enable_unstable = exp_data . get ( experiment , { } ) . get ( ENABLE_UNSTABLE , False ) enable_testing = exp_data . get ( experiment , { } ) . get ( ENABLE_TESTING , False ) if ( ( track == 'testing' and enable_testing ) or ( track == 'unstable' and ( enable_unstable or enable_testing ) ) ) : ret . status = ENABLED ret . source = ALWAYS if ReturnEarly ( ret ) : return ret try : mach_uuid = FetchUUID ( ) except ExperimentsError , e : raise MissingUUID ( e ) logging . debug ( 'Found uuid %s' , mach_uuid ) return ExperimentIsBucket ( experiment , exp_data , mach_uuid )