ó
ÉČ÷Xc           @` sŇ  d  Z  d d l m Z d d l m Z d d l m 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 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 d d l m Z e j d d d  e j d e d  e j d d d  e j d d d  e j Z i d e j 6d e j 6d e j 6d e j 6Z  d   Z! d e	 j" e j# f d     YZ$ d d  Z% e& d  k rÎe j'   n  d S(!   s   Serve TensorFlow summary data to a web frontend.

This is a simple web server to proxy data from the event_loader to the web, and
serve static web files.
i    (   t   absolute_import(   t   division(   t   print_functionN(   t   app(   t   flags(   t   logging(   t   resource_loader(   t
   status_bar(   t   event_accumulator(   t   event_multiplexer(   t   tensorboard_handlert   logdirsö  logdir specifies the directory where
TensorBoard will look to find TensorFlow event files that it can display.
TensorBoard will recursively walk the directory structure rooted at logdir,
looking for .*tfevents.* files.

You may also pass a comma seperated list of log directories, and TensorBoard
will watch each directory. You can also assign names to individual log
directories by putting a colon between the name and the path, as in

tensorboard --logdir=name1:/path/to/logs/1,name2:/path/to/logs/2
t   debugsL   Whether to run the app in debug mode. This increases log verbosity to DEBUG.t   hosts   0.0.0.0s   What host to listen to. Defaults to serving on 0.0.0.0, set to 127.0.0.1 (localhost) todisable remote access (also quiets security warnings).t   portiv  s"   What port to serve TensorBoard on.iô  i   ič  i   c         C` s   i  } |  d k r | Sxd |  j d  D]S } d | k rc | d d k rc | j d d  \ } } n d } | } | | | <q& W| S(   s#  Parses the logdir flag into a map from paths to run group names.

  The events files flag format is a comma-separated list of path specifications.
  A path specification either looks like 'group_name:/path/to/directory' or
  '/path/to/directory'; in the latter case, the group is unnamed. Group names
  cannot start with a forward slash: /foo:bar/baz will be interpreted as a
  spec with no name and path '/foo:bar/baz'.

  Globs are not supported.

  Args:
    flag_value: A comma-separated list of run specifications.
  Returns:
    A dict mapping directory paths to names like {'/path/to/directory': 'name'}.
    Groups without an explicit name are named after their path. If flag_value
    is None, returns an empty dict, which is helpful for testing things that
    don't require any valid runs.
  t   ,t   :i    t   /i   N(   t   Nonet   split(   t
   flag_valuet   filest   specificationt   run_namet   path(    (    sd   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/tensorflow/tensorboard/tensorboard.pyt   ParseEventFilesFlagK   s    t   ThreadedHTTPServerc           B` s   e  Z d  Z e Z RS(   s   A threaded HTTP server.(   t   __name__t
   __module__t   __doc__t   Truet   daemon(    (    (    sd   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/tensorflow/tensorboard/tensorboard.pyR   n   s   c         C` s  t  j r) t j t j  t j d  n  t  j sC t j d  d St  j re t j d t j	    n  t
 t  j  } t j d | d d d t  } | j d	 d
  t j t j |  } y t t  j t  j f |  } Wn( t j k
 r t j d t  j  d SXy) t j d  j   } t j d |  Wn$ t k
 rPt j d  d } n Xt j d | t  j  t d | t  j f  t d t  j  | j   d  S(   Ns   TensorBoard is in debug mode.sN   A logdir must be specified. Run `tensorboard --help` for details and examples.i˙˙˙˙s$   Starting TensorBoard in directory %st   path_to_runt   interval_secsi<   t   size_guidancet   intervali   s8   Tried to connect to port %d, but that address is in use.iţ˙˙˙s   tensorboard/TAGs   TensorBoard is tag: %ss   Unable to read TensorBoard tagt    s   TensorBoard %ss"   Starting TensorBoard %s on port %ds)   (You can navigate to http://localhost:%d)(    t   FLAGSR   R   t   set_verbosityt   DEBUGt   infoR   t   errort   ost   getcwdR   R	   t   AutoloadingMultiplexert   TENSORBOARD_SIZE_GUIDANCEt
   AutoUpdatet	   functoolst   partialR
   t   TensorboardHandlerR   R   R   t   socketR   t   load_resourcet   stript   IOErrort   warningR   t   SetupStatusBarInsideGooglet   printt   serve_forever(   t   unused_argvR    t   multiplexert   factoryt   servert   tag(    (    sd   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/tensorflow/tensorboard/tensorboard.pyt   maint   s>    							

t   __main__((   R   t
   __future__R    R   R   t   BaseHTTPServerR/   R*   R2   t   SocketServert   tensorflow.python.platformt
   tensorflowR   R   R   R   R   t   tensorflow.python.summaryR   R	   t   tensorflow.tensorboardR
   t   DEFINE_stringR   t   DEFINE_booleant   Falset   DEFINE_integerR%   t   COMPRESSED_HISTOGRAMSt   IMAGESt   SCALARSt
   HISTOGRAMSR-   R   t   ThreadingMixInt
   HTTPServerR   R?   R   t   run(    (    (    sd   /tmp/pip-build-UG86a1/tensorflow/tensorflow-0.6.0.data/purelib/tensorflow/tensorboard/tensorboard.pyt   <module>   sD   
	


	#	)