def GetSchedulerOptions(configuration): # Here we're getting the configuration settings on the following, for this # particular configuration: # # - What cost do we attribute to tryjobs/bisections? # - What is the budget for each scheduling iteration? # # These options will all be part of a sub-object in the 'scheduler' key in # the bot configuration. What we're expecting is a structure like so: # # { # "scheduler": { # "cost": { # }, # "budget": <floating point> # } # } try: bot_config = bot_configurations.Get(configuration) except ValueError: bot_config = {} scheduler_options = bot_config.get('scheduler', {}) return SchedulerOptions( costs=scheduler_options.get( 'costs', collections.defaultdict(lambda: DEFAULT_COST)), budget=scheduler_options.get('budget', DEFAULT_BUDGET))
def _ArgumentsWithConfiguration(original_arguments): # "configuration" is a special argument that maps to a list of preset # arguments. Pull any arguments from the specified "configuration", if any. configuration = original_arguments.get('configuration') if configuration: new_arguments = bot_configurations.Get(configuration) else: new_arguments = {} # Override the configuration arguments with the API-provided arguments. new_arguments.update(original_arguments) return new_arguments
def _ArgumentsWithConfiguration(original_arguments): # "configuration" is a special argument that maps to a list of preset # arguments. Pull any arguments from the specified "configuration", if any. new_arguments = original_arguments.copy() configuration = original_arguments.get('configuration') if configuration: default_arguments = bot_configurations.Get(configuration) if default_arguments: for k, v in list(default_arguments.items()): new_arguments.setdefault(k, v) if new_arguments.get('benchmark') in _UNSUPPORTED_BENCHMARKS: raise ValueError(_ERROR_UNSUPPORTED % new_arguments.get('benchmark')) return new_arguments
def _ArgumentsWithConfiguration(original_arguments): # "configuration" is a special argument that maps to a list of preset # arguments. Pull any arguments from the specified "configuration", if any. configuration = original_arguments.get('configuration') if configuration: new_arguments = bot_configurations.Get(configuration) else: new_arguments = {} # Override the configuration arguments with the API-provided arguments. new_arguments.update(original_arguments) if new_arguments.get('benchmark') in _UNSUPPORTED_BENCHMARKS: raise ValueError(_ERROR_UNSUPPORTED % new_arguments.get('benchmark')) return new_arguments
def _ArgumentsWithConfiguration(original_arguments): # "configuration" is a special argument that maps to a list of preset # arguments. Pull any arguments from the specified "configuration", if any. new_arguments = original_arguments.copy() configuration = original_arguments.get('configuration') if configuration: try: default_arguments = bot_configurations.Get(configuration) except ValueError: # Reraise with a clearer message. raise ValueError("Bot Config: %s doesn't exist." % configuration) logging.info('Bot Config: %s', default_arguments) if default_arguments: for k, v in list(default_arguments.items()): # We special-case the extra_test_args argument to be additive, so that # we can respect the value set in bot_configurations in addition to # those provided from the UI. if k == 'extra_test_args': # First, parse whatever is already there. We'll canonicalise the # inputs as a JSON list of strings. provided_args = new_arguments.get('extra_test_args', '') extra_test_args = [] if provided_args: try: extra_test_args = json.loads(provided_args) except ValueError: extra_test_args = shlex.split(provided_args) try: configured_args = json.loads(v) except ValueError: configured_args = shlex.split(v) new_arguments['extra_test_args'] = json.dumps( extra_test_args + configured_args) else: new_arguments.setdefault(k, v) return new_arguments
def _ArgumentsWithConfiguration(original_arguments): # "configuration" is a special argument that maps to a list of preset # arguments. Pull any arguments from the specified "configuration", if any. new_arguments = original_arguments.copy() configuration = original_arguments.get('configuration') if configuration: try: default_arguments = bot_configurations.Get(configuration) except KeyError: # Reraise with a clearer message. raise ValueError("Bot Config: %s doesn't exist." % configuration) logging.info('Bot Config: %s', default_arguments) if default_arguments: for k, v in list(default_arguments.items()): new_arguments.setdefault(k, v) if new_arguments.get('benchmark') in _UNSUPPORTED_BENCHMARKS: raise ValueError(_ERROR_UNSUPPORTED % new_arguments.get('benchmark')) return new_arguments
def testGetWithAlias(self): actual = bot_configurations.Get('chromium-rel-mac11-pro') expected = {'arg': 'value'} self.assertEqual(actual, expected)
def testGet(self): actual = bot_configurations.Get('mac-11-perf') expected = {'arg': 'value'} self.assertEqual(actual, expected)