
    i                         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Z ej                  e      Z	  G d d	      Zy)
    )Any   )build_plugin_setup_client)Config)Configuration)load_and_installNc                   L    e Zd ZdZdededdfdZdedefdZd	ed
e	de
ddfdZy)PluginAwareaU  
    Base class for classes that support plugin loading.

    This class provides functionality to lazily load plugins when they are first accessed.
    Subclasses must set the following attributes before calling super().__init__():
    - config: Config
    - _openapi_config: OpenApiConfig
    - _pool_threads: int

    These attributes are considered private and should not be used by end users. The config property
    is also considered private, but it was originally named without the underscore and this name
    can't be changed without breaking compatibility with plugins in the wild.
    argskwargsreturnNc                    d| _         	 g }t        | d      s|j                  d       t        | d      s|j                  d       t        | d      s|j                  d       |rtt        j	                  ddj                  |       d| j                  j                   d       t        ddj                  |       d| j                  j                   d      y	)
a  
        Initialize the PluginAware class.

        Args:
            *args: Variable length argument list.
            **kwargs: Arbitrary keyword arguments.

        Raises:
            AttributeError: If required attributes are not set in the subclass.
        Fconfig_openapi_config_pool_threadsz5PluginAware class requires the following attributes: z, z. These must be set in the z; class's __init__ method before calling super().__init__().N)	_plugins_loadedhasattrappendloggererrorjoin	__class____name__AttributeError)selfr   r   missing_attrss       m/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pinecone/utils/plugin_aware.py__init__zPluginAware.__init__   s      % tX&  *t./  !23t_-  1LLG		R_H`Ga b,,0NN,C,C+D E56
 !G		R_H`Ga b,,0NN,C,C+D E56      namec                 j   t         j                  d|       g d}||v r&t        d| j                  j                   d| d      | j
                  st         j                  d| j                  j                         	 t        j                  | d      }t        j                  | d      }t        j                  | d	      }| j                  |||
       d| _        	 t        j                  | |      S t        d| j                  j                   d| d      # t        $ r Y nw xY w6# t        $ r Y Aw xY w)a  
        Called when an attribute is not found through the normal lookup process.
        This allows for lazy loading of plugins when they are first accessed.

        Args:
            name: The name of the attribute being accessed.

        Returns:
            The requested attribute.

        Raises:
            AttributeError: If the attribute cannot be found after loading plugins.
        z__getattr__ called for %s)r   r   r   'z' object has no attribute 'zb'. This attribute must be set in the subclass's __init__ method before calling super().__init__().zLoading plugins for %sr   r   r   r   openapi_configpool_threadsT)	r   debugr   r   r   r   object__getattribute__load_plugins)r   r    required_attrsr   r$   r%   s         r   __getattr__zPluginAware.__getattr__?   sA    	0$7G>! DNN++,,Gv N5 6  ##LL14>>3J3JK00x@!'!8!8?P!Q%66t_M!!!.| "  (,$!224>> q!8!8 99TUYTZZ[\]] & ! s1   <AD& D 	D"D& !D""D& &	D21D2r   r$   r%   c                 8   	 t        |||      }t        | |       t        j                  d| j                  j
                         y# t        $ r }t        j                  d|       Y d}~yd}~wt        $ r"}t        j                  d|d       Y d}~yd}~ww xY w)z
        Load plugins for the parent class.

        Args:
            config: The Pinecone configuration.
            openapi_config: The OpenAPI configuration.
            pool_threads: The number of threads in the pool.
        r#   z"Plugins loaded successfully for %sz"Failed to import plugin module: %sNzError loading plugins: %sT)exc_info)
r   install_pluginsr   r&   r   r   ImportErrorwarning	Exceptionr   )r   r   r$   r%   openapi_client_builderes         r   r)   zPluginAware.load_pluginsl   s    	H%>n<&" D"89LL=t~~?V?VW 	DNN?CC 	HLL4a$LGG	Hs$   AA 	BA++B7BB)r   
__module____qualname____doc__r   r   strr+   r   OpenApiConfigintr)    r   r   r
   r
      sc    !c !S !T !F+^ +^ +^ZHH.;HKNH	Hr   r
   )typingr   setup_openapi_clientr   pinecone.configr   %pinecone.config.openapi_configurationr   r8   pinecone_plugin_interfacer   r.   logging	getLoggerr   r   r
   r:   r   r   <module>rB      s:     ; " P I 			8	$ uH uHr   