
    Ki	                    \    d Z ddlmZ ddlmZ ddlmZmZ erddlm	Z	  G d d	ed	         Z
y
)zProgress reporting dependency.    )annotations)TYPE_CHECKING   )
Dependencycurrent_execution   )ExecutionProgressc                  p    e Zd ZdZddZddZedd       Zedd       Zedd       Z	ddZ
dddZdd	Zy
)Progressa9  A dependency to report progress updates for the currently executing task.

    Tasks can use this to report their current progress (current/total values) and
    status messages to external observers.

    Example:

    ```python
    @task
    async def process_records(records: list, progress: Progress = Progress()) -> None:
        await progress.set_total(len(records))
        for i, record in enumerate(records):
            await process(record)
            await progress.increment()
            await progress.set_message(f"Processed {record.id}")
    ```
    c                    d | _         y N)	_progressselfs    i/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/docket/dependencies/_progress.py__init__zProgress.__init__    s	    37    c                X   K   t        j                         }|j                  | _        | S wr   )r   getprogressr   )r   	executions     r   
__aenter__zProgress.__aenter__#   s&     %))+	"++s   (*c                T    | j                   J d       | j                   j                  S )zCurrent progress value.%Progress must be used as a dependency)r   currentr   s    r   r   zProgress.current(   *     ~~)R+RR)~~%%%r   c                T    | j                   J d       | j                   j                  S )z)Total/target value for progress tracking.r   )r   totalr   s    r   r   zProgress.total.   s*     ~~)R+RR)~~###r   c                T    | j                   J d       | j                   j                  S )zUser-provided status message.r   )r   messager   s    r   r    zProgress.message4   r   r   c                |   K   | j                   J d       | j                   j                  |       d{    y7 w)z1Set the total/target value for progress tracking.Nr   )r   	set_total)r   r   s     r   r"   zProgress.set_total:   s4     ~~)R+RR)nn&&u---   2<:<c                |   K   | j                   J d       | j                   j                  |       d{    y7 w)z0Atomically increment the current progress value.Nr   )r   	increment)r   amounts     r   r%   zProgress.increment?   s4     ~~)R+RR)nn&&v...r#   c                |   K   | j                   J d       | j                   j                  |       d{    y7 w)z#Update the progress status message.Nr   )r   set_message)r   r    s     r   r(   zProgress.set_messageD   s4     ~~)R+RR)nn((111r#   N)returnNone)r)   r   )r)   z
int | None)r)   int)r)   
str | None)r   r+   r)   r*   )r   )r&   r+   r)   r*   )r    r,   r)   r*   )__name__
__module____qualname____doc__r   r   propertyr   r   r    r"   r%   r(    r   r   r   r      s\    $8
 & &
 $ $
 & &
.
/
2r   r   N)r0   
__future__r   typingr   _baser   r   r   r	   r   r2   r   r   <module>r6      s(    $ "   0-:2z*% :2r   