
    uj                        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 d dl	m
Z
 d dlmZ d dlmZ  ee j                  Zej                            ej                            e                    Zd	 Z G d
 de          ZdS )    N)ArgumentParser)Optional)
CLICommand)scan_cache_dir)CacheNotFound)
get_logger)	log_levelc                      t          |           S )z> Function which will be called for a specific sub parser.
    )ScanCacheCMD)argss    h/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/modelscope/cli/scancache.pysubparser_funcr      s         c                   :    e Zd ZdZd Zedefd            Zd ZdS )r   z
scan-cachec                 ,    || _         |j        | _        d S )N)r   dir	cache_dir)selfr   s     r   __init__zScanCacheCMD.__init__   s    	(,r   parsersc                     |                      t          j                  }|                                }|                    dt
          dd           |                    t                     dS )z; define args for create pipeline template command.
        z--dirNzLcache directory to scan (optional). Default to the default ModelScope cache.)typedefaulthelp)func)
add_parserr   nameadd_mutually_exclusive_groupadd_argumentstrset_defaultsr   )r   parsergroups      r   define_argszScanCacheCMD.define_args   ss     ##L$5663355Z 	 	
 	
 	
 	00000r   c           	      X   	 t          j                     }t          | j                  }t          j                     }n1# t          $ r$}|j        }t	          d|            Y d }~d S d }~ww xY wt	          |                                           t	          dt          ||z
  d           dt          |j                   d|j	         d           t          |j
                  dk    r@dt          |j
                   d	}t	          |           |j
        D ]}t	          |           d S d S )
NzCache directory not found: z	
Done in    zs. Scanned z repo(s) for a total of .r   zGot z warning(s) while scanning.)timer   r   r   printexport_as_tableroundlenrepossize_on_disk_strwarnings)r   t0
cache_infot1excr   messagewarnings           r   executezScanCacheCMD.execute/   s`   	B'77JBB 	 	 	I;	;;<<<FFFFF	 	j((**+++>rBw** > >s:;K7L7L > >):> > >	? 	? 	? z"##a''RS!455RRRG'NNN%.  g	 (' s   := 
A+A&&A+N)	__name__
__module____qualname__r   r   staticmethodr   r$   r6    r   r   r   r      s^        D1 1 1 1^ 1 1 1 \1    r   r   )loggingosr(   argparser   typingr   modelscope.cli.baser   modelscope.hub.cache_managerr   modelscope.hub.errorsr   modelscope.utils.loggerr   WARNINGloggerpathdirnameabspath__file__current_pathr   r   r;   r   r   <module>rK      s    				  # # # # # #       * * * * * * 7 7 7 7 7 7 / / / / / / . . . . . .	go	.	.	.wrwx8899  ( ( ( ( (: ( ( ( ( (r   