o
    $i*                  
   @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZm	Z	 d dl
Z
d dlm  mZ d dlm  mZ d dlm  mZ d dlm  mZ d dlmZmZ d dlmZ d dlmZ d dlm Z  d dl!m"Z"m#Z# e$e%Z&G dd	 d	Z'e%d
kr>e j(ddZ)e)j*dde+dd e)j*dde,dd e)j*dde,d dd e)j*dde+dd e)j*dde+dd e)j*dde+dd e)j*dddd ej-ej.ej/d  e)j*d!de+ej0ej1d e)j*d"de+ej2d#3ej2d e)j*d$de,ed%3ed e)j*d&de,ed'3ed e)j*d(de+dd)d e)j*d*de+dd+d e)j*d,de+dd-d e)j*d.d/d0d1 e)j*d2ddd3d4 e)j*d5d/d6d1 e)j*d7de+d8d9d e)j*d:de+d8d;d e)4 Z5zejd<krZe5j6nd Z7ejd<kree5j8nd=Z9e e5j:e5j;e5j<e5j=e7e9d> e>e5j?e5j@e7e9 e5jAreBe5jACd?Dd@ZAndZAe ZEe'dXi dAe5jFdBe5jGdCe5jHdDe5jIdEe5jJdFe5jKdGe5j<dHe5j:dIe5j;dJe5j=dKe7dLe9dMe5jLdNe5jMdOe5jNdPe5jO dQeAZdRdS ZPejd<kreEQejReP eESeT  W dS  eUy= ZV z;e"eW ZXdTeY d=  dUeX ZZe[eVej\re&]eZ ne&^eZ eVe#ej_eZe
j`jae5jIdVdW W Y dZV[VdS dZV[Vww dS )Y    N)OptionalSet)LOGGING_ROTATE_BACKUP_COUNTLOGGING_ROTATE_BYTES)get_or_create_event_loop)logging_utils)setup_component_logger)format_error_messagepublish_error_to_driverc                %   @   sz   e Zd ZdZ					ddedededed	ed
edededededededededededeee  f"ddZ	dd Z
dS )	Dashboarda5  A dashboard process for monitoring Ray nodes.

    This dashboard is made up of a REST API which collates data published by
        Reporter processes on nodes into a json structure, and a webserver
        which polls said API for display purposes.

    Args:
        host: Host address of dashboard aiohttp server.
        port: Port number of dashboard aiohttp server.
        port_retries: The retry times to select a valid port.
        gcs_address: GCS address of the cluster.
        cluster_id_hex: Cluster ID hex string.
        node_ip_address: The IP address of the dashboard.
        serve_frontend: If configured, frontend HTML
            is not served from the dashboard.
        log_dir: Log directory of dashboard.
        logging_level: The logging level (e.g. logging.INFO, logging.DEBUG)
        logging_format: The format string for log messages
        logging_filename: The name of the log file
        logging_rotate_bytes: Max size in bytes before rotating log file
        logging_rotate_backup_count: Number of backup files to keep when rotating
    NFThostportport_retriesgcs_addresscluster_id_hexnode_ip_addresslog_dirlogging_levellogging_formatlogging_filenamelogging_rotate_byteslogging_rotate_backup_counttemp_dirsession_dirminimalserve_frontendmodules_to_loadc                 C   sx   t jdi d|d|d|d|d|d|d|d|d	|	d
|
d|d|d|d|d|d|d|| _ d S )N	http_host	http_porthttp_port_retriesr   r   r   r   r   r   r   r   r   r   r   r   r   r    )dashboard_headDashboardHead)selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r    T/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/dashboard/dashboard.py__init__9   sF   
	

zDashboard.__init__c                    s   | j  I d H  d S N)r!   run)r#   r    r    r$   r'   a   s   zDashboard.run)NNFTN)__name__
__module____qualname____doc__strintboolr   r   r%   r'   r    r    r    r$   r   !   sV    %	


(r   __main__zRay dashboard.)descriptionz--hostTz$The host to use for the HTTP server.)requiredtypehelpz--portz$The port to use for the HTTP server.z--port-retriesFz'The retry times to select a valid port.)r1   r2   defaultr3   z--gcs-addresszThe address (ip:port) of GCS.z--cluster-id-hexzThe cluster ID in hex.z--node-ip-addressz1The IP address of the node where this is running.z--logging-levelc                 C   s   t |  S r&   )logginggetLevelNameupper)sr    r    r$   <lambda>   s    r9   )r1   r2   r4   choicesr3   z--logging-formatz--logging-filenamezISpecify the name of log file, log to stdout if set empty, default is "{}"z--logging-rotate-byteszASpecify the max bytes for rotating log file, default is {} bytes.z--logging-rotate-backup-countz<Specify the backup count of rotated log file, default is {}.z	--log-dirz"Specify the path of log directory.z
--temp-dirz?Specify the path of the temporary directory use by Ray process.z--session-dirz9Specify the path of the session directory of the cluster.z	--minimal
store_truezMinimal dashboard only contains a subset of features that don't require additional dependencies installed when ray is installed by `pip install ray[default]`.)actionr3   z--modules-to-loadzSpecify the list of module names in [module_1],[module_2] format.E.g., JobHead,StateHead... If nothing is specified, all modules are loaded.)r1   r4   r3   z--disable-frontendz;If configured, frontend html is not served from the server.z--stdout-filepath z&The filepath to dump dashboard stdout.z--stderr-filepathz&The filepath to dump dashboard stderr.win32   )r   r   r   filename	max_bytesbackup_countz ,,r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                   C   s   t d ttj d S )Nz#Exiting with SIGTERM immediately...)loggerwarningos_exitsignalSIGTERMr    r    r    r$   sigterm_handler  s   
rJ   zThe dashboard on node z" failed with the following error:
)address)
gcs_clientr    )bargparser5   rF   platformrH   sys	tracebacktypingr   r   rayray._private.ray_constants_privateray_constantsray.dashboard.consts	dashboardconstsdashboard_constsray.dashboard.headheadr!   ray.dashboard.utilsutilsdashboard_utilsray._common.ray_constantsr   r   ray._common.utilsr   ray._privater   ray._private.ray_loggingr   ray._private.utilsr	   r
   	getLoggerr(   rD   r   ArgumentParserparseradd_argumentr,   r-   LOGGER_LEVELLOGGER_LEVEL_CHOICESLOGGER_LEVEL_HELPLOGGER_FORMATLOGGER_FORMAT_HELPDASHBOARD_LOG_FILENAMEformat
parse_argsargsr   logging_rotation_bytesr   logging_rotation_backup_countr   r   r   r    redirect_stdout_stderr_if_neededstdout_filepathstderr_filepathr   setstripsplitloopr   r   r   r   r   r   r   r   r   disable_frontendrJ   add_signal_handlerrI   run_until_completer'   	Exceptione
format_exctraceback_strunamemessage
isinstanceFrontendNotFoundErrorrE   errorDASHBOARD_DIED_ERROR_raylet	GcsClientr    r    r    r$   <module>   s   

D
		

	

 