o
    bi)                  
   @   sx  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 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j-ej.d e&j'd!de(ej/d"0ej/d e&j'd#de)ej1d$0ej1d e&j'd%de)ej2d&0ej2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.d/d0 e&j'd1ddd2d3 e&j'd4d.d5d0 e&j'd6de(d7d8d e&j'd9de(d7d:d e&3 Z4zejd;krVe4j5nd Z6ejd;krae4j7nd<Z8ee4j9e4j:e4j;e4j<e6e8d= e=e4j>e4j?e6e8 e4j@reAe4j@Bd>Cd?Z@ndZ@e ZDe$dWi d@e4jEdAe4jFdBe4jGdCe4jHdDe4jIdEe4jJdFe4j;dGe4j9dHe4j:dIe4j<dJe6dKe8dLe4jKdMe4jLdNe4jMdOe4jN dPe@ZdQdR ZOejd;kreDPejQeO eDReS  W dS  eTy9 ZU z;eeV ZWdSeX d<  dTeW ZYeZeUej[re#\eY ne#]eY eUe ej^eYe
j_j`e4jHdUdV W Y dZU[UdS dZU[Uww dS )X    N)OptionalSet)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   K/home/ubuntu/.local/lib/python3.10/site-packages/ray/dashboard/dashboard.py__init__5   sF   
	

zDashboard.__init__c                    s   | j  I d H  d S N)r   run)r!   r   r   r"   r%   ]   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.)r/   r0   defaultr1   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    r7   )r/   r0   r2   choicesr1   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]`.)actionr1   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.)r/   r2   r1   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   
rH   zThe dashboard on node z" failed with the following error:
)address)
gcs_clientr   )aargparser3   rD   platformrF   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.utilsr   ray._privater   ray._private.ray_loggingr   ray._private.utilsr   r   	getLoggerr&   rB   r	   ArgumentParserparseradd_argumentr*   r+   LOGGER_LEVELLOGGER_LEVEL_CHOICESLOGGER_LEVEL_HELPLOGGER_FORMATLOGGER_FORMAT_HELPDASHBOARD_LOG_FILENAMEformatLOGGING_ROTATE_BYTESLOGGING_ROTATE_BACKUP_COUNT
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_frontendrH   add_signal_handlerrG   run_until_completer%   	Exceptione
format_exctraceback_strunamemessage
isinstanceFrontendNotFoundErrorrC   errorDASHBOARD_DIED_ERROR_raylet	GcsClientr   r   r   r"   <module>   s   

D
		

	

 