
    uj                     &    d dl Z d dlmZmZ ddZdS )    N)ThreadPoolExecutoras_completed   itemc           
          g }g }t          |          5  fd|D             }t          |          D ]{}|                                \  }}	}
|
r0|                    ||
f           t	          d| d| d|
            L|                    ||	f           t	          d| d| d|	            |	 ddd           n# 1 swxY w Y   t	          d	t          |           d
t          |           d           |rDt	          d| d           |D ]\  }}
t	          d| d|
            t          j        d           ||fS )a  Download multiple items concurrently with progress reporting.

    Args:
        download_fn: Callable that takes an item and returns
            (identifier, result_path, error_string_or_None).
        items: List of items to download.
        max_workers (int): Maximum concurrent workers.
        item_name (str): Display name for the item type.

    Returns:
        tuple: (succeeded_list, failed_list).
    )max_workersc                 >    i | ]}                     |          |S  )submit).0r   download_fnexecutors     d/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/modelscope/cli/utils.py
<dictcomp>z'concurrent_download.<locals>.<dictcomp>   s)    NNN8??;55tNNN    zFailed to download  z: zDownloaded z -> Nz
Download complete: z succeeded, z failedzFailed zs:z     )r   r   resultappendprintlensysexit)r   itemsr   	item_name	succeededfailedfuturesfuture
identifierresult_patherrorr   s   `          @r   concurrent_downloadr#      s    IF		4	4	4 	ONNNNNNNN"7++ 	O 	OF-3]]__*JU Oz51222MIMM
MMeMMNNNN  *k!:;;;MIMM
MMMMNNNN	O	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 
 "#i.. " "[[" " " # # # %	%%%&&&!' 	. 	.J,z,,U,,----fs   BB??CC)r   r   )r   concurrent.futuresr   r   r#   r
   r   r   <module>r%      sD    



 ? ? ? ? ? ? ? ?# # # # # #r   