U
    Uc                     @   sl   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m	Z	 e
dZG dd	 d	e	jZdS )
z1Wrapper around plugin to conditionally enable it.    )absolute_import)division)print_functionN)base_pluginz2.2.0c                   @   s    e Zd ZdZdd Zdd ZdS )WhatIfToolPluginLoaderz]WhatIfToolPlugin factory.
    This class checks for `tensorflow` install and dependency.
    c                 C   sP   zddl }W n tk
r"   Y dS X ttj}|tk r<dS ddlm} ||S )zReturns the plugin, if possible.
        Args:
          context: The TBContext flags.
        Returns:
          A WhatIfToolPlugin instance or None if it couldn't be loaded.
        r   N)WhatIfToolPlugin)	
tensorflowImportErrorpkg_resourcesparse_versiontensorboard__version___MIN_TENSORBOARD_VERSIONZ!tensorboard_plugin_wit.wit_pluginr   )selfcontextr   versionr    r   L/tmp/pip-unpacked-wheel-15h0ro02/tensorboard_plugin_wit/wit_plugin_loader.pyload&   s    zWhatIfToolPluginLoader.loadc                 C   sV   | d}z0|jdddtddd |jdd	d
tddd W n tjk
rP   Y nX d S )Nzwhat-if-toolz%--whatif-use-unsafe-custom-predictionZcustom_predict_fnzYOUR_CUSTOM_PREDICT_FUNCTION.py a   The file location of your custom prediction function. Note               that the flag executes arbitrary code, so make sure you passed the               correct file location. See how to define the function in               https://github.com/PAIR-code/what-if-tool/blob/master/README.md)destmetavartypedefaulthelpz--whatif-data-dirZwit_data_dirPATHz|An optional additional directory under which the What-If Tool can load example data from, outside of the TensorBoard logdir.)add_argument_groupadd_argumentstrargparseArgumentError)r   parsergroupr   r   r   define_flags=   s(    


z#WhatIfToolPluginLoader.define_flagsN)__name__
__module____qualname____doc__r   r#   r   r   r   r   r   !   s   r   )r'   
__future__r   r   r   r   r
   r   Ztensorboard.pluginsr   r   r   ZTBLoaderr   r   r   r   r   <module>   s   
