def test_main(): name = 'test_index.html' if os.path.exists(name): os.remove(name) main(name, 'test_x') assert os.path.exists(name) os.remove(name)
def test_runner_implicit_program_run(): try: sys.argv.append('-f') sys.argv.append("tests/fld_test_program.txt") runner.clean_up() runner.parse_args() runner.main() except Exception as e: raise e
def test_runner_stream_input(): with open("tests/fld_test_program.txt", 'rt') as f: sys.stdin = f try: sys.argv.append('-p') runner.clean_up() runner.parse_args() assert runner.from_pipe assert not runner.from_file runner.main(False) except Exception as e: raise e
def up_to_date_map(): if request.method == "POST": try: day = request.form.get('day') print(day) runner.main(day) print('it worked') return redirect(url_for("generated_map")) except ValueError as e: print(e) print(day) return redirect(url_for("index")) print('it even got here') return render_template("my_map.html")
def test_debug(): try: sys.argv.pop() sys.argv.pop() sys.argv.append('-f') sys.argv.append("tests/fld_test_program.txt") sys.argv.append('--debug') runner.clean_up() runner.parse_args() assert '-f' not in sys.argv assert runner.from_file assert not runner.from_pipe assert runner.debug runner.main(False) except Exception as e: raise e
def main(): argparser = argparse.ArgumentParser() argparser.add_argument('--wrapper', '-w', help='python script with function create_model ' + 'that takes modeldir ' '(that is, directory where experiment saves ' + 'the checkpoints etc)' + 'and returns dict -> dict function (model).' + 'By default, studio-serve will try to determine ' + 'this function automatically.', default=None) argparser.add_argument('--port', help='port to run Flask server on', type=int, default=5000) argparser.add_argument('--host', help='host name.', default='0.0.0.0') argparser.add_argument( '--killafter', help='Shut down after this many seconds of inactivity', default=3600) options, other_args = argparser.parse_known_args(sys.argv[1:]) serve_args = ['studio::serve_main'] assert len(other_args) >= 1 experiment_key = other_args[-1] runner_args = other_args[:-1] runner_args.append('--reuse={}/modeldir:modeldata'.format(experiment_key)) runner_args.append('--force-git') runner_args.append('--port=' + str(options.port)) if options.wrapper: serve_args.append('--wrapper=' + options.wrapper) serve_args.append('--port=' + str(options.port)) serve_args.append('--host=' + options.host) serve_args.append('--killafter=' + str(options.killafter)) total_args = runner_args + serve_args runner.main(total_args)
def main(): driver = webdriver.Chrome(options=set_chrome_options()) try: import runner result = runner.main(driver) except Exception as e: result = e finally: driver.close() return result
def run_and_add_to_csv(results_file_path,num_of_parties,key_size,set_size,old_method,strategy,bandwidth=None,latency=None,num_threads=None): start_time = time.time() print "Run with bandwidth {0} and latency {1}".format(bandwidth,latency) result = runner.main(key_size=key_size,num_parties=num_of_parties,set_size=set_size,old_method=old_method,strategy=strategy,num_threads=num_threads) if len(result) != num_of_parties: return False final_results = ['|'.join(map(str, list(item[1]))) for item in sorted(result.items(),key= lambda x:x[0])] row = [REV,str(bandwidth),str(latency),str(start_time),str(key_size),str(num_of_parties), str(num_threads), str(set_size),str(old_method),runner.getStrategyName(strategy)] + final_results with open(results_file_path, 'ab') as csvfile: csvwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) csvwriter.writerow(row) return True
def run_and_add_to_csv(results_file_path, num_of_parties, key_size, set_size, old_method, strategy, bandwidth=None, latency=None, num_threads=None): start_time = time.time() print "Run with bandwidth {0} and latency {1}".format(bandwidth, latency) result = runner.main(key_size=key_size, num_parties=num_of_parties, set_size=set_size, old_method=old_method, strategy=strategy, num_threads=num_threads) if len(result) != num_of_parties: return False final_results = [ '|'.join(map(str, list(item[1]))) for item in sorted(result.items(), key=lambda x: x[0]) ] row = [ REV, str(bandwidth), str(latency), str(start_time), str(key_size), str(num_of_parties), str(num_threads), str(set_size), str(old_method), runner.getStrategyName(strategy) ] + final_results with open(results_file_path, 'ab') as csvfile: csvwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) csvwriter.writerow(row) return True
__version__ = "0.1.0" try: import runner except ModuleNotFoundError: from name_that_hash import runner if __name__ == "__main__": runner.main()
import runner import os if __name__ == '__main__': thisdir = os.path.dirname( os.path.realpath( __file__ ) ) runner.main(thisdir)
# DM18-0995 # import runner import subprocess import os import uuid import shutil def handler(tc, tc_support, outdir): src_files, headers = tc header_dirs = set([os.path.split(hdr)[0] for hdr in headers]) cmd = ["clang", "--analyze"] cmd += ["-Xanalyzer", "-analyzer-output=plist"] cmd += ["-Xanalyzer", "-analyzer-checker=alpha.security"] cmd += ["-I" + tc_support] for hd in header_dirs: cmd += ["-I" + hd] cmd += src_files FNULL = open(os.devnull, 'w') proc = subprocess.Popen(cmd, stderr=FNULL, stdout=FNULL) proc.communicate() for item in os.listdir("."): if item.endswith(".plist"): shutil.move(item, os.path.join(outdir, item)) runner.main(handler)
import argparse import runner if __name__ == '__main__': parser = argparse.ArgumentParser(description='run command and eval score') parser.add_argument('command', help='comma separated command') parser.add_argument('--run_num', default=3, help='num of running process') parser.add_argument('--label', default='noname', help='label of the program') args = parser.parse_args() runner.main(args)
# coding=utf-8 # NOTE: this file must have valid python 2 syntax. We want to display an error message # when running with python 2. import sys pythonVersion = sys.version.split()[0] if not pythonVersion.startswith('3.'): sys.stderr.write("\nFEHLER: es wird Python 3 benoetigt, nicht " + pythonVersion + ".\n\n") if sys.flags.interactive: import os os._exit(ecode) else: sys.exit(ecode) if __name__ == '__main__': import runner runner.main(globals())
""" This is a very hackish runner for cross compilation toolchain scratchbox. Later on we might come out with some general solution """ import os def args_for_scratchbox(cwd, args): return ['/scratchbox/login', '-d', str(cwd)] + args def run_scratchbox(args, cwd, out, timeout=None): return run(args_for_scratchbox(cwd, args), cwd, out, timeout) def dry_run_scratchbox(args, cwd, out, timeout=None): return dry_run(args_for_scratchbox(cwd, args), cwd, out, timeout) import runner # XXX hack hack hack dry_run = runner.dry_run run = runner.run runner.dry_run = dry_run_scratchbox runner.run = run_scratchbox if __name__ == '__main__': import sys runner.main(sys.argv)
""" This is a very hackish runner for cross compilation toolchain scratchbox. Later on we might come out with some general solution """ import os def args_for_scratchbox(cwd, args): return ['/scratchbox/login', '-d', str(cwd)] + args def run_scratchbox(args, cwd, out, timeout=None): return run(args_for_scratchbox(cwd, args), cwd, out, timeout) def dry_run_scratchbox(args, cwd, out, timeout=None): return dry_run(args_for_scratchbox(cwd, args), cwd, out, timeout) if __name__ == '__main__': import runner # XXX hack hack hack dry_run = runner.dry_run run = runner.run runner.dry_run = dry_run_scratchbox runner.run = run_scratchbox import sys runner.main(sys.argv)
from math import factorial as fact def run(): count = 0 for n in xrange(23, 101): r = 1 fn = fact(n) while fn / fact(r) / fact(n - r) < 10**6: r += 1 o = 2 * (int(n / 2) + 1 - r) - (1 if n % 2 == 0 else 0) count += o return count from runner import main main(run)
args.clip = 0.25 args.log_interval = 200 args.nhead = 2 args.is_manual_update = True args.wandb = None # None means no. add project name # wandb project: world-language-model-pytorch-examples args.early_stop = 10 args.is_quickrun = False # =========================================== # args.wandb = 'world-language-model-pytorch-examples' args.is_quickrun = True args.epoch = 5 args.is_manual_update = False args.model = 'LSTM' main(args) # args.model = 'GRU' # main(args) # args.model = 'RNN_TANH' # main(args) # args.model = 'RNN_RELU' # main(args) # args.model = 'Transformer' # main(args) # # args.is_manual_update = False # args.model = 'LSTM' # main(args) # args.model = 'GRU' # main(args) # args.model = 'RNN_TANH'
runner.memory_fraction_attacked = attacker_fraction print("Checking that no experiment pods are present") if len(running_experiment_pods()) > 0: print("Cleaning up before new job") clean_experiment_pods() print( "SR job starts. scheduler: '%s', sgx: %f, attack: %f, trace: '%s', skip: %d" % (scheduler, sgx_fraction, attacker_fraction, args.trace, args.skip)) intermediate_file = "rawrunner_%s_%s_%f_%f.txt" % ( filename_time, scheduler, sgx_fraction, attacker_fraction) with open(intermediate_file, "w") as f: runner.main(args.trace, args.skip, f) print("Runner finished, waiting for all pods to finish...") while True: nb_pods = len([ x for x in running_experiment_pods() if x.status.phase in ("Pending", "Running") ]) print("Still %d pods to wait" % nb_pods) if nb_pods > 0: time.sleep(10) else: break print("Finished, now parsing logs") output_file = "runner_%s_%s_%f_%f.txt" % (
check='eslint', config=conf.ESLINT_CONFIG, output='Running eslint over commit', command='eslint {}', match_files=[b'.*\.js'], ignore_files=[ b'.*bower_components/.*', b'.*node_modules/.*', ], print_filename=True, ), ] if __name__ == '__main__': sys.path.append( os.path.dirname(os.path.dirname(os.path.realpath(__file__))) ) import conf import runner import utils filename, _ = os.path.splitext(os.path.basename(__file__)) hook, Check = utils.check_factory(filename) checks = pre_commit_checks(Check, hook) utils.notify('Begin {} hook'.format(hook)) all_files = False if len(sys.argv) > 1 and sys.argv[1] == '--all-files': all_files = True runner = runner.Runner() runner.main(hook, checks, all_files)
def test_main_exits_with_status_code_0(self): result = runner.main() assert result == 0
def test_main_return_1_or_0(self): result = runner.main() assert result == 1 or result == 0
def model_base(lr=.001, rho=.9, epsilon=1.0e-6): nn = Sequential() nn.add(BatchNormalization(input_shape=(3, 101, 101))) nn.add(MyConvolution2D(16, 6, 6, init='he_normal')) nn.add(LeakyReLU(alpha=.01)) nn.add(MaxPooling2D()) nn.add(MyConvolution2D(16, 5, 5, init='he_normal')) nn.add(LeakyReLU(alpha=.01)) nn.add(MaxPooling2D()) nn.add(MyConvolution2D(16, 3, 3, init='he_normal')) nn.add(LeakyReLU(alpha=.01)) nn.add(MaxPooling2D()) nn.add(Flatten()) nn.add(Dense(200)) nn.add(LeakyReLU(alpha=.01)) nn.add(Dense(100)) nn.add(LeakyReLU(alpha=.01)) nn.add(Dense(2)) nn.add(LeakyReLU(alpha=.01)) nn.add(Activation('softmax')) nn.compile(loss='binary_crossentropy', optimizer=Adamax(lr=lr), class_mode='binary') return nn if __name__ == '__main__': from runner import main main()
def setup_class(cls): runner.main(['command', '--output_dir', cls.test_dir,'examples/results.json'])
def lambda_handler(event, context): from runner import main main()
#!/usr/bin/env python """runner [-v|-q] [-c config] taskdir""" # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from runner import main if __name__ == '__main__': main()