testing/variations/PRESUBMIT.py
def _ValidateExperimentGroup(experiment_group, create_message_fn):
  """Validates one group of one config in a configuration entry."""
  name = experiment_group.get('name', '')
  if not name or not isinstance(name, str):
    return create_message_fn('Missing valid name for experiment')

  # Add context to other messages.
  def _CreateGroupMessage(message_format, *args):
    suffix = ' in Group[%s]' % name
    return create_message_fn(message_format + suffix, *args)

  if 'params' in experiment_group:
    params = experiment_group['params']
    if not isinstance(params, dict):
      return _CreateGroupMessage('Expected dict for params')
    for (key, value) in iter(params.items()):
      if not isinstance(key, str) or not isinstance(value, str):
        return _CreateGroupMessage('Invalid param (%s: %s)', key, value)
  for key in experiment_group.keys():
    if key not in VALID_EXPERIMENT_KEYS:
      return _CreateGroupMessage('Key[%s] is not a valid key', key)
  return []
Validates one group of one config in a configuration entry.
Validates one group of one config in a configuration entry.
Validates one group of one config in a configuration entry .
def _ValidateExperimentGroup(experiment_group, create_message_fn):
  name = experiment_group.get('name', '')
  if not name or not isinstance(name, str):
    return create_message_fn('Missing valid name for experiment')
  def _CreateGroupMessage(message_format, *args):
    suffix = ' in Group[%s]' % name
    return create_message_fn(message_format + suffix, *args)
  if 'params' in experiment_group:
    params = experiment_group['params']
    if not isinstance(params, dict):
      return _CreateGroupMessage('Expected dict for params')
    for (key, value) in iter(params.items()):
      if not isinstance(key, str) or not isinstance(value, str):
        return _CreateGroupMessage('Invalid param (%s: %s)', key, value)
  for key in experiment_group.keys():
    if key not in VALID_EXPERIMENT_KEYS:
      return _CreateGroupMessage('Key[%s] is not a valid key', key)
  return []
def _ValidateExperimentGroup ( experiment_group , create_message_fn ) : name = experiment_group . get ( 'name' , '' ) if not name or not isinstance ( name , str ) : return create_message_fn ( 'Missing valid name for experiment' ) def _CreateGroupMessage ( message_format , * args ) : suffix = ' in Group[%s]' % name return create_message_fn ( message_format + suffix , * args ) if 'params' in experiment_group : params = experiment_group [ 'params' ] if not isinstance ( params , dict ) : return _CreateGroupMessage ( 'Expected dict for params' ) for ( key , value ) in iter ( params . items ( ) ) : if not isinstance ( key , str ) or not isinstance ( value , str ) : return _CreateGroupMessage ( 'Invalid param (%s: %s)' , key , value ) for key in experiment_group . keys ( ) : if key not in VALID_EXPERIMENT_KEYS : return _CreateGroupMessage ( 'Key[%s] is not a valid key' , key ) return [ ]
Validates one group of one config in a configuration entry.
Validates one group of one config in a configuration entry .
"""Validates one group of one config in a configuration entry.""" # Add context to other messages.
experiment_group
create_message_fn