o
    )j                     @   s&   d dl Z d dlmZmZ dddZdS )    N)ThreadPoolExecutoras_completed   itemc              	      s  g }g }t |dK fdd|D }t|D ]4}| \}}	}
|
r8|||
f td| d| d|
  q|||	f td| d| d|	  qW d	   n1 sWw   Y  td
t| dt| d |rtd| d |D ]\}}
td| d|
  qwt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                    s   i | ]	}  ||qS  )Zsubmit).0r   download_fnexecutorr   U/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/modelscope/cli/utils.py
<dictcomp>   s    z'concurrent_download.<locals>.<dictcomp>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   Z	item_nameZ	succeededfailedZfuturesfuture
identifierresult_patherrorr   r	   r   concurrent_download   s,   

r   )r   r   )r   concurrent.futuresr   r   r   r   r   r   r   <module>   s   