python/ray/state.py
def chrome_tracing_dump(self, filename=None):
        """Return a list of profiling events that can viewed as a timeline.

        To view this information as a timeline, simply dump it as a json file
        by passing in "filename" or using using json.dump, and then load go to
        chrome://tracing in the Chrome web browser and load the dumped file.
        Make sure to enable "Flow events" in the "View Options" menu.

        Args:
            filename: If a filename is provided, the timeline is dumped to that
                file.

        Returns:
            If filename is not provided, this returns a list of profiling
                events. Each profile event is a dictionary.
        """
        # TODO(rkn): Support including the task specification data in the
        # timeline.
        # TODO(rkn): This should support viewing just a window of time or a
        # limited number of events.

        self._check_connected()

        profile_table = self.profile_table()
        all_events = []

        for component_id_hex, component_events in profile_table.items():
            # Only consider workers and drivers.
            component_type = component_events[0]["component_type"]
            if component_type not in ["worker", "driver"]:
                continue

            for event in component_events:
                new_event = {
                    # The category of the event.
                    "cat": event["event_type"],
                    # The string displayed on the event.
                    "name": event["event_type"],
                    # The identifier for the group of rows that the event
                    # appears in.
                    "pid": event["node_ip_address"],
                    # The identifier for the row that the event appears in.
                    "tid": event["component_type"] + ":" + event["component_id"],
                    # The start time in microseconds.
                    "ts": self._seconds_to_microseconds(event["start_time"]),
                    # The duration in microseconds.
                    "dur": self._seconds_to_microseconds(
                        event["end_time"] - event["start_time"]
                    ),
                    # What is this?
                    "ph": "X",
                    # This is the name of the color to display the box in.
                    "cname": self._default_color_mapping[event["event_type"]],
                    # The extra user-defined data.
                    "args": event["extra_data"],
                }

                # Modify the json with the additional user-defined extra data.
                # This can be used to add fields or override existing fields.
                if "cname" in event["extra_data"]:
                    new_event["cname"] = event["extra_data"]["cname"]
                if "name" in event["extra_data"]:
                    new_event["name"] = event["extra_data"]["name"]

                all_events.append(new_event)

        if not all_events:
            logger.warning(
                "No profiling events found. Ray profiling must be enabled "
                "by setting RAY_PROFILING=1."
            )

        if filename is not None:
            with open(filename, "w") as outfile:
                json.dump(all_events, outfile)
        else:
            return all_events
Return a list of profiling events that can viewed as a timeline.

        To view this information as a timeline, simply dump it as a json file
        by passing in "filename" or using using json.dump, and then load go to
        chrome://tracing in the Chrome web browser and load the dumped file.
        Make sure to enable "Flow events" in the "View Options" menu.

        Args:
            filename: If a filename is provided, the timeline is dumped to that
                file.

        Returns:
            If filename is not provided, this returns a list of profiling
                events. Each profile event is a dictionary.
        
Return a list of profiling events that can viewed as a timeline.
To view this information as a timeline, simply dump it as a json file
by passing in "filename" or using using json.dump, and then load go to
chrome://tracing in the Chrome web browser and load the dumped file.
Make sure to enable "Flow events" in the "View Options" menu.
Return a list of profiling events that can viewed as a timeline . To view this information as a timeline simply dump it as a json file by passing in " filename " or using using json . dump and then load go to chrome : // tracing in the Chrome web browser and load the dumped file . Make sure to enable " Flow events " in the " View Options " menu .
def chrome_tracing_dump(self, filename=None):
        self._check_connected()
        profile_table = self.profile_table()
        all_events = []
        for component_id_hex, component_events in profile_table.items():
            component_type = component_events[0]["component_type"]
            if component_type not in ["worker", "driver"]:
                continue
            for event in component_events:
                new_event = {
                    "cat": event["event_type"],
                    "name": event["event_type"],
                    "pid": event["node_ip_address"],
                    "tid": event["component_type"] + ":" + event["component_id"],
                    "ts": self._seconds_to_microseconds(event["start_time"]),
                    "dur": self._seconds_to_microseconds(
                        event["end_time"] - event["start_time"]
                    ),
                    "ph": "X",
                    "cname": self._default_color_mapping[event["event_type"]],
                    "args": event["extra_data"],
                }
                if "cname" in event["extra_data"]:
                    new_event["cname"] = event["extra_data"]["cname"]
                if "name" in event["extra_data"]:
                    new_event["name"] = event["extra_data"]["name"]
                all_events.append(new_event)
        if not all_events:
            logger.warning(
                "No profiling events found. Ray profiling must be enabled "
                "by setting RAY_PROFILING=1."
            )
        if filename is not None:
            with open(filename, "w") as outfile:
                json.dump(all_events, outfile)
        else:
            return all_events
def chrome_tracing_dump ( self , filename = None ) : self . _check_connected ( ) profile_table = self . profile_table ( ) all_events = [ ] for component_id_hex , component_events in profile_table . items ( ) : component_type = component_events [ 0 ] [ "component_type" ] if component_type not in [ "worker" , "driver" ] : continue for event in component_events : new_event = { "cat" : event [ "event_type" ] , "name" : event [ "event_type" ] , "pid" : event [ "node_ip_address" ] , "tid" : event [ "component_type" ] + ":" + event [ "component_id" ] , "ts" : self . _seconds_to_microseconds ( event [ "start_time" ] ) , "dur" : self . _seconds_to_microseconds ( event [ "end_time" ] - event [ "start_time" ] ) , "ph" : "X" , "cname" : self . _default_color_mapping [ event [ "event_type" ] ] , "args" : event [ "extra_data" ] , } if "cname" in event [ "extra_data" ] : new_event [ "cname" ] = event [ "extra_data" ] [ "cname" ] if "name" in event [ "extra_data" ] : new_event [ "name" ] = event [ "extra_data" ] [ "name" ] all_events . append ( new_event ) if not all_events : logger . warning ( "No profiling events found. Ray profiling must be enabled " "by setting RAY_PROFILING=1." ) if filename is not None : with open ( filename , "w" ) as outfile : json . dump ( all_events , outfile ) else : return all_events
Return a list of profiling events that can viewed as a timeline.
Return a list of profiling events that can viewed as a timeline .
"""Return a list of profiling events that can viewed as a timeline.

        To view this information as a timeline, simply dump it as a json file
        by passing in "filename" or using using json.dump, and then load go to
        chrome://tracing in the Chrome web browser and load the dumped file.
        Make sure to enable "Flow events" in the "View Options" menu.

        Args:
            filename: If a filename is provided, the timeline is dumped to that
                file.

        Returns:
            If filename is not provided, this returns a list of profiling
                events. Each profile event is a dictionary.
        """ # TODO(rkn): Support including the task specification data in the # timeline. # TODO(rkn): This should support viewing just a window of time or a # limited number of events. # Only consider workers and drivers. # The category of the event. # The string displayed on the event. # The identifier for the group of rows that the event # appears in. # The identifier for the row that the event appears in. # The start time in microseconds. # The duration in microseconds. # What is this? # This is the name of the color to display the box in. # The extra user-defined data. # Modify the json with the additional user-defined extra data. # This can be used to add fields or override existing fields.
If filename is not provided, this returns a list of profiling
events. Each profile event is a dictionary.
If filename is not provided this returns a list of profiling events . Each profile event is a dictionary .
self
filename
If a filename is provided, the timeline is dumped to that
file.
If a filename is provided the timeline is dumped to that file .