Exemple #1
0
def test_profiling_info_endpoint(shutdown_only):
    ray.init(num_cpus=1)

    redis_client = ray.worker.global_worker.redis_client

    node_ip = ray.nodes()[0]["NodeManagerAddress"]

    while True:
        reporter_port = redis_client.get("REPORTER_PORT:{}".format(node_ip))
        if reporter_port:
            break

    reporter_channel = grpc.insecure_channel("{}:{}".format(
        node_ip, int(reporter_port)))
    reporter_stub = reporter_pb2_grpc.ReporterServiceStub(reporter_channel)

    @ray.remote(num_cpus=1)
    class ActorA:
        def __init__(self):
            pass

        def getpid(self):
            return os.getpid()

    a = ActorA.remote()
    actor_pid = ray.get(a.getpid.remote())

    reply = reporter_stub.GetProfilingStats(
        reporter_pb2.GetProfilingStatsRequest(pid=actor_pid, duration=10))
    profiling_stats = json.loads(reply.profiling_stats)
    assert profiling_stats is not None
Exemple #2
0
 async def launch_profiling(self, req) -> aiohttp.web.Response:
     ip = req.query["ip"]
     pid = int(req.query["pid"])
     duration = int(req.query["duration"])
     reporter_stub = self._stubs[ip]
     reply = await reporter_stub.GetProfilingStats(
         reporter_pb2.GetProfilingStatsRequest(pid=pid, duration=duration))
     profiling_info = (json.loads(reply.profiling_stats)
                       if reply.profiling_stats else reply.std_out)
     return dashboard_utils.rest_response(success=True,
                                          message="Profiling success.",
                                          profiling_info=profiling_info)
Exemple #3
0
    def launch_profiling(self, node_id, pid, duration):
        profiling_id = str(uuid.uuid4())

        def _callback(reply_future):
            reply = reply_future.result()
            with self._raylet_stats_lock:
                self._profiling_stats[profiling_id] = reply

        reporter_stub = self.reporter_stubs[node_id]
        reply_future = reporter_stub.GetProfilingStats.future(
            reporter_pb2.GetProfilingStatsRequest(pid=pid, duration=duration))
        reply_future.add_done_callback(_callback)
        return profiling_id
Exemple #4
0
 async def launch_profiling(self, req) -> aiohttp.web.Response:
     node_id = req.query.get("node_id")
     pid = int(req.query.get("pid"))
     duration = int(req.query.get("duration"))
     profiling_id = str(uuid.uuid4())
     reporter_stub = self._stubs[node_id]
     reply = await reporter_stub.GetProfilingStats(
         reporter_pb2.GetProfilingStatsRequest(pid=pid, duration=duration))
     self._profiling_stats[profiling_id] = reply
     return await dashboard_utils.rest_response(
         success=True,
         message="Profiling launched.",
         profiling_id=profiling_id)