def generate_target_documentation(outdir): targets_to_generate = [ 'generic_android', 'generic_linux', 'generic_chromeos', 'generic_local', 'juno_linux', 'juno_android' ] intro = ( '\nThis is a list of commonly used targets and their device ' 'parameters, to see a complete for a complete reference please use the' ' WA :ref:`list command <list-command>`.\n\n\n') pluginloader.clear() pluginloader.update(packages=['wa.framework.target.descriptor']) target_descriptors = list_target_descriptions(pluginloader) outfile = os.path.join(outdir, 'targets.rst') with open(outfile, 'w') as wfh: wfh.write(underline('Common Targets')) wfh.write(intro) for td in sorted(target_descriptors, key=lambda t: t.name): if td.name not in targets_to_generate: continue text = underline(td.name, '~') if hasattr(td, 'description'): desc = strip_inlined_text(td.description or '') text += desc text += underline('Device Parameters:', '-') text += get_params_rst(td.conn_params) text += get_params_rst(td.platform_params) text += get_params_rst(td.target_params) text += get_params_rst(td.assistant_params) wfh.write(text)
def generate_target_documentation(outdir): targets_to_generate = ['generic_android', 'generic_linux', 'generic_chromeos', 'generic_local', 'juno_linux', 'juno_android'] intro = '\nThis is a list of commonly used targets and their device '\ 'parameters, to see a complete for a complete reference please use the '\ 'WA :ref:`list command <list-command>`.\n\n\n' pluginloader.clear() pluginloader.update(packages=['wa.framework.target.descriptor']) target_descriptors = list_target_descriptions(pluginloader) outfile = os.path.join(outdir, 'targets.rst') with open(outfile, 'w') as wfh: wfh.write(underline('Common Targets')) wfh.write(intro) for td in sorted(target_descriptors, key=lambda t: t.name): if td.name not in targets_to_generate: continue text = underline(td.name, '~') if hasattr(td, 'description'): desc = strip_inlined_text(td.description or '') text += desc text += underline('Device Parameters:', '-') text += get_params_rst(td.conn_params) text += get_params_rst(td.platform_params) text += get_params_rst(td.target_params) text += get_params_rst(td.assistant_params) wfh.write(text)
def execute(self, state, args): agenda = OrderedDict() agenda['config'] = OrderedDict(augmentations=[], iterations=args.iterations) agenda['workloads'] = [] target_desc = None targets = {td.name: td for td in list_target_descriptions()} for name in args.plugins: if name in targets: if target_desc is not None: raise ConfigError( 'Specifying multiple devices: {} and {}'.format( target_desc.name, name)) target_desc = targets[name] agenda['config']['device'] = name agenda['config'][ 'device_config'] = target_desc.get_default_config() continue extcls = pluginloader.get_plugin_class(name) config = pluginloader.get_default_config(name) # Handle special case for EnergyInstrumentBackends if issubclass(extcls, EnergyInstrumentBackend): if 'energy_measurement' not in agenda['config'][ 'augmentations']: energy_config = pluginloader.get_default_config( 'energy_measurement') agenda['config']['augmentations'].append( 'energy_measurement') agenda['config']['energy_measurement'] = energy_config agenda['config']['energy_measurement'][ 'instrument'] = extcls.name agenda['config']['energy_measurement'][ 'instrument_parameters'] = config elif extcls.kind == 'workload': entry = OrderedDict() entry['name'] = extcls.name if name != extcls.name: entry['label'] = name entry['params'] = config agenda['workloads'].append(entry) else: if extcls.kind in ('instrument', 'output_processor'): if extcls.name not in agenda['config']['augmentations']: agenda['config']['augmentations'].append(extcls.name) if extcls.name not in agenda['config']: agenda['config'][extcls.name] = config if args.output: wfh = open(args.output, 'w') else: wfh = sys.stdout yaml.dump(agenda, wfh, indent=4, default_flow_style=False) if args.output: wfh.close()
def list_targets(): targets = list_target_descriptions() targets = sorted(targets, key=lambda x: x.name) output = DescriptionListFormatter() for target in targets: output.add_item(target.description or '', target.name) print(output.format_data()) print('')
def execute(self, state, args): agenda = OrderedDict() agenda['config'] = OrderedDict(augmentations=[], iterations=args.iterations) agenda['workloads'] = [] target_desc = None targets = {td.name: td for td in list_target_descriptions()} for name in args.plugins: if name in targets: if target_desc is not None: raise ConfigError('Specifying multiple devices: {} and {}'.format(target_desc.name, name)) target_desc = targets[name] agenda['config']['device'] = name agenda['config']['device_config'] = target_desc.get_default_config() continue extcls = pluginloader.get_plugin_class(name) config = pluginloader.get_default_config(name) # Handle special case for EnergyInstrumentBackends if issubclass(extcls, EnergyInstrumentBackend): if 'energy_measurement' not in agenda['config']['augmentations']: energy_config = pluginloader.get_default_config('energy_measurement') agenda['config']['augmentations'].append('energy_measurement') agenda['config']['energy_measurement'] = energy_config agenda['config']['energy_measurement']['instrument'] = extcls.name agenda['config']['energy_measurement']['instrument_parameters'] = config elif extcls.kind == 'workload': entry = OrderedDict() entry['name'] = extcls.name if name != extcls.name: entry['label'] = name entry['params'] = config agenda['workloads'].append(entry) else: if extcls.kind in ('instrument', 'output_processor'): if extcls.name not in agenda['config']['augmentations']: agenda['config']['augmentations'].append(extcls.name) if extcls.name not in agenda['config']: agenda['config'][extcls.name] = config if args.output: wfh = open(args.output, 'w') else: wfh = sys.stdout yaml.dump(agenda, wfh, indent=4, default_flow_style=False) if args.output: wfh.close()
def __init__(self, loader=pluginloader): self.loader = loader self.sources = [] self.plugin_configs = defaultdict(lambda: defaultdict(dict)) self.global_alias_values = defaultdict(dict) self.targets = {td.name: td for td in list_target_descriptions()} # Generate a mapping of what global aliases belong to self._global_alias_map = defaultdict(dict) self._list_of_global_aliases = set() for plugin in self.loader.list_plugins(): for param in plugin.parameters: if param.global_alias: self._global_alias_map[plugin.name][param.global_alias] = param self._list_of_global_aliases.add(param.global_alias)
def get_target_description(name): targets = list_target_descriptions() for target in targets: if name == identifier(target.name): return target