
    .`i
                        d dl Z d dlmZmZ d dlmZ erd dlmZ 	 d dlZn# e	$ r  ed          ZY nw xY wde
e         de
e         de
e         fd	Zde
e         de
e         de
e         fd
Z	 	 	 dded         dede
e         dz  de
e         fdZ	 	 ddddede
e         dz  de
e         dz  deeee
e         f         f
dZdS )    N)TYPE_CHECKINGOptional)PlaceholderModule)
BaseClientboto3pathspatternsreturnc                      fd| D             S )Nc                 L    g | ]t          fd D                        S )c              3   B   K   | ]}t          j         |          V  d S Nfnmatch.0patternpaths     t/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/vllm/transformers_utils/s3_utils.py	<genexpr>z+_filter_allow.<locals>.<listcomp>.<genexpr>   s/      FF'wtW--FFFFFF    anyr   r   r	   s    @r   
<listcomp>z!_filter_allow.<locals>.<listcomp>   sM       FFFFXFFFFF  r    r   r	   s    `r   _filter_allowr      .          r   c                      fd| D             S )Nc                 L    g | ]t          fd D                        S )c              3   B   K   | ]}t          j         |          V  d S r   r   r   s     r   r   z,_filter_ignore.<locals>.<listcomp>.<genexpr>   s/      JJg7?411JJJJJJr   r   r   s    @r   r   z"_filter_ignore.<locals>.<listcomp>   sM       JJJJJJJJJ  r   r   r   s    `r   _filter_ignorer#      r   r    s3r   r   allow_patternc                     | t          j        d          } |                    d          s|dz   }t          | ||          \  }}fd|D             S )a)  
    List full file names from S3 path and filter by allow pattern.

    Args:
        s3: S3 client to use.
        path: The S3 path to list from.
        allow_pattern: A list of patterns of which files to pull.

    Returns:
        list[str]: List of full S3 paths allowed by the pattern
    Nr%   /)r   r&   c                      g | ]
}d  d| S )s3://r(   r   )r   r   bucket_names     r   r   zglob.<locals>.<listcomp>7   s*    ;;;T(K(($((;;;r   )r   clientendswith
list_files)r%   r   r&   _r   r+   s        @r   globr0   "   sk      
z\$== cz&rMRRRKE;;;;U;;;;r   ignore_patternc                 ~   |                     d                              d          }d                    |dd                   }|d         }|                     ||          }d |                    dg           D             }t          |d	g          }|t          ||          }|t          ||          }|||fS )
aZ  
    List files from S3 path and filter by pattern.

    Args:
        s3: S3 client to use.
        path: The S3 path to list from.
        allow_pattern: A list of patterns of which files to pull.
        ignore_pattern: A list of patterns of which files not to pull.

    Returns:
        tuple[str, str, list[str]]: A tuple where:
            - The first element is the bucket name
            - The second element is string represent the bucket
              and the prefix as a dir like string
            - The third element is a list of files allowed or
              disallowed by pattern
    r*   r(      Nr   )BucketPrefixc                     g | ]
}|d          S )Keyr   )r   objs     r   r   zlist_files.<locals>.<listcomp>V   s    ???CSZ???r   Contentsz*/)removeprefixsplitjoinlist_objects_v2getr#   r   )	r%   r   r&   r1   partsprefixr+   objectsr   s	            r   r.   r.   :   s    . g&&,,S11EXXeABBi  F(K  F CCG??7;;z2#>#>???E54&))E e]33!un55%%r   )Nr$   N)NN)r   typingr   r   vllm.utils.import_utilsr   botocore.clientr   r   ImportErrorliststrr   r#   r0   tupler.   r   r   r   <module>rI      s    * * * * * * * * 5 5 5 5 5 5 +******'LLLL ' ' 'g&&EEE'c d3i DI    $s) tCy T#Y     "&&*< <<
< 9t#< 
#Y	< < < <6 '+'+	%& %&%&
%& 9t#%& I$	%&
 3T#Y%& %& %& %& %& %&s   ! 44