def testMain(self): session_id = uuid.uuid1() scheduler_address = '127.0.0.1:' + self.scheduler_port actor_client = new_client() session_ref = actor_client.create_actor( SessionActor, uid=SessionActor.gen_name(session_id), address=scheduler_address, session_id=session_id) a = ones((100, 100), chunks=30) * 2 * 1 + 1 b = ones((100, 100), chunks=30) * 2 * 1 + 1 c = (a * b * 2 + 1).sum() graph = c.build_graph() targets = [c.key] graph_key = uuid.uuid1() session_ref.submit_tensor_graph(json.dumps(graph.to_json()), graph_key, target_tensors=targets) check_time = time.time() while True: time.sleep(1) self.check_process_statuses() if time.time() - check_time > 60: raise SystemError('Check graph status timeout') if session_ref.graph_state(graph_key) == GraphState.SUCCEEDED: result = session_ref.fetch_result(graph_key, c.key) break expected = (np.ones(a.shape) * 2 * 1 + 1)**2 * 2 + 1 assert_array_equal(loads(result), expected.sum()) a = ones((100, 50), chunks=30) * 2 + 1 b = ones((50, 200), chunks=30) * 2 + 1 c = a.dot(b) graph = c.build_graph() targets = [c.key] graph_key = uuid.uuid1() session_ref.submit_tensor_graph(json.dumps(graph.to_json()), graph_key, target_tensors=targets) check_time = time.time() while True: time.sleep(1) self.check_process_statuses() if time.time() - check_time > 60: raise SystemError('Check graph status timeout') if session_ref.graph_state(graph_key) == GraphState.SUCCEEDED: result = session_ref.fetch_result(graph_key, c.key) break assert_array_equal(loads(result), np.ones((100, 200)) * 450)
def testMain(self): session_id = uuid.uuid1() scheduler_address = '127.0.0.1:' + self.scheduler_port actor_client = new_client() session_ref = actor_client.create_actor( SessionActor, uid=SessionActor.gen_name(session_id), address=scheduler_address, session_id=session_id) a = ones((100, 100), chunks=30) * 2 * 1 + 1 b = ones((100, 100), chunks=30) * 2 * 1 + 1 c = (a * b * 2 + 1).sum() graph = c.build_graph() targets = [c.key] graph_key = uuid.uuid1() session_ref.submit_tensor_graph(json.dumps(graph.to_json()), graph_key, target_tensors=targets) state = self.wait_for_termination(session_ref, graph_key) self.assertEqual(state, GraphState.SUCCEEDED) result = session_ref.fetch_result(graph_key, c.key) expected = (np.ones(a.shape) * 2 * 1 + 1)**2 * 2 + 1 assert_array_equal(loads(result), expected.sum()) graph_key = uuid.uuid1() session_ref.submit_tensor_graph(json.dumps(graph.to_json()), graph_key, target_tensors=targets) # todo this behavior may change when eager mode is introduced state = self.wait_for_termination(session_ref, graph_key) self.assertEqual(state, GraphState.FAILED) a = ones((100, 50), chunks=30) * 2 + 1 b = ones((50, 200), chunks=30) * 2 + 1 c = a.dot(b) graph = c.build_graph() targets = [c.key] graph_key = uuid.uuid1() session_ref.submit_tensor_graph(json.dumps(graph.to_json()), graph_key, target_tensors=targets) state = self.wait_for_termination(session_ref, graph_key) self.assertEqual(state, GraphState.SUCCEEDED) result = session_ref.fetch_result(graph_key, c.key) assert_array_equal(loads(result), np.ones((100, 200)) * 450)