Beispiel #1
0
    def testLocalCluster(self):
        endpoint = gen_endpoint('0.0.0.0')
        with LocalDistributedCluster(endpoint,
                                     scheduler_n_process=2,
                                     worker_n_process=3) as cluster:
            pool = cluster.pool

            self.assertTrue(
                pool.has_actor(pool.actor_ref(
                    ClusterInfoActor.default_name())))
            self.assertTrue(
                pool.has_actor(
                    pool.actor_ref(SessionManagerActor.default_name())))
            self.assertTrue(
                pool.has_actor(pool.actor_ref(DispatchActor.default_name())))

            with new_session(endpoint) as session:
                api = session._api

                t = mt.ones((3, 3), chunk_size=2)
                result = session.run(t)

                np.testing.assert_array_equal(result, np.ones((3, 3)))

            self.assertNotIn(session._session_id,
                             api.session_manager.get_sessions())
Beispiel #2
0
    def testDistribute(self):
        distributor = gen_distributor(2, 4)

        idx = distributor.distribute(SessionActor.default_name())
        self.assertEqual(idx, 1)

        idx = distributor.distribute(
            GraphActor.gen_uid('fake_session_id', 'fake_graph_key'))
        self.assertEqual(idx, 0)

        idx = distributor.distribute(DispatchActor.default_name())
        self.assertEqual(idx, 2)

        idx = distributor.distribute('w:1:mars-sender')
        self.assertEqual(idx, 3)