def start_server(wbconfig, mp): host = wbconfig.get("host", "0.0.0.0") port = wbconfig.getint("port", 2628) backlog = wbconfig.getint("backlog", 512) timeout = wbconfig.getint("timeout", 60) or None address = (host, port) master.init(address, backlog) drop_privs(wbconfig) master.run(timeout, mp)
'alpha': 3.0 }] for param in params: for row in rows: # time.sleep(DELAY) print('--- Param Experiment - ' + param['strategy'] + ' - ' + param['id'] + ' ---') startTime = time.time() np.random.seed(0) random.seed(0) A = np.random.randint(256, size=(row, col)) x = np.random.randint(256, size=(col, 1)) keys, times, comps, stops, ideals = run(A, x, iteration, param) np.save( 'statistics/Param_' + param['strategy'] + '_' + param['id'] + '_Exp.npy', time.time() - startTime) np.save( 'statistics/Param_' + param['strategy'] + '_' + param['id'] + '_Key.npy', keys) np.save( 'statistics/Param_' + param['strategy'] + '_' + param['id'] + '_Time.npy', times) np.save( 'statistics/Param_' + param['strategy'] + '_' + param['id'] + '_Comp.npy', comps) np.save(
sys.stdout = open('/tmp/raven.log', 'a') sys.stderr = sys.stdout def check_sh(): cur = LooseVersion(sh.__version__) want = LooseVersion('1.11') if cur < want: log.error('sh version %s required (%s found), probably due to https://github.com/amoffat/sh/commit/5b3a99cdc03dac6b171ce095efea20332d9b7c01' % (want, cur)) sys.exit(1) if __name__ == '__main__': if len(sys.argv) != 2: print('Usage: %s <role>' % (sys.argv[0],)) sys.exit(1) # We might share our tmpspace with other roles config.tmpdir = '%s/%s' % (config.tmpdir, sys.argv[1]) check_sh() log.log('Starting raven %s as %s..' % (config.version, sys.argv[1])) amqp.init() if sys.argv[1] == 'watcher': watcher.run() elif sys.argv[1] == 'master': master.run() elif sys.argv[1] == 'worker': worker.run()
slaveNames = ['Step', 'Gain', 'Subtraction'] sequences = list(itertools.permutations(range(3))) fmus, connections = configuration.read(fmuDir, 'StepSubtraction.xml') dt = .25 t0, tEnd = 0., 2. axs[0, 0].set_title('Gain, y2') axs[0, 1].set_title('Subtraction, y3') for idx in range(6): sequenceIdx = tuple(slaveNames[i] for i in sequences[idx]) print "The master is producing data for the sequence {0} -> {1}".format( sequences[idx], sequenceIdx) data = master.run(fmus, connections, sequenceIdx, dt, t0, tEnd) ax = axs[idx, 0] t2s, y2s = data[('Gain', 'y')] ax.step(t2s, t2s > 1, 'r--') ax.stem(t2s, y2s, color='red', basefmt='--') plt.xlim([t0, tEnd]) ax.set_ylabel(r'$\sigma$ = {0}'.format(sequences[idx])) ax = axs[idx, 1] t3s, y3s = data[('Subtraction', 'y')] ax.step(t2s, np.zeros(t2s.shape), 'r--') ax.stem(t3s, y3s, basefmt='--') plt.xlim([t0, tEnd]) fig.set_size_inches(12, 16)
""" #============================ #以下書き換えると動作しなくなります。 #============================ import sys import master try: ok = sys.argv[1] ov = sys.argv[2] try: sub = sys.argv[3] except: sub = "1" master.run(ok, ov, sub) except: master.run()
import master master.run('2.jpg')