
    -j               
       \    d Z ddlZddlmZmZmZ 	 	 ddee         deded	ee         fd
ZdS )zAsync utils.    N)Any	CoroutineListFRunning async taskstasksshow_progressprogress_bar_descreturnc                   	 | 	 t          j                    }	 ddl}|                                 n# t          $ r t          d          w xY wn## t
          $ r t          j                    }Y nw xY w|r!ddlm	 dt          t                   f	fd}ndt          t                   ffd}	 |                     |                      }n## t          $ r}t          d|          |d}~ww xY w|S )	zRun a list of async tasks.r   Nzinest_asyncio is required to run async tasks in jupyter. Please install it via `pip install nest_asyncio`.)tqdmr
   c                  .   K    j         d i d{V S )z"gather tasks and show progress bardescN)gather)r	   tasks_to_executer   s   [/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/ragas/async_utils.py_gatherz run_async_tasks.<locals>._gather    s2      $&6O=NOOOOOOOOO    c                  0   K   t          j           d {V S )N)asyncior   )r   s   r   r   z run_async_tasks.<locals>._gather&   s'       )9::::::::r   z/Fatal error occurred while running async tasks.)r   get_running_loopnest_asyncioapplyImportErrorRuntimeErrornew_event_looptqdm.asyncior   r   r   run_until_complete	Exception)
r   r   r	   loopr   r   outputser   r   s
     `     @@r   run_async_tasksr"      s    #(('))	!       	 	 	{  	
 ! ( ( (%''(  
;%%%%%%	PtCy 	P 	P 	P 	P 	P 	P 	P 	P 	P	;tCy 	; 	; 	; 	; 	; 	;X!44WWYY?? X X X LaPPVWW	X
 Ns=   A 4 A AA A21A21C 
C/C**C/)Fr   )	__doc__r   typingr   r   r   boolstrr"    r   r   <module>r(      s       ' ' ' ' ' ' ' ' ' '
  2* *	?** * 
#Y	* * * * * *r   