U
    Vc	                     @   s`   d 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
 ZdS )zPublic API for the Embedding Projector.

@@ProjectorPluginAsset
@@ProjectorConfig
@@EmbeddingInfo
@@EmbeddingMetadata
@@SpriteMetadata
    N)text_format)tf)metadata)EmbeddingInfo)SpriteMetadata)ProjectorConfigc              	      sj   t  d fdd   dkr&tdt|}tj tj}t	j
j|d}|| W 5 Q R X dS )a  Stores a config file used by the embedding projector.

    Args:
      logdir: Directory into which to store the config file, as a `str`.
        For compatibility, can also be a `tf.compat.v1.summary.FileWriter`
        object open at the desired logdir.
      config: `tf.contrib.tensorboard.plugins.projector.ProjectorConfig`
        proto that holds the configuration for the projector such as paths to
        checkpoint files and metadata files for the embeddings. If
        `config.model_checkpoint_path` is none, it defaults to the
        `logdir` used by the summary_writer.

    Raises:
      ValueError: If the summary writer does not have a `logdir`.
    Z
get_logdirc                      s    S )N r   logdirr   J/tmp/pip-unpacked-wheel-g8kmtpbc/tensorboard/plugins/projector/__init__.py<lambda>:       z&visualize_embeddings.<locals>.<lambda>Nz*Expected logdir to be a path, but got Nonew)getattr
ValueError_text_formatZMessageToStringospathjoin	_metadataZPROJECTOR_FILENAMEr   ioZgfileZGFilewrite)r
   configZconfig_pbtxtr   fr   r	   r   visualize_embeddings)   s    
r   )__doc__r   Zgoogle.protobufr   r   Ztensorboard.compatr   Ztensorboard.plugins.projectorr   r   Z2tensorboard.plugins.projector.projector_config_pb2r   r   r   r   r   r   r   r   <module>   s   
