def _emit_config(self) -> None: # First build up the dictionary containing the configuration used. self._populate_config() # Add to metadata assets stored to container image. metadata.add_asset(metadata.YAMLDictAsset(self.confd, 'environment')) # Then print it out in YAML format. utils.yamlp(self.confd, self.prog)
def _populate_service_config(self) -> None: # Remove program from output since it is redundant and because we don't # know how it'll be parsed by the given program. tmpargs = copy.deepcopy(vars(self.args)) tmpargs.pop('program') self.confd['Configuration'] = tmpargs metadata.add_asset(metadata.YAMLDictAsset(self.confd, 'run'))
def main(argv): logger.log('adding a file asset...') metadata.add_asset(metadata.FileAsset('some-metadata.txt')) logger.log('adding a yaml dict asset...') adict = dict() adict['Application'] = {'argv': argv} adict['System'] = {'whoami': host.whoami(), 'hostname': host.hostname()} metadata.add_asset(metadata.YAMLDictAsset(adict, 'yaml-metadata'))
def _emit_builder_info(self) -> None: ''' Emits builder information gathered at run-time. ''' binfo = dict() binfo['Builder'] = { 'which': host.which(self.buildc), 'version': host.capture('{} --version'.format(self.buildc)), } utils.yamlp(binfo, 'Builder') metadata.add_asset(metadata.YAMLDictAsset(binfo, 'builder'))
def _populate_env_config(self) -> None: # Host environment. self.confd['Host'] = { 'whoami': host.whoami(), 'kernel': host.kernel(), 'kernel_release': host.kernelrel(), 'hostname': host.hostname(), 'os_release': host.os_pretty_name() } # Do this so the YAML output has the 'Host' heading. hostd = {'Host': self.confd['Host']} metadata.add_asset(metadata.YAMLDictAsset(hostd, 'environment'))
def main(argv): logger.log('adding a file asset...') # adds an arbitrary metadata file to a subfolder: custom metadata.add_asset( metadata.FileAsset('some-metadata.txt', 'subdir-a/subdir-b')) logger.log('adding a yaml dict asset...') adict = dict() # collect metadata adict['Application'] = {'argv': argv} adict['System'] = {'whoami': host.whoami(), 'hostname': host.hostname()} # save metadata to file metadata.add_asset(metadata.YAMLDictAsset(adict, 'yaml-metadata'))
def parse_snapfile(self) -> None: ''' Collect time data from snap output file. ''' with open(self.snap_output) as out_file: lines = out_file.readlines() time_table = [] # Search for time table. for pos, line in enumerate(lines): if line.lstrip().startswith('keyword Timing Summary'): logger.log(F'Found time table on line: {pos}\n') time_table = lines[pos + 1:] break # Collect iteration results. results = [] for row in time_table: # trim white space, su trimmed = re.sub(r'[ ]{2,}', ':', row.strip()) # Skip empty or decorative if trimmed == '' or '*' in trimmed: continue label, value = trimmed.split(':') if label in self.keywords: results.append(value) # Add iteration results to experiment data. self.data['results'].append(results) # Save dictionary data. logger.log('\nAdding metadata file...') metadata.add_asset( metadata.YAMLDictAsset(self.data, 'timing-metadata')) return