U
    /em                  .   @  sD  d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 d dl4m5Z5 d d	l6m7Z7 e0e-e/e3e%e$e7e1e.e+e,e&e'e2ee(ed
ddde(ed
dde(ede(ede(ede(e!d
e(ed
e(e"d
e(ed
dde(ed
dde(ed
e(e#de(ede(ede(ede(e ddde(e ddde(eddde(eddde(eddde(eddde(ede(ede(ede(ede(ede)e*eed-Z8edd Z9d ddZ:dS )!    )annotations)urljoin)memoize)web)IOLoop)gpu_docgpu_memory_docgpu_utilization_doc)%AggregateActionBandwidthTypesBandwidthWorkersClusterMemoryComputePerKeyCurrentLoad	EventLoopExceptionsTableMemoryByKey	OccupancySystemMonitorSystemTimeseries	TaskGraphTaskGroupGraphTaskGroupProgressTaskProgress
TaskStreamWorkerNetworkBandwidthWorkersMemoryWorkersTransferBytesWorkerTable
events_docexceptions_doc	graph_dochardware_docindividual_docindividual_profile_docindividual_profile_server_docprofile_docprofile_server_docshuffling_doc
status_docstealing_docsystemmonitor_doc	tasks_doctg_graph_docworkers_doc)BokehApplication)counters_docd   i  Z10s)Zn_rectanglesZclear_interval   )height   Z
cpu_figure)Zfig_attrZprocessing_figurei  	bandwidthZdiskcpuZmemory)-z/systemz/shufflez	/stealingz/workersz/exceptionsz/eventsz	/countersz/tasksz/statusz/profilez/profile-serverz/graphz	/hardwarez/groupsz/gpuz/individual-task-streamz/individual-progressz/individual-graphz/individual-groupsz/individual-group-progressz/individual-workers-memoryz/individual-cluster-memoryz"/individual-workers-transfer-bytesz/individual-cpuz/individual-nprocessingz/individual-occupancyz/individual-workersz/individual-exceptionsz/individual-bandwidth-typesz/individual-bandwidth-workersz/individual-workers-networkz/individual-workers-diskz&/individual-workers-network-timeseriesz"/individual-workers-cpu-timeseriesz%/individual-workers-memory-timeseriesz#/individual-workers-disk-timeseriesz/individual-memory-by-keyz /individual-compute-time-per-keyz%/individual-aggregate-time-per-actionz/individual-scheduler-systemz/individual-event-loopz/individual-profilez/individual-profile-serverz/individual-gpu-memoryz/individual-gpu-utilizationc                  C  s^   ddl m}  d|  dkrdgng ddd tD dddg d}t|d dd d|d< |S )Nr   )device_get_countstatusworkerstaskssystemZgpuprofilegraphgroupsinfoc                 S  sR   g | ]J}d |kr| dd| dddd  dddd	d
qS )Z
individual/ -   NZCpuZCPUZGpuZGPUurlname)stripjoinsplittitlereplace).0x rN   C/tmp/pip-unpacked-wheel-g426oqom/distributed/dashboard/scheduler.py
<listcomp>   s   "  z&template_variables.<locals>.<listcomp>ZhardwareZHardwarerD   )ZpagesplotsrQ   c                 S  s   | d S )NrF   rN   )drN   rN   rO   <lambda>       z$template_variables.<locals>.<lambda>)key)r8   r9   r:   r;   )r<   r=   r>   r?   )Zdistributed.diagnostics.nvmlr7   applicationssorted)r7   template_variablesrN   rN   rO   rX   y   s.            
 
rX    c              
   C  sd   t t||t d}| | |t  |ddtj	dt
|p@ddd difg |  d S )N)prefixrX   z.*r@   rE   rY   r8   )r/   rV   rX   Zadd_applicationZ
initializer   currentadd_handlersr   ZRedirectHandlerr   rG   start)ZapplicationZhttp_serverZ	schedulerrZ   Z	bokeh_apprN   rN   rO   connect   s"       
r^   N)rY   );
__future__r   urllib.parser   Ztlzr   Ztornador   Ztornado.ioloopr   Z%distributed.dashboard.components.nvmlr   r   r	   Z*distributed.dashboard.components.schedulerr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   Zdistributed.dashboard.corer/   Zdistributed.dashboard.workerr0   rV   rX   r^   rN   rN   rN   rO   <module>   s   '                 A
"