def main(argv): # Name the experiment. experiment.name('test-shellcmds') fname = 'afile.txt' logger.log('# Testing globbing...') shargs = {'echo': True} # Wildcards need to be escaped with a `\' or quoted to protect them from # expansion by the host. container.run('ls \\*') # shell and container interfaces should behave as identically as possible. host.run('ls \\*', **shargs) logger.emlog('# Testing redirection...') logger.log(F'# Adding text to {fname}:') container.run(F'echo "Some Text" | tee {fname}') container.run(F'echo "More \'Text\'" >> {fname}') logger.emlog(F'# The contents of {fname} are:') host.run(F'cat {fname}', **shargs) logger.emlog('# Testing quoting...') container.run('echo "Some \'Text\'"') logger.emlog('# Testing command chaining...') container.run('true && echo true!') container.run('false || echo false... && echo and done!') metadata.add_asset(metadata.FileAsset(fname))
def main(argv): # Name the experiment. experiment.name('test-shellcmds') fname = 'afile.txt' logger.log('# Testing globbing...') shargs = {'echo': True} # Wildcards don't need to be escaped with a `\' or quoted to protect them # from expansion by the host. We take care of that for you. container.run('ls *') # host and container interfaces should behave as identically as possible. host.run('ls *', **shargs) logger.emlog('# Testing redirection...') logger.log(F'# Adding text to {fname}:') host.run(F'echo "Some Text" | tee {fname}', **shargs) host.run(F'echo "More \'Text\'" >> {fname}', **shargs) logger.emlog(F'# The contents of {fname} are:') host.run(F'cat {fname}', **shargs) logger.emlog('# Testing quoting...') container.run('echo "Some \'Text\'"') logger.emlog('# Testing command chaining...') container.run('true && echo true!') container.run('false || echo false is good && echo true is good') logger.emlog('# Testing variable lifetimes within chained commands...') container.run('export FOO="bar" && ' 'test ! -z $FOO && ' 'echo "Looks good!" || ' 'exit 1') metadata.add_asset(metadata.FileAsset(fname))
def main(argv): experiment.name('nbody') logger.log('# Experiment: {}'.format(experiment.name())) prun = host.whichl(['srun', 'mpiexec']) if prun is None: sys.exit('Cannot find a parallel launcher...') app = '/nbody/nbody-mpi' # The seemingly strange use of {{}} allows us to first format the string # with arguments (the {}) and then generate strings with values passed to -n # from the output of range() (the {{}}). runcmds = experiment.generate('{} -n {{}}'.format(prun), range(1, 3)) etimes = list() for r in runcmds: stime = utils.now() # TODO(skg) FIXME container.prun(r, app) etime = utils.now() telapsed = etime - stime etimes.append(telapsed) logger.log(F'# Execution Time: {telapsed}\n') # Take a break between runs. time.sleep(1) logger.log('# Report') logger.log('# Command, Execution Time') for i in zip(runcmds, etimes): logger.log('{}, {}'.format(*i))
def main(argv): experiment.name('custom-actions') container.run( './example-application.sh', # Application invocation. preaction=pre_action, # Set pre-action callback function. postaction=post_action # Set post-action callback function. )
def __init__(self, config: experiment.CLIConfiguration): ''' Experiment configuration ''' experiment.name(config.args.name) # Set experiment configuration, executable and data output. self.config = config self.executable = config.args.executable self.csv_output = config.args.csv_output self.data: typing.Dict[str, list] = { 'commands': list(), 'results': list() } self.emit_conf() self.add_assets() # Labels of data to be obtained from app ouput. self.keywords = [ 'Total cells requested', 'Total cells sent', 'Total cell messages', 'Total transport', 'Total setup' ]
def main(argv): # Set the experiment's name. This particular experiment is named # hello-world. experiment.name('hello-world') # The logger emits strings to the console. Additionally, the output # produced by logging actions is recorded and stored in experiment metadata # written (by default) after experiment termination. logger.log('hello world')
def main(argv): experiment.name('hello-extras') logger.log('This is an example of how to use extras') # Use the extra modules we specified at run-time if they are loaded. if utils.module_imported('mymod'): mymod.say_hello() else: logger.log('*** NOTE: mymod is not imported ***') if utils.module_imported('mypackage'): mypackmod.say_hello() else: logger.log('*** NOTE: mypackmod is not imported ***')
def __init__(self, config): # The experiment configuration. self.config = config # Set the experiment's name. experiment.name(self.config.args.name) # The instance responsible for naming data. self.data_labeler = DataLabeler() # Data container. self.data = {'commands': list(), 'bmdata': list()} # Emit program configuration to terminal. self.emit_conf() # Add assets to collection of metadata. self.add_assets()
def _write_metadata(self) -> None: base = os.path.join(self.args.output_path, str(experiment.name())) outp = impl.getmetasubd(base) # Do this here so the output log has the output directory in it. logger.log(F'# {self.prog} Output Target: {outp}') metadata.write(outp) logger.log(F'# {self.prog} Output Written to: {outp}')
def main(argv): # Name the experiment. experiment.name('test1-runcmds') cmds = [ 'srun -n %n', 'srun -n %n %n', 'srun -n%n%n', 'srun -n noarg', ] for c in cmds: logger.log(F'# Command: {c}') nfun = 'nidx' rcmds = experiment.runcmds(0, 4, c, nfun) for r in rcmds: logger.log(F'# {r}') logger.log('')
def __init__(self, config): # The experiment configuration. self.config = config # Set the experiment's name experiment.name(self.config.args.name) # Data container. self.data = { 'commands': list(), 'numpe': list(), 'nthread': list(), 'alups': list(), 'tlups': list() } # Emit program configuration to terminal. self.emit_conf() # Add assets to collection of metadata. self.add_assets()
def __init__(self, config: experiment.CLIConfiguration) -> None: ''' Experiment configuration. ''' experiment.name(config.args.name) self.config = config # PENNANT input file self.pinfile = config.args.pinfile self.data: typing.Dict[str, list] = { 'commands': list(), 'results': list() } # Emit program config to terminal & collected assets. self.emit_conf() self.add_assets()
def __init__(self, config: experiment.CLIConfiguration): experiment.name(config.args.name) # set experiment configuratin, executable self.config = config self.executable = self.config.args.executable self.data: typing.Dict[str, list] = { 'commands': list(), 'results': list() } self.emit_conf() # Emit config to terminal self.add_assets() # Copy input file to metadata # Optional property: manual factors self.manual_factors: typing.List[typing.List[int]] = [] if config.args.manual_factors is not None: self.manual_factors = csv_to_list(config.args.manual_factors)
def __init__(self, config: experiment.CLIConfiguration): ''' Experiment configuration. ''' experiment.name(config.args.name) # set experiment configuration, executable and data output. self.config = config self.executable = self.config.args.executable self.csv_output = self.config.args.csv_output # establish custom snap properties. self.snap_input = self.config.args.snapinfile self.snap_output = self.config.args.snapoutfile self.data: typing.Dict[str, list] = { 'commands': list(), 'results': list() } self.emit_conf() # Emit config to terminal self.add_assets() # Copy input file to metadata record # Label of data to be obtained. self.keywords = [ 'Parallel Setup', 'Input', 'Setup', 'Solve', 'Parameter Setup', 'Outer Source', 'Inner Iterations', 'Inner Source', 'Transport Sweeps', 'Inner Misc Ops', 'Solution Misc Ops', 'Output', 'Total Execution time', 'Grind Time (nanoseconds)', ]
def main(argv): # Name the experiment. experiment.name('ooo') exprs = [ '4 / 3 * 2 - 1 + 0', '-1 - -2 - -3', '-(1 - 2) - (3 - 4)', '((1 / 2) * (3 * 4))', '((1 / 2) * (3 * 4)) - 5 / 6 * 7**8', '((1 / 2) * (3 * 4)) - 5 / 6 * 7**8 % 9', '(10 % 9) % 8 - 7 * 6 + 5 % (4)', '0**0', '0**1', '1**0', '-10**2', '-(10)**-2', '-1**2-3', '2**(3**4)', '(2**3)**4', '2**3**4', '-1**2**-3**4 * 5', '1+1+-1+3' ] for i in exprs: logger.log(F'# Testing {i}') pa = int(eval(i)) me = mathex.evaluate(i) logger.log(F'# Python says the answer is {pa}') logger.log(F'# Mathex says the answer is {me}') # Our goal is consistency with Python. if (pa != me): raise ValueError(F'{pa} != {me}') logger.log('')
def main(argv): # Program description desc = 'bueno run script for Laghos experiments.' # Default values defaults = experiment.CannedCLIConfiguration.Defaults defaults.csv_output = 'data.csv' defaults.description = experiment.name() defaults.executable = '/AMG/test/amg' defaults.input = 'experiments/quick' defaults.name = 'AMG' defaults.runcmds = (0, 2, 'srun -n %n', 'nidx + 1') # Initial configuration config = experiment.CannedCLIConfiguration(desc, argv, defaults) # Parse provided arguments config.parseargs() for genspec in experiment.readgs(config.args.input, config): # Note that config is updated by readgs after each iteration. exprmnt = Experiment(config) exprmnt.run(genspec) exprmnt.report()
def main(argv): # Program description desc = 'bueno run script for Laghos experiments.' # Default values defaults = experiment.CannedCLIConfiguration.Defaults defaults.csv_output = 'data.csv' defaults.description = experiment.name() defaults.executable = '/laghos/Laghos/laghos' defaults.input = 'experiments/quick-sedov-blast2D' defaults.name = 'laghos' defaults.runcmds = (0, 2, 'srun -n %n', 'nidx + 1') # Initial configuration config = experiment.CannedCLIConfiguration(desc, argv, defaults) # Update configuration to include extra arguments if utils.module_imported('icaptdb'): config.addargs(icaptdb.AddArgsAction) # Parse provided arguments config.parseargs() for genspec in experiment.readgs(config.args.input, config): # Note that config is updated by readgs after each iteration. exprmnt = Experiment(config) exprmnt.run(genspec) exprmnt.report()
def main(argv): experiment.name('hello-container') container.run('echo "hello from a container!"') host.run('echo "hello from the host!"')
# # Copyright (c) 2019-2020 Triad National Security, LLC # All rights reserved. # # This file is part of the bueno project. See the LICENSE file at the # top-level directory of this distribution for more information. # from bueno.public import experiment from bueno.public import host from bueno.public import logger from bueno.public import metadata experiment.name('metadata') 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'))