
    ^jJ              	           d dl mZ d dlmZ d dlZddlmZ ddee   defdZddee   defd	Z	ddee   d
ee   fdZ
ddee   ded
efdZ	 	 	 ddee   deded
dfdZy)    )Optional)protonN   )flagssessionphasec                     | yt         j                  r| dk7  rt        d      t        j                  t        j                  | |            S )z
    Retrieves profiling data for a given session.

    Args:
        session (Optional[int]): The session ID of the profiling session, or None if profiling is inactive.
    Returns:
        str: The profiling data in JSON format.
    Nr   EOnly one session can be retrieved when running from the command line.)r   command_line
ValueErrorjsonloads	libprotonget_datar   r   s     _/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/triton/profiler/data.pygetr      sC     gl`aa::i((%899    c                 t    | yt         j                  r| dk7  rt        d      t        j                  | |      S )a  
    Retrieves profiling data for a given session encoded with MessagePack.

    Args:
        session (Optional[int]): The session ID of the profiling session, or None if profiling is inactive.

    Returns:
        bytes: The profiling data encoded with MessagePack.
    Nr   r
   )r   r   r   r   get_data_msgpackr   s     r   get_msgpackr      s:     gl`aa%%gu55r   returnc                 r    | yt         j                  r| dk7  rt        d      t        j                  |       S )z
    Advances the profiling phase for a given session.

    Args:
        session (Optional[int]): The session ID of the profiling session, or None if profiling is inactive.

    Returns:
        Optional[int]: The next phase number after advancing.
    Nr   zFOnly one session can advance phase when running from the command line.)r   r   r   r   advance_data_phase)r   s    r   advance_phaser   (   s8     glabb''00r   c                 t    | yt         j                  r| dk7  rt        d      t        j                  | |      S )a  
    Checks if the profiling data for a given session and phase is complete.

    A "complete" phase is safe to read/clear because all device-side records for
    the phase have been flushed to the host and the phase will no longer receive
    new records.

    Args:
        session (Optional[int]): The session ID of the profiling session, or None if profiling is inactive.
        phase (int): The phase number to check. Defaults to 0.

    Returns:
        bool: True if the phase data is complete, False otherwise.
    Fr   zVOnly one session can check phase completion status when running from the command line.)r   r   r   r   is_data_phase_completer   s     r   is_phase_completer   9   s:     glqrr++GU;;r   clear_up_to_phasec                 x    | yt         j                  r| dk7  rt        d      t        j                  | ||       y)aC  
    Clears profiling data for a given session.

    Args:
        session (Optional[int]): The session ID of the profiling session, or None if profiling is inactive.
        phase (int): The phase number to clear. Defaults to 0.
        clear_up_to_phase (bool): If True, clear all phases up to and including `phase`.
    Nr   zCOnly one session can be cleared when running from the command line.)r   r   r   r   
clear_data)r   r   r   s      r   clearr"   O   s:     gl^__%):;r   )r   r   )r   )r   r   F)typingr   triton._C.libprotonr   r   r   r   intr   r   r   boolr   r"    r   r   <module>r(      s     3  :# :3 : 6# 63 6"18C= 1# 1"<x} < <T <. #<c]<< < 
	<r   