o
    -wi                     @   sX   d dl Z d dlmZmZ d dlmZmZ edZdejde	deg ef defd	d
Z
dS )    N)CallableTypeVar)asyncio_compatprinter_Tspinner_printertextfuncreturnc                    s    dt f fdd}t|S )a  Run a slow function while displaying a loading icon.

    Args:
        spinner_printer: The printer to use to display text.
        text: The text to display next to the spinner while the function runs.
        func: The function to run.

    Returns:
        The result of func.
    r
   c               	      s   t   d fdd} t 4 I d H "}||   t  d I d H }   |W  d   I d H  S 1 I d H s>w   Y  d S )Nr
   c                     s   d}   <}|r.  s-| }|| d  | d7 } tdI d H    rn W d    d S W d    d S 1 sFw   Y  d S )Nr       g?)dynamic_textis_setloading_symbolset_textasynciosleepdisplay)tick	text_areaspinner)func_runningr   r    Z/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/wandb/sdk/lib/printer_asyncio.pyupdate_spinner   s   

" zNrun_async_with_spinner.<locals>._loop_run_with_spinner.<locals>.update_spinner)r
   N)r   Eventr   open_task_group
start_soonget_running_looprun_in_executorset)r   groupresr	   r   r   )r   r   _loop_run_with_spinner   s   0z6run_async_with_spinner.<locals>._loop_run_with_spinner)r   r   run)r   r   r	   r$   r   r#   r   run_async_with_spinner	   s   
r&   )r   typingr   r   wandb.sdk.libr   r   r   Printerstrr&   r   r   r   r   <module>   s    
