def test_perf_and_ipc(self): perf = ex.PerfModel() ipc = ex.CompIPC() datastore = mdl.DataStore() for i in range(10): perf_seed = perf.get_seed('lalal') if i > 0: data_item = datastore['ipc'][-1] ipc_eta = ipc.get('get_perf_bid', data_item) perf_seed.apply('set_ipc_bid', ipc_eta) dc_perf = datastore['perf'].add_new() perf_seed.run(dc_perf) ipc_perf_data = perf.get('get_ipc_data', datastore['perf'][-1]) ipc_seed = ipc.get_seed('asdf') ipc_seed.apply('set_perf_data', ipc_perf_data) dc_ipc = datastore['ipc'].add_new() ipc_seed.run(dc_ipc) print('FLOWS') for pdata in datastore['perf']: #print(pdata) print(pdata['result'].get_json()['FLOW']) #print(datastore['ipc'][0]['result'].get_json()) print('ETAS') for cdata in datastore['ipc']: print(cdata['result'].get_json()['eta'])
def test_append(self): dstore = mdl.DataStore() dstack = dstore['ASDF'] new_container = dstack.add_new() s_exp = '{"foo": "bar"}' new_container['item'].write(s_exp) s_ret = dstore['ASDF'][0]['item'].read() self.assertEquals(s_ret, s_exp)
def test_simple_model_execution(self): """ Run a simple model and check that we can look at some results """ model = mdl.Model() model.add_subsystem('EngineCycle', ex.PerfModel()) runnable_model = model.configure({'EngineCycle': 'lalala'}) datastore = mdl.DataStore() runnable_model.run('EngineCycle', datastore) self.assertTrue('EngineCycle' in datastore) ditem = datastore['EngineCycle'][-1] perf_data = ex.PerfAccessor(ditem) print(perf_data.data)
def test_coupled_model_execution(self): """ Run a model with one node connected to another """ model = mdl.Model() model.add_subsystem('EngineCycle', ex.PerfModel()) model.add_subsystem('IPC', ex.CompIPC()) # good connection model.connect(src='EngineCycle.get_ipc_data', dst='IPC.set_perf_data') runnable_model = model.configure(defaultdict(lambda: 'asdf')) datastore = mdl.DataStore() runnable_model.run('EngineCycle', datastore) runnable_model.run('IPC', datastore) print(datastore) print(datastore['EngineCycle'][-1]['result'].read()) print(datastore['IPC'][-1]['result'].read())
def test_cyclic_model_execution(self): """ Set up a simple model with a cyclic data dependency and get the thing to run """ model = mdl.Model() model.add_subsystem('EngineCycle', ex.PerfModel()) model.add_subsystem('IPC', ex.CompIPC()) model.connect(src='EngineCycle.get_ipc_data', dst='IPC.set_perf_data') model.connect(src='IPC.get_perf_bid', dst='EngineCycle.set_ipc_bid') runnable_model = model.configure(defaultdict(lambda: 'asdf')) datastore = mdl.DataStore() history = [] for _ in range(5): runnable_model.run('EngineCycle', datastore) runnable_model.run('IPC', datastore) d = model.get(datastore, 'EngineCycle', 'get_ipc_data') if history: self.assertTrue(d is not history[-1]) history.append(d) print(d.flow)
def test_contains(self): dstore = mdl.DataStore() dstack = dstore['ASDF'] self.assertTrue('ASDF' in dstore)
def test_create(self): mdl.DataStore()
def test_full_model(self): model = ex.build_model() runnable_model = model.configure(defaultdict(lambda: 'asdf')) datastore = mdl.DataStore() ex.execute(runnable_model, datastore)