
    ߔ9i                     <   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mZmZmZmZmZmZmZ d dlmZ d dlmZmZ d dlmZmZ dd	lmZmZ dd
lmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&  e#jN                  e(      Z) G d d      Z*dee+e	f   de,fdZ-dee+e	f   de+de,fdZ.dee+e	f   de,fdZ/dee+e	f   de,fdZ0dee+e	f   de,fdZ1d!de+dee+e	df   dee+   fdZ2dee+e	f   de,fdZ3d"dee+e	f   dee+   de4fdZ5 G d de      Z6ed        Z7 G d d       Z8y)#    N)contextmanager)Path)CallableDictIteratorListOptionalTuple	TypedDictUnion)urlparse)REPO_TYPES_URL_PREFIXESREPOCARD_NAME)metadata_loadmetadata_save   )HfApirepo_type_and_id_from_hf_id)LFS_MULTIPART_UPLOAD_COMMAND)HfFolderSoftTemporaryDirectoryloggingrun_subprocesstqdmvalidate_hf_hub_argsc                       e Zd ZdZ	 ddedededej                  dee   f
dZ	e
d	efd
       Ze
d	efd       Ze
d	efd       Ze
d	efd       Ze
d	efd       Zd Zy)CommandInProgressz=
    Utility to follow commands launched asynchronously.
    Ntitleis_done_methodstatus_methodprocesspost_methodc                 f    || _         || _        || _        || _        d| _        d| _        || _        y )N )r   _is_done_status_process_stderr_stdout_post_method)selfr   r   r    r!   r"   s         d/var/www/html/backtest/airagagent/rag_env/lib/python3.12/site-packages/huggingface_hub/repository.py__init__zCommandInProgress.__init__#   s6     
&$'    returnc                 p    | j                         }|r#| j                  | j                          d| _        |S )z.
        Whether the process is done.
        N)r%   r*   )r+   results     r,   is_donezCommandInProgress.is_done3   s6    
 d''3 $Dr.   c                 "    | j                         S )z
        The exit code/status of the current action. Will return `0` if the
        command has completed successfully, and a number between 1 and 255 if
        the process errored-out.

        Will return -1 if the command is still ongoing.
        )r&   r+   s    r,   statuszCommandInProgress.status@   s     ||~r.   c                      | j                   dkD  S )z2
        Whether the process errored-out.
        r   )r5   r4   s    r,   failedzCommandInProgress.failedK   s    
 {{Qr.   c                     | j                   j                  7| xj                  | j                   j                  j                         z  c_        | j                  S )zC
        The current output message on the standard error.
        )r'   stderrr(   readr4   s    r,   r9   zCommandInProgress.stderrR   ?    
 ==+LLDMM005577L||r.   c                     | j                   j                  7| xj                  | j                   j                  j                         z  c_        | j                  S )zD
        The current output message on the standard output.
        )r'   stdoutr)   r:   r4   s    r,   r=   zCommandInProgress.stdout[   r;   r.   c           	          | j                   }|dk(  rd}d| j                   d| d| j                  sdnd d| j                  j                   d		S )
Nrunning[z command, status code: z, zin progress.z	finished.z PID: ])r5   r   r2   r'   pid)r+   r5   s     r,   __repr__zCommandInProgress.__repr__d   s`    R<F 

|26( ;&*llD E!!"!%	
r.   N)__name__
__module____qualname____doc__strr   
subprocessPopenr	   r-   propertyboolr2   intr5   r7   r9   r=   rD    r.   r,   r   r      s     +/(( !(  	(
 !!( h'(  
 
 
            

r.   r   folderr/   c                 (   t         j                  j                  t         j                  j                  | d            }t	        j
                  dj                         | t        j                  t        j                        }|xr |j                  dk(  S )a  
    Check if the folder is the root or part of a git repository

    Args:
        folder (`str`):
            The folder in which to run the command.

    Returns:
        `bool`: `True` if the repository is part of a repository, `False`
        otherwise.
    z.gitz
git branch)cwdr=   r9   r   )	ospathexistsjoinrK   runsplitPIPE
returncode)rQ   folder_exists
git_branchs      r,   is_git_repor^   q   sc     GGNN277<<#?@M 2 2 4&akapapqJ7Z22a77r.   
remote_urlc                     t        |       syt        d|       j                  }t        j                  dd|      }|j                         D cg c]  }t        j                  dd|       }}||v S c c}w )am  
    Check if the folder is a local clone of the remote_url

    Args:
        folder (`str` or `Path`):
            The folder in which to run the command.
        remote_url (`str`):
            The url of a git repository.

    Returns:
        `bool`: `True` if the repository is a local clone of the remote
        repository specified, `False` otherwise.
    Fzgit remote -vhttps://.*@https://)r^   r   r=   resubrY   )rQ   r_   remotesremotes       r,   is_local_clonerg      sl     v_f5<<G 
J?JHOXfrvvnj&9XGX   Ys   A0filenamec                    t        |       j                  }t        |       j                  } 	 t        dj	                         | gz   |      }|j
                  j                         }t        |      dk(  rydddd}|j	                  d      D ]&  }|j                         D ]  }||v sd|v sd||<    ( t        |j                               S # t        j                  $ r*}t        |      sY d}~yt        |j                        d}~ww xY w)	z
    Check if the file passed is tracked with git-lfs.

    Args:
        filename (`str` or `Path`):
            The filename to check.

    Returns:
        `bool`: `True` if the file passed is tracked with git-lfs, `False`
        otherwise.
    zgit check-attr -aNFr   )diffmergefilter
lfsT)r   parentnamer   rY   r=   striprK   CalledProcessErrorr^   OSErrorr9   lenkeysallvalues)rh   rQ   p
attributesexcfound_lfs_tag	attributetags           r,   is_tracked_with_lfsr~      s    (^""FH~""H&.446(CVLXX^^%
 :!"UeDM%%d+ *	 %%' 	*CiEY$6%)c"	**
 }##%&&! (( &6"#**%%	&s   8C D	D/DD	c                 (   t        |       j                  }t        |       j                  } 	 t        dj	                         | gz   |d      }t        |j                         }|S # t        j                  $ r}t        |j                        d}~ww xY w)a  
    Check if file is git-ignored. Supports nested .gitignore files.

    Args:
        filename (`str` or `Path`):
            The filename to check.

    Returns:
        `bool`: `True` if the file passed is ignored by `git`, `False`
        otherwise.
    zgit check-ignoreFcheckN)r   ro   rp   r   rY   rN   r[   rK   rr   rs   r9   )rh   rQ   rx   
is_ignoredrz   s        r,   is_git_ignoredr      s     (^""FH~""H"-335
BFRWXall++
  (( "cjj!!"s   6A$ $B7BBc           	      
   	 t        | d      5 }|j                  d      }ddd       t        h dt        t	        dd            dhz
  z        }t        j                  d|            S # 1 sw Y   KxY w# t        $ r Y yw xY w)	z
    Check if file is a binary file.

    Args:
        filename (`str` or `Path`):
            The filename to check.

    Returns:
        `bool`: `True` if the file passed is a binary file, `False` otherwise.
    rbi   N>         	   
                      T)openr:   	bytearraysetrangerN   	translateUnicodeDecodeError)rh   fcontent
text_charss       r,   is_binary_filer      s    	(D! 	-Qff^,G	-
 83uT5?Q;RVZU[;[[\
G%%dJ788	- 	-  s(   A6 A*A	A6 *A3/A6 6	BBpatternc                 F   	 t        dj                         | gz   |      }t        |j                  j	                               r+|j                  j	                         j                  d      }|S g }	 |S # t
        j                  $ r}t        |j                        d}~ww xY w)aQ  
    Returns a list of filenames that are to be staged.

    Args:
        pattern (`str` or `Path`):
            The pattern of filenames to check. Put `.` to get all files.
        folder (`str` or `Path`):
            The folder in which to run the command.

    Returns:
        `List[str]`: List of files that are to be staged.
    z#git ls-files --exclude-standard -morm   N)	r   rY   rt   r=   rq   rK   rr   EnvironmentErrorr9   )r   rQ   rx   filesrz   s        r,   files_to_be_stagedr      s    +@FFHG9TV\]qxx~~ HHNN$**40E L	 E L (( +szz**+s   A*A3 .A3 3B BB c                     	 t        d|        y# t        j                  $ r#}d|j                  v rt	        d      Y d}~yd}~ww xY w)a  
    Check if the current checked-out branch is tracked upstream.

    Args:
        folder (`str` or `Path`):
            The folder in which to run the command.

    Returns:
        `bool`: `True` if the current checked-out branch is tracked upstream,
        `False` otherwise.
    z4git rev-parse --symbolic-full-name --abbrev-ref @{u}THEADzNo branch checked outNF)r   rK   rr   r9   rs   )rQ   rz   s     r,   is_tracked_upstreamr   	  sF    MvV(( SZZ122	s    AA  Aupstreamc                     	 t        d|xs d |       }t        |j                  j                  d            dz
  S # t        j
                  $ r}t        |j                        d}~ww xY w)a  
        Check the number of commits that would be pushed upstream

        Args:
            folder (`str` or `Path`):
                The folder in which to run the command.
            upstream (`str`, *optional*):
    The name of the upstream repository with which the comparison should be
    made.

        Returns:
            `int`: Number of commits that would be pushed upstream were a `git
            push` to proceed.
    zgit cherry -v r$   rm   r   N)r   rt   r=   rY   rK   rr   r   r9   )rQ   r   r1   rz   s       r,   commits_to_pushr     sc    +.R0@ A6J6==&&t,-11(( +szz**+s   9< A)A$$A)c                   "    e Zd ZU eed<   eed<   y)PbarTbar
past_bytesN)rF   rG   rH   r   __annotations__rO   rP   r.   r,   r   r   5  s    	IOr.   r   c               #   6  K   t         j                         t        j                  k\  r	 d ydt
        j                  fd} t        j                  j                  dd      }t               5 }t        j                  j                  |d      t        j                  d<   t         j                  dt        j                  d           t        j                         }t        j                  | |fd	      }|j                          	 d |j!                          |j                          |t        j                  d<   	 ddd       y# t        $ r Y yw xY w# |j!                          |j                          |t        j                  d<   w xY w# 1 sw Y   yxY ww)
zv
    This is a context manager that will log the Git LFS progress of cleaning,
    smudging, pulling and pushing.
    Nstopping_eventc           	      0    i fddt         t           f fd}t        j                  j	                  t        j
                  d         s^ j                         r         yt        j                  d       t        j                  j	                  t        j
                  d         s^ |t        j
                  d         D ]  }	 |j                         \  }}}}|j                          d| }|j                  d	      \  }	}
t        |	      }t        |
      }j                  ||f      }|#t        |||d
dd      t        |	      d||f<   |d   j                  ||d   z
         ||d<    y# t        $ r}t        d|       |d}~ww xY w)zl
        To be launched as a separate thread with an event meaning it should stop
        the tail.
        c                      j                         D ]O  } | d   j                  | d   j                  | d   z
         | d   j                          | d   j	                          Q y )Nr   r   )rw   updatetotalrefreshclose)pbarpbarss    r,   close_pbarsz?_lfs_log_progress.<locals>.output_progress.<locals>.close_pbarsQ  s^     $U""4;#4#4tL7I#IJU##%U!!#$r.   r/   c              3   J  K   t        | d      5 }d}	 j                         r         na|j                         }|9t        |j	                               dk(  s||z  }|j                  d      r| d}nt        j                  d       y	 ddd       y# 1 sw Y   yxY ww)z
            Creates a generator to be iterated through, which will return each
            line one by one. Will stop tailing the file if the stopping_event is
            set.
            rr$   Nr   rm   r   )r   is_setreadlinert   rq   endswithtimesleep)rh   filecurrent_lineline_bitr   r   s       r,   	tail_filez=_lfs_log_progress.<locals>.output_progress.<locals>.tail_fileW  s      h$ &!%,,.##}}H+C8H4IQ4N$0'006"..+-L

1  & & &s   B#A=B	B#B B#GIT_LFS_PROGRESSN   z!Cannot unpack LFS progress line:
z file /BTi   )descinitialr   unit
unit_scaleunit_divisor)r   r   r   r   )r   rJ   rT   rU   rV   environr   r   r   rY   
ValueError
capitalizerO   getr   r   )r   r   linestatefile_progressbyte_progressrh   errordescriptioncurrent_bytestotal_bytescurrent_bytes_inttotal_bytes_intr   r   r   s   `             @@r,   output_progressz*_lfs_log_progress.<locals>.output_progressI  s    /1	$	&8C= 	&0 ''..,>!?@$$&JJqM ''..,>!?@ bjj);<= 	7DY@D

=}mX #--/0xjAK)6)<)<S)A&M; #M 2!+.O99eX./D|  ( 1- #'%) #&m"4
,uh'( U""#4tL7I#IJ%6\";	7  Y #EdV!LMSXXYs   
E88	FFFr   r$   lfs_progresszFollowing progress in T)targetargsdaemon)loggergetEffectiveLevelr   ERROR	Exception	threadingEventrT   r   r   r   rU   rW   debugThreadstartr   )r   current_lfs_progress_valuetmpdir
exit_eventxs        r,   _lfs_log_progressr   ;  sM     !W]]2	 	J7	 J7X "$0BB!G		! HV)+fn)M

%&-bjj9K.L-MNO__&
O:-PTU			HNNFFH-GBJJ)*H He  		z NNFFH-GBJJ)*H HsX   &FE ?F,BFE	3F=	F	EFEF5F

FFFc                   Z   e Zd ZU dZee   ed<   e	 	 	 	 	 	 	 	 dAdee	e
f   dee	   dee	   deee	f   dee	   d	ee	   d
ee	   dedee   fd       Zede	fd       Zd ZedBde	deee	df   fd       ZdCdee	   d	ee	   fdZd Zde	fdZde	fdZde	fdZdee	   fdZdDdee	ee	   f   defdZdee	ee	   f   fdZd ZdEde	dee	   fdZdEde	dee	   fd ZdDd!ZdFd"ed#efd$ZdGde	d%efd&Z dHd'e	fd(Z!	 	 	 dId)ee	   d*ed+edee	e"e	ef   f   fd,Z#dDd
e	d-efd.Z$dBd/e	d0ee	   defd1Z%dBd/e	d0ee	   defd2Z&dCd/e	d3ee	   d0ee	   fd4Z'defd5Z(	 	 	 	 dJd'e	d*ed6ed+edede	e"e	ef   f   f
d7Z)e*	 	 	 	 dKd'e	d8ee	   d9ed*ed+ef
d:       Z+dee,   fd;Z-d<e,ddfd=Z.ed>        Z/ed?        Z0d@ Z1y)L
Repositoryz
    Helper class to wrap the git and git-lfs commands.

    The aim is to facilitate interacting with huggingface.co hosted model or
    dataset repos, though not a lot here (if any) is actually specific to
    huggingface.co.
    command_queueN	local_dir
clone_from	repo_typetokengit_user	git_emailrevisionskip_lfs_filesclientc
                    t        |t              rt        |      }t        j                  |d       t        j
                  j                  t        j                         |      | _        || _	        g | _
        || _        |	|	n	t               | _        | j                          t        |t              r|| _        n%|du rd| _        nt!        j"                         | _        || j%                  |       n6t'        | j                        rt(        j+                  d       nt-        d      | j                  7||3| j                  j/                  | j                        }
||
d   }||
d	   }||| j1                  ||       | j3                          | j5                          || j7                  |d
       t9        j:                  | j<                         y)a	  
        Instantiate a local clone of a git repo.

        If `clone_from` is set, the repo will be cloned from an existing remote repository.
        If the remote repo does not exist, a `EnvironmentError` exception will be thrown.
        Please create the remote repo first using [`create_repo`].

        `Repository` uses the local git credentials by default. If explicitly set, the `token`
        or the `git_user`/`git_email` pair will be used instead.

        Args:
            local_dir (`str` or `Path`):
                path (e.g. `'my_trained_model/'`) to the local directory, where
                the `Repository` will be initialized.
            clone_from (`str`, *optional*):
                Either a repository url or `repo_id`.
                Example:
                - `"https://huggingface.co/philschmid/playground-tests"`
                - `"philschmid/playground-tests"`
            repo_type (`str`, *optional*):
                To set when cloning a repo from a repo_id. Default is model.
            token (`bool` or `str`, *optional*):
                A valid authentication token (see https://huggingface.co/settings/token).
                If `None` or `True` and machine is logged in (through `huggingface-cli login`
                or [`~huggingface_hub.login`]), token will be retrieved from the cache.
                If `False`, token is not sent in the request header.
            git_user (`str`, *optional*):
                will override the `git config user.name` for committing and
                pushing files to the hub.
            git_email (`str`, *optional*):
                will override the `git config user.email` for committing and
                pushing files to the hub.
            revision (`str`, *optional*):
                Revision to checkout after initializing the repository. If the
                revision doesn't exist, a branch will be created with that
                revision name from the default branch's current HEAD.
            skip_lfs_files (`bool`, *optional*, defaults to `False`):
                whether to skip git-LFS files or not.
            client (`HfApi`, *optional*):
                Instance of [`HfApi`] to use when calling the HF Hub API. A new
                instance will be created if this is left to `None`.

        Raises:
            - [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
              if the remote repository set in `clone_from` does not exist.
        T)exist_okNF)repo_urlz [Repository] is a valid git repozNIf not specifying `clone_from`, you need to pass Repository a valid git clone.emailfullnamecreate_branch_ok)
isinstancer   rJ   rT   makedirsrU   rW   getcwdr   
_repo_typer   r   r   r   check_git_versionshuggingface_tokenr   	get_tokenr   r^   r   r   r   whoamigit_config_username_and_emaillfs_enable_largefilesgit_credential_helper_storegit_checkoutatexitregisterwait_for_commands)r+   r   r   r   r   r   r   r   r   r   users              r,   r-   zRepository.__init__  s   v i&II
I-biik9=#, & 2f!eS!49D"e^%)D" &.%7%7%9D"!OOZO04>>*?@ !qrr!!-93DHX;;%%d&<&<=D  M	
+9#8..xC""$((*h> 	../r.   r/   c                     	 t        d| j                        j                  j                         }|S # t        j
                  $ r}t        |j                        d}~ww xY w)zz
        Returns the current checked out branch.

        Returns:
            `str`: Current checked out branch.
        zgit rev-parse --abbrev-ref HEADNr   r   r=   rq   rK   rr   r   r9   )r+   r1   rz   s      r,   current_branchzRepository.current_branch   sU    	/#$Et~~V]]cceF  ,, 	/"3::..	/s   .2 AAAc                 V   	 t        d| j                        j                  j                         }	 t        d| j                        j                  j                         }t        j                  |dz   |z          y# t        $ r t        d      w xY w# t        $ r t        d      w xY w)z
        Checks that `git` and `git-lfs` can be run.

        Raises:
            - [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
              if `git` or `git-lfs` are not installed.
        zgit --versionz9Looks like you do not have git installed, please install.zgit-lfs --versionzLooks like you do not have git-lfs installed, please install. You can install from https://git-lfs.github.com/. Then run `git lfs install` (you only have to do this once).rm   N)r   r   r=   rq   FileNotFoundErrorr   r   info)r+   git_versionlfs_versions      r,   r  zRepository.check_git_versions/  s    	`($..IPPVVXK	()<dnnMTTZZ\K 	K$&45 ! 	`"#^__	`
 ! 	"O 	s   .A; .B ;BB(r   c                    t        |t              r|n|du rdn| j                  }||j                  d      rt	        d      | j
                  j                  }||v s!d|vrt        |j                  d            dk  rt        ||      \  }}}|| d| n|}||| _
        |dz   }| j                  t        v r|t        | j                     z  }|0t        |      j                  }|j                  | d	| d
| d      }||z  }t        j                   dd|      }		 t#        d| j$                         t        t'        j(                  | j$                              dk(  rt*        j-                  d|	 d       t/               5  t&        j0                  j3                         }
| j4                  r|
j7                  ddi       t#        | j4                  rdnd d| d| j$                  |
       ddd       yt9        | j$                        s&t;        d| j$                   d| j$                   d      t=        | j$                  |      r&t*        j-                  | j$                   d|	 d       yt#        d| j$                  d      }d |	 d!|	 d"}|j>                  dk(  r)t        j                   d#d$|j@                        }|d%| z  }t;        |      # 1 sw Y   yxY w# tB        jD                  $ r}t;        |jF                        d}~ww xY w)&a  
        Clone from a remote. If the folder already exists, will try to clone the
        repository within it.

        If this folder is a git repository with linked history, will try to
        update the repository.

        Args:
            repo_url (`str`):
                The URL from which to clone the repository
            token (`Union[str, bool]`, *optional*):
                Whether to use the authentication token. It can be:
                 - a string which is the token itself
                 - `False`, which would not use the authentication token
                 - `True`, which would fetch the authentication token from the
                   local folder and use it (you should be logged in for this to
                   work).
                - `None`, which would retrieve the value of
                  `self.huggingface_token`.

        <Tip>

        Raises the following error:

            - [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError)
              if an organization token (starts with "api_org") is passed. Use must use
              your own personal access token (see https://hf.co/settings/tokens).

            - [`EnvironmentError`](https://docs.python.org/3/library/exceptions.html#EnvironmentError)
              if you are trying to clone the repository in a non-empty folder, or if the
              `git` operations raise errors.

        </Tip>
        FNapi_orgzgYou must use your personal access token, not an Organization token (see https://hf.co/settings/tokens).httpr   r   )hub_urlz://z://user:@z(https?)://.*@z\1://zgit lfs installr   zCloning z into local empty directory.GIT_LFS_SKIP_SMUDGE1z	git clonezgit lfs clone z .)envzPTried to clone a repository in a non-empty folder that isn't a git repository ('z7'). If you really want to do this, do it manually:
 cd z && git init && git remote add origin && git pull origin main
 or clone repo to a new folder and move your existing files there afterwards.z is already a clone of z?. Make sure you pull the latest changes with `repo.git_pull()`.zgit remote get-url originr   zTried to clone zn in an unrelated git repository.
If you believe this is an error, please add a remote with the following URL: .ra   rb   z'
Local path has its origin defined as: )$r   rJ   r  
startswithr   r   endpointrt   rY   r   r   r   r   schemereplacerc   rd   r   r   rT   listdirr   warningr   r   copyr   r   r^   r   rg   r[   r=   rK   rr   r9   )r+   r   r   r  r   	namespace	repo_namerepo_idr!  clean_repo_urlr  output	error_msgclean_local_remote_urlrz   s                  r,   r   zRepository.clone_fromF  s6   L %%  E> ++ 	 !1!1)!<8 
 ++&&h6#9c(..QTBU>VZ[>[.I(\c.d+Iy)4=4I1YK0yG$"+}H"993DOODD !(+22#++vhcNvhhugUV<WXH  18XF5	/,dnn= 2::dnn-.!3.)99UVW&( **//+C**

$93#?@" +/*=*=;?SSTU]T^^`a   #4>>2*//3~~.> ?::>..9I J''  "$..(;NN>>**A.AQ R. . ,,G_deF *.)9 :==K<LAO 
 ((A-13
TZTaTa1b.!'OPfOg%hh	*955W Z ,, 	/"3::..	/sF   A$K A*K-K 6A6K -A$K KK K L
0LL
c                    	 |(t        dj                         |gz   | j                         |(t        d| j                         | j                         yy# t        j                  $ r}t        |j                        d}~ww xY w)a  
        Sets git username and email (only in the current repo).

        Args:
            git_user (`str`, *optional*):
                The username to register through `git`.
            git_email (`str`, *optional*):
                The email to register through `git`.
        Nzgit config user.namezgit config user.email )r   rY   r   rK   rr   r   r9   )r+   r   r   rz   s       r,   r  z(Repository.git_config_username_and_email  s{    	/#5;;=
JDNN[$!7	{CIIKT^^\ %,, 	/"3::..	/s   AA B*A??Bc                     	 t        d| j                         y# t        j                  $ r}t	        |j
                        d}~ww xY w)z;
        Sets the git credential helper to `store`
        z"git config credential.helper storeN)r   r   rK   rr   r   r9   )r+   rz   s     r,   r  z&Repository.git_credential_helper_store  s;    	/?P,, 	/"3::..	/s    AAAc                     	 t        d| j                        }|j                  j                         S # t        j
                  $ r}t        |j                        d}~ww xY w)zy
        Get commit sha on top of HEAD.

        Returns:
            `str`: The current checked out commit SHA.
        zgit rev-parse HEADNr  )r+   rx   rz   s      r,   git_head_hashzRepository.git_head_hash  sN    	/3T^^DA88>>##,, 	/"3::..	/s   /2 AAAc                     	 t        d| j                        }|j                  j                         }t	        j
                  dd|      S # t        j                  $ r}t        |j                        d}~ww xY w)zp
        Get URL to origin remote.

        Returns:
            `str`: The URL of the `origin` remote.
        z"git config --get remote.origin.urlra   rb   N)
r   r   r=   rq   rc   rd   rK   rr   r   r9   )r+   rx   urlrz   s       r,   git_remote_urlzRepository.git_remote_url  s`    	/CT^^TA((.."C66.*c::,, 	/"3::..	/s   AA	 	A6A11A6c                 |    | j                         }| j                         }|j                  d      r|dd }| d| S )z
        Get URL to last commit on HEAD. We assume it's been pushed, and the url
        scheme is the same one as for GitHub or HuggingFace.

        Returns:
            `str`: The URL to the current checked-out commit.
        r   Nr?   z/commit/)r0  r3  r   )r+   shar2  s      r,   git_head_commit_urlzRepository.git_head_commit_url  sH       "!!#<<cr(Chse$$r.   c                     	 t        d| j                        j                  j                         }t        |      dk(  rg S |j                  d      D cg c]  }|j                          }}|D cg c]  }d|j                         d   v s| }}|D cg c]#  }|j                         d   j                         % }}|S # t        j
                  $ r}t        |j                        d}~ww xY wc c}w c c}w c c}w )z
        Returns a list of the files that are deleted in the working directory or
        index.

        Returns:
            `List[str]`: A list of files that have been deleted in the working
            directory or index.
        zgit status -sNr   rm   Dr?   
r   r   r=   rq   rK   rr   r   r9   rt   rY   )r+   
git_statusrz   r5   modified_files_statusesdeleted_files_statusesdeleted_filess          r,   list_deleted_fileszRepository.list_deleted_files  s    	/'HOOUUWJ z?aI AK@P@PQU@V"Wf6<<>"W"W 8O!kVRUY_YeYeYghiYjRj&!k!k CYY+113YY- ,, 	/"3::..	/ #X "l Zs/   .C C10C6C6(C;C.C))C.patternsrh   c                     t        |t              r|g}	 |D ]"  }t        d|rdnd d| | j                         $ y# t        j
                  $ r}t        |j                        d}~ww xY w)a9  
        Tell git-lfs to track files according to a pattern.

        Setting the `filename` argument to `True` will treat the arguments as
        literal filenames, not as patterns. Any special glob characters in the
        filename will be escaped when writing to the `.gitattributes` file.

        Args:
            patterns (`Union[str, List[str]]`):
                The pattern, or list of patterns, to track with git-lfs.
            filename (`bool`, *optional*, defaults to `False`):
                Whether to use the patterns as literal filenames.
        zgit lfs track z
--filenamer$   r  N)r   rJ   r   r   rK   rr   r   r9   )r+   r?  rh   r   rz   s        r,   	lfs_trackzRepository.lfs_track/  st     h$ zH	/# $X\2$FayQNN
 ,, 	/"3::..	/s   '= A*A%%A*c                     t        |t              r|g}	 |D ]*  }t        dj                         |gz   | j                         , y# t
        j                  $ r}t        |j                        d}~ww xY w)z
        Tell git-lfs to untrack those files.

        Args:
            patterns (`Union[str, List[str]]`):
                The pattern, or list of patterns, to untrack with git-lfs.
        zgit lfs untrackN)	r   rJ   r   rY   r   rK   rr   r   r9   )r+   r?  r   rz   s       r,   lfs_untrackzRepository.lfs_untrackH  so     h$ zH	/# V0668G9DdnnUV,, 	/"3::..	/s   /A A2A--A2c                     	 d}t        | d| j                         t        | dt         | j                         y# t        j                  $ r}t        |j                        d}~ww xY w)zI
        HF-specific. This enables upload support of files >5GB.
        z'git config lfs.customtransfer.multipartz.path huggingface-cliz.args N)r   r   r   rK   rr   r   r9   )r+   
lfs_configrz   s      r,   r  z Repository.lfs_enable_largefilesX  sh    	/BJj\)>?P,f%A$BC ,, 	/"3::..	/s   := A*A%%A*r   c                    g }| j                         }t        || j                        D ]  }||v rt        j                  j                  t        j                         | j                  |      }t        |      rQt        |      r]t        j                  j                  |      dz  }|dk\  rt        j                  d       t        |      }|s| j                  |       |j                  |        | j                  |       |S )aH  
        Automatically track binary files with git-lfs.

        Args:
            pattern (`str`, *optional*, defaults to "."):
                The pattern with which to track files that are binary.

        Returns:
            `List[str]`: List of filenames that are now tracked due to being
            binary files
        rQ      r   zParsing a large file to check if binary or not. Tracking large files using `repository.auto_track_large_files` is recommended so as to not load the full file in memory.)r>  r   r   rT   rU   rW   r   r~   r   getsizer   r$  r   rA  appendrC  )r+   r   files_to_be_tracked_with_lfsr=  rh   path_to_file
size_in_mb	is_binarys           r,   auto_track_binary_filesz"Repository.auto_track_binary_filesf  s     (*$//1*74>>J 	BH=(77<<		T^^XNL'59UWW__\:kJ
#NNR +<8	NN8,077A)	B. 	'++r.   c                    g }| j                         }t        || j                        D ]  }||v rt        j                  j                  t        j                         | j                  |      }t        j                  j                  |      dz  }|dk\  smt        |      ryt        |      r| j                  |       |j                  |        | j                  |       |S )ap  
        Automatically track large files (files that weigh more than 10MBs) with
        git-lfs.

        Args:
            pattern (`str`, *optional*, defaults to "."):
                The pattern with which to track files that are above 10MBs.

        Returns:
            `List[str]`: List of filenames that are now tracked due to their
            size.
        rG  rH  r   )r>  r   r   rT   rU   rW   r   rI  r~   r   rA  rJ  rC  )r+   r   rK  r=  rh   rL  rM  s          r,   auto_track_large_filesz!Repository.auto_track_large_files  s     (*$//1*74>>J 		>H=(77<<		T^^XNL6+FJR(;L(IR`amRnx(,33H=		> 	'++r.   c                    	 t               5  t        d|rdnd | j                        }t        j	                  |j
                         ddd       y# 1 sw Y   yxY w# t        j                  $ r}t        |j                        d}~ww xY w)a  
        git lfs prune

        Args:
            recent (`bool`, *optional*, defaults to `False`):
                Whether to prune files even if they were referenced by recent
                commits. See the following
                [link](https://github.com/git-lfs/git-lfs/blob/f3d43f0428a84fc4f1e5405b76b5a73ec2437e65/docs/man/git-lfs-prune.1.ronn#recent-files)
                for more information.
        zgit lfs prune z--recentr$   N
r   r   r   r   r  r=   rK   rr   r   r9   )r+   recentr1   rz   s       r,   	lfs_prunezRepository.lfs_prune  sx    	/"$ +'.vSU8V(WY]YgYghFMM*+ + + ,, 	/"3::..	/s4   
A =A	A AA A B1BBrebasern   c                 (   |sdnd}|r|dz  }	 t               5  t        || j                        }t        j	                  |j
                         ddd       y# 1 sw Y   yxY w# t        j                  $ r}t        |j                        d}~ww xY w)a7  
        git pull

        Args:
            rebase (`bool`, *optional*, defaults to `False`):
                Whether to rebase the current branch on top of the upstream
                branch after fetching.
            lfs (`bool`, *optional*, defaults to `False`):
                Whether to fetch the LFS files too. This option only changes the
                behavior when a repository was cloned without fetching the LFS
                files; calling `repo.git_pull(lfs=True)` will then fetch the LFS
                file from the remote repository.
        zgit pullzgit lfs pullz	 --rebaseNrS  )r+   rV  rn   commandr1   rz   s         r,   git_pullzRepository.git_pull  s     %(*^{"G	/"$ +'@FMM*+ + + ,, 	/"3::..	/s4   
A$ 6AA$ A!A$ !A$ $B7BBauto_lfs_trackc                    |rL| j                  |      }|j                  | j                  |             |rt        j	                  d| d       	 t        dj                         |gz   | j                        }t        j                  d|j                   d       y# t        j                  $ r}t        |j                        d}~ww xY w)a7  
        git add

        Setting the `auto_lfs_track` parameter to `True` will automatically
        track files that are larger than 10MB with `git-lfs`.

        Args:
            pattern (`str`, *optional*, defaults to "."):
                The pattern with which to add files to staging.
            auto_lfs_track (`bool`, *optional*, defaults to `False`):
                Whether to automatically track large and binary files with
                git-lfs. Any file over 10MB in size, or in binary format, will
                be automatically tracked.
        z!Adding files tracked by Git LFS: z5. This may take a bit of time if the files are large.z
git add -vzAdding to index:
rm   N)rQ  extendrO  r   r$  r   rY   r   r  r=   rK   rr   r   r9   )r+   r   rZ  tracked_filesr1   rz   s         r,   git_addzRepository.git_add  s      77@M   !=!=g!FG7 G; ;
	/#L$6$6$8G9$DdnnUFKK,V]]O2>?,, 	/"3::..	/s   AB C	/CC	commit_messagec                 V   	 t        dj                         |gz   | j                        }t        j	                  d|j
                   d       y# t        j                  $ rG}t        |j                        dkD  rt        |j                        t        |j
                        d}~ww xY w)z
        git commit

        Args:
            commit_message (`str`, *optional*, defaults to "commit files to HF hub"):
                The message attributed to the commit.
        zgit commit -v -mzCommitted:
rm   r   N)r   rY   r   r   r  r=   rK   rr   rt   r9   r   )r+   r_  r1   rz   s       r,   
git_commitzRepository.git_commit  s    	3#$6$<$<$>.AQ$QSWSaSabFKK,v}}oR89,, 	33::"&szz22&szz22		3s   AA B(!AB##B(r   blockingauto_lfs_prunec                    d}|r|d| z  }t        | j                  |      }|dkD  r0t        j                  d| d       |rt        j                  d       	 t	               5  t        j                  |j                         t
        j                  t
        j                  d| j                        |rxj                         \  }}j                         }j                          t        |      rt        j                  |       |r#t        j                  |j                  ||	      d
d
d
       |sSfd}
t#        dfd|
|r| j$                  nd
      }| j&                  j)                  |       | j+                         |fS |r| j%                          | j+                         S # 1 sw Y   xY w# t
        j                  $ r}	t        |	j                         d
}	~	ww xY w)a%  
        git push

        If used without setting `blocking`, will return url to commit on remote
        repo. If used with `blocking=True`, will return a tuple containing the
        url to commit and the command object to follow for information about the
        process.

        Args:
            upstream (`str`, *optional*):
                Upstream to which this should push. If not specified, will push
                to the lastly defined upstream or to the default one (`origin
                main`).
            blocking (`bool`, *optional*, defaults to `True`):
                Whether the function should return only when the push has
                finished. Setting this to `False` will return an
                `CommandInProgress` object which has an `is_done` property. This
                property will be set to `True` when the push is finished.
            auto_lfs_prune (`bool`, *optional*, defaults to `False`):
                Whether to automatically prune files once they have been pushed
                to the remote.
        zgit pushz --set-upstream r   zSeveral commits (z) will be pushed upstream.z$The progress bars may be unreliable.zutf-8)r9   r=   encodingrS   )r*  r9   Nc                  .    j                         } | y| S )Nr?   poll)r5   r!   s    r,   r    z*Repository.git_push.<locals>.status_methodQ  s     >!Mr.   pushc                  (     j                         d uS rE   rg  )r!   s   r,   <lambda>z%Repository.git_push.<locals>.<lambda>Z  s    w||~T'A r.   )r   r    r!   r"   )r   r   r   r$  r   rK   rL   rY   rZ   communicaterh  killrt   rr   r   r   r9   r   rU  r   rJ  r6  )r+   r   rb  rc  rX  number_of_commitsr=   r9   return_coderz   r    command_in_progressr!   s               @r,   git_pushzRepository.git_push  s   8 )(44G+DNNHEq NN./@.AA[\]EF	/"$ u$**MMO%??%??$ %,%8%8%:NFF"),,.KLLN6{v."(;;K^dmstt%u. " #4A+.<DNN$# %%&9:++-/BBBNN''))_u u( ,, 	/"3::..	/s1   
F8 $C	F,-F8 ,F51F8 8G%G  G%r   c                 <   	 t        d| | j                        }t        j                  d| d| j                   d       t        j                  |j
                         y	# t        j                  $ r}|st        |j                        	 t        d| | j                        }t        j                  d| d| d       t        j                  |j
                         n0# t        j                  $ r}t        |j                        d	}~ww xY wY d	}~y	d	}~ww xY w)
a  
        git checkout a given revision

        Specifying `create_branch_ok` to `True` will create the branch to the
        given revision if that revision doesn't exist.

        Args:
            revision (`str`):
                The revision to checkout.
            create_branch_ok (`str`, *optional*, defaults to `False`):
                Whether creating a branch named with the `revision` passed at
                the current checked-out reference if `revision` isn't an
                existing revision is allowed.
        zgit checkout zChecked out z from r  zgit checkout -b z
Revision `z2` does not exist. Created and checked out branch `z`.N)
r   r   r   r$  r  r=   rK   rr   r   r9   )r+   r   r   r1   rz   s        r,   r  zRepository.git_checkouti  s    	7#mH:$>OFNN\(6$:M:M9NaPQNN6==),, 	7#&szz227+.>xj,I4>>ZFNN$XJ.`ai`jjlm NN6==1!44 7*3::667 2	7s=   AA! !D4DAC! D!D4D		DDDtag_namerf   c                    |r@	 t        d| | j                        j                  j                         }t        |      dk7  S 	 t        d| j                        j                  j                         }|j                  d      }||v S # t        j
                  $ r}t        |j                        d}~ww xY w# t        j
                  $ r}t        |j                        d}~ww xY w)aw  
        Check if a tag exists or not.

        Args:
            tag_name (`str`):
                The name of the tag to check.
            remote (`str`, *optional*):
                Whether to check if the tag exists on a remote. This parameter
                should be the identifier of the remote.

        Returns:
            `bool`: Whether the tag exists.
        zgit ls-remote origin refs/tags/Nr   zgit tagrm   r9  )r+   rs  rf   r1   rz   git_tagss         r,   
tag_existszRepository.tag_exists  s     3'*I((TVZVdVdellrrt v;!##3))T^^DKKQQS  ~~d+Hx'' 00 3&szz223 00 3&szz223s/   1B .B7 B4B//B47C$
CC$c                    d}d}| j                  |      sd}| j                  ||      sd}|r3	 t        ddd|g| j                        j                  j	                          |r8|r6	 t        d| d	| | j                        j                  j	                          yy# t
        j                  $ r}t        |j                        d}~ww xY w# t
        j                  $ r}t        |j                        d}~ww xY w)
a  
        Delete a tag, both local and remote, if it exists

        Args:
            tag_name (`str`):
                The tag name to delete.
            remote (`str`, *optional*):
                The remote on which to delete the tag.

        Returns:
             `bool`: `True` if deleted, `False` if the tag didn't exist.
                If remote is not passed, will just be updated locally
        TF)rf   gitr}   z-dN	git push z
 --delete )	rv  r   r   r=   rq   rK   rr   r   r9   )r+   rs  rf   delete_locallydelete_remotelyrz   s         r,   
delete_tagzRepository.delete_tag  s     x("Nx7#O3udH=t~~NUU[[] o36(*XJGX__eeg  00 3&szz223 00 3&szz223s/   2B '4C C
0CC
C: C55C:messagec                    |r	ddd|d|g}ndd|g}	 t        || j                        j                  j                          |r6	 t        d| d| | j                        j                  j                          yy# t        j
                  $ r}t        |j                        d}~ww xY w# t        j
                  $ r}t        |j                        d}~ww xY w)a[  
        Add a tag at the current head and push it

        If remote is None, will just be updated locally

        If no message is provided, the tag will be lightweight. if a message is
        provided, the tag will be annotated.

        Args:
            tag_name (`str`):
                The name of the tag to be added.
            message (`str`, *optional*):
                The message that accompanies the tag. The tag will turn into an
                annotated tag if a message is passed.
            remote (`str`, *optional*):
                The remote on which to add the tag.
        rx  r}   z-az-mNry  r  r  )r+   rs  r}  rf   tag_argsrz   s         r,   add_tagzRepository.add_tag  s    $ udHdGDHuh/H	/8T^^4;;AAC 36(!H:>OVV\\^  ,, 	/"3::..	/ 00 3&szz223s/   .A9 4B) 9B&B!!B&)C<CCc                     	 t        d| j                        j                  j                         }t        |      dk(  S # t        j
                  $ r}t        |j                        d}~ww xY w)z
        Return whether or not the git status is clean or not

        Returns:
            `bool`: `True` if the git status is clean, `False` otherwise.
        zgit status --porcelainNr   )	r   r   r=   rq   rK   rr   r   r9   rt   )r+   r:  rz   s      r,   is_repo_cleanzRepository.is_repo_clean  s_    	/'(@$..QXX^^`J :!## ,, 	/"3::..	/s   .> A+A&&A+clean_okc                     |r&| j                         rt        j                  d       y| j                  d       | j	                  |       | j                  d| j                   ||      S )aF  
        Helper to add, commit, and push files to remote repository on the
        HuggingFace Hub. Will automatically track large files (>10MB).

        Args:
            commit_message (`str`):
                Message to use for the commit.
            blocking (`bool`, *optional*, defaults to `True`):
                Whether the function should return only when the `git push` has
                finished.
            clean_ok (`bool`, *optional*, defaults to `True`):
                If True, this function will return None if the repo is
                untouched. Default behavior is to fail because the git command
                fails.
            auto_lfs_prune (`bool`, *optional*, defaults to `False`):
                Whether to automatically prune files once they have been pushed
                to the remote.
        z*Repo currently clean. Ignoring push_to_hubNTrZ  origin r   rb  rc  )r  r   r  r^  ra  rq  r  )r+   r_  rb  r  rc  s        r,   push_to_hubzRepository.push_to_hub  si    2 **,KKDED)'}}t2234)  
 	
r.   branchtrack_large_filesc              #     K   t        d| j                        }t        |      r;t        |      dkD  rt        |dd       dd dz   }t        j                  d d       || j                  |d	
       t        | j                        r(t        j                  d       | j                  d	       n#t        j                  d| j                   d       t        j                         }t        j                  t        j                  j                  || j                               	 |  | j!                  |       	 | j#                  |       	 | j'                  d| j                   ||       t        j                  |       y# t$        $ r}	dt        |	      vr|	Y d}	~	Ud}	~	ww xY w# t$        $ r }	dt        |	      v rt%        d      |	|	d}	~	ww xY w# | j!                  |       	 | j#                  |       n%# t$        $ r}	dt        |	      vr|	Y d}	~	nd}	~	ww xY w	 | j'                  d| j                   ||       n,# t$        $ r }	dt        |	      v rt%        d      |	|	d}	~	ww xY wt        j                  |       w xY ww)a  
        Context manager utility to handle committing to a repository. This
        automatically tracks large files (>10Mb) with git-lfs. Set the
        `track_large_files` argument to `False` if you wish to ignore that
        behavior.

        Args:
            commit_message (`str`):
                Message to use for the commit.
            branch (`str`, *optional*):
                The branch on which the commit will appear. This branch will be
                checked-out before any operation.
            track_large_files (`bool`, *optional*, defaults to `True`):
                Whether to automatically track large files or not. Will do so by
                default.
            blocking (`bool`, *optional*, defaults to `True`):
                Whether the function should return only when the `git push` has
                finished.
            auto_lfs_prune (`bool`, defaults to `True`):
                Whether to automatically prune files once they have been pushed
                to the remote.

        Examples:

        ```python
        >>> with Repository(
        ...     "text-files",
        ...     clone_from="<user>/text-files",
        ...     token=True,
        >>> ).commit("My first file :)"):
        ...     with open("file.txt", "w+") as f:
        ...         f.write(json.dumps({"hey": 8}))

        >>> import torch

        >>> model = torch.nn.Transformer()
        >>> with Repository(
        ...     "torch-model",
        ...     clone_from="<user>/torch-model",
        ...     token=True,
        >>> ).commit("My cool model :)"):
        ...     torch.save(model.state_dict(), "model.pt")
        ```

        r  rG     Nr?   z, ...]zPThere exists some updated files in the local repository that are not committed: z|. This may lead to errors if checking out a branch. These files and their modifications will be added to the current commit.Tr   zPulling changes ...)rV  z@The current branch has no upstream branch. Will push to 'origin 'r  znothing to commitr  r  zcould not read UsernamezCCouldn't authenticate user for push. Did you set `token` to `True`?)r   r   rt   rJ   r   r   r  r   r$  rY  r  rT   r   chdirrU   rW   r^  ra  rs   rq  )
r+   r_  r  r  rb  rc  files_to_stagefiles_in_msgcurrent_working_directoryes
             r,   commitzRepository.commit   sm    n ,CG~>"Q&">"1#56s;hFLL+n -## ft<t~~.NN01MMM&NN]^b^q^q]rrstu$&IIK!
7HI	0JLL(9L:/&t':':&;<%#1   HH./%  &c!f4G 5  ,A6!"ghnooG LL(9L:/ &c!f4G 5
&t':':&;<%#1  
  ,A6!"ghnooG HH./s   D$J'G +J>F !F, 1J	F)F$J$F))J,	G5GGJJ,G>=J>	H HJH  J$!IJ	I/I**I//JJc                     t         j                  j                  | j                  t              }t         j                  j                  |      rt        |      S y rE   )rT   rU   rW   r   r   isfiler   )r+   filepaths     r,   repocard_metadata_loadz!Repository.repocard_metadata_load  s8    77<<>77>>(# **r.   datac                 r    t        t        j                  j                  | j                  t
              |      S rE   )r   rT   rU   rW   r   r   )r+   r  s     r,   repocard_metadata_savez!Repository.repocard_metadata_save  s"    RWW\\$..-H$OOr.   c                 `    | j                   D cg c]  }|j                  dkD  s| c}S c c}w )z@
        Returns the asynchronous commands that failed.
        r   )r   r5   r+   cs     r,   commands_failedzRepository.commands_failed  s(    
  -->aA>>>s   ++c                 Z    | j                   D cg c]  }|j                  r| c}S c c}w )zS
        Returns the asynchronous commands that are currently in progress.
        )r   r2   r  s     r,   commands_in_progresszRepository.commands_in_progress  s$    
  --?aQYY???s   ((c                    d}| j                   D ][  }t        j                  d|j                   d|j                  j
                   d       t        j                  |j                         ] | j                  rS|dz  dk(  r#t        j                  d| j                   d       |dz  }t        j                  d       | j                  rRy	y	)
zr
        Blocking method: blocks all subsequent execution until all commands have
        been processed.
        r   zThe z command with PID z failed.r   zCWaiting for the following commands to finish before shutting down: r  r   N)r  r   r   r   r'   rC   r9   r  r$  r   r   )r+   indexcommand_faileds      r,   r  zRepository.wait_for_commands  s    
 "22 	0NLL4 4 455GH_H_HcHcGddlmnLL../	0 ''rzQYZ^ZsZsYttuv QJEJJqM ''r.   )NNTNNNFNrE   )NN)F)r  )FF)r  F)commit files to HF hub)NTF)r  TTF)NTTF)2rF   rG   rH   rI   r   r   r   r   r   rJ   r   r	   rN   r   r-   rM   r  r  r   r  r  r0  r3  r6  r>  rA  rC  r  rO  rQ  rU  rY  r^  ra  r
   rq  r  rv  r|  r  r  r  r   r  r   r  r  r  r  r  rP   r.   r,   r   r     s    )** %)#'"&"&#'"&$"&j0d#j0 SMj0 C=	j0
 T3Yj0 3-j0 C=j0 3-j0 j0 j0 j0X   6. }/3 }/uT3_/E }/ }/~/hsm /W_`cWd /&//s // /%S %!DI !F/%T#Y"7 /4 /2/E#tCy.$9 / /),s ),T#Y ),V,c ,DI ,B/$/t /$ /0 /s  /$  /D3 3& #'$	X*3-X* X* 	X*
 
sE#0011	2X*t7S 7D 7@(3 ( ( (<#3 # # #J 3  3hsm  3HUXM  3D$t $  7$"
"
 "
 	"

 "
 
tS%%6 677	8"
H  !%"&$h0h0 h0  	h0
 h0 h0 h0T P4 PD P ? ? @ @r.   r   )r  NrE   )9r	  rT   rc   rK   r   r   
contextlibr   pathlibr   typingr   r   r   r   r	   r
   r   r   urllib.parser   huggingface_hub.constantsr   r   huggingface_hub.repocardr   r   hf_apir   r   rn   r   utilsr   r   r   r   r   r   
get_loggerrF   r   r   rJ   rN   r^   rg   r~   r   r   r   r   rO   r   r   r   r   rP   r.   r,   <module>r     s    	 	    %  T T T ! L A 6 -  
		H	%P
 P
f8c4i( 8T 8"!5d+ ! ! !2"'%T	"2 "'t "'JU39- $ 2U39- $ . 5dD3I UYZ]U^ 2c4i 0 T ,+E#t), + +QT +,I  iH iHXL Lr.   