o
    -wi                     @  s  U d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
 ddlmZmZmZ ddlmZmZmZmZ ddlmZmZmZmZmZmZmZmZ dd	lmZmZm Z m!Z!m"Z" dd
l#m$Z$m%Z% G dd deZ&G dd deZ'G dd deddZ(G dd deddZ)G dd deZ*G dd deZ+G dd deddZ,eee'e*e+e,f e	e!e
ddf Z-ee-j.Z/de0d < G d!d" d"eZ1G d#d$ d$e1eZ2G d%d& d&e1eZ3G d'd( d(e1eddZ4eee2e3e4f e	e e
d)df Z5ee5j.Z6de0d*< dgd+d, e6D Z7d-S ).z.Actions that are triggered by W&B Automations.    )annotations)AnyLiteralOptionalUnion)BeforeValidatorField)	AnnotatedSelfget_args)GQLBaseGQLIdSerializedToJsonTypename   )AlertSeverityGenericWebhookActionFieldsGenericWebhookActionInputNoOpActionFieldsNoOpTriggeredActionInputNotificationActionFieldsNotificationActionInputQueueJobActionFields)LenientStrEnumdefault_if_noneto_input_actionto_saved_actionupper_if_str)SlackIntegrationWebhookIntegrationc                   @  s    e Zd ZdZdZdZdZdZdS )
ActionTypez.The type of action triggered by an automation.	QUEUE_JOBNOTIFICATIONGENERIC_WEBHOOKNO_OPN)__name__
__module____qualname____doc__r!   r"   r#   r$    r)   r)   V/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/wandb/automations/actions.pyr    !   s    r    c                   @  s   e Zd ZU ejZded< dS )SavedLaunchJobActionzLiteral[ActionType.QUEUE_JOB]action_typeN)r%   r&   r'   r    r!   r,   __annotations__r)   r)   r)   r*   r+   1   s   
 r+   c                   @  "   e Zd ZU dZded< ded< dS )_SavedActionSlackIntegrationr   z%Typename[Literal['SlackIntegration']]
typename__r   idNr%   r&   r'   r0   r-   r)   r)   r)   r*   r/   ?   s   
 r/   allow)extrac                   @  r.   )_SavedActionWebhookIntegrationGenericWebhookIntegrationz.Typename[Literal['GenericWebhookIntegration']]r0   r   r1   Nr2   r)   r)   r)   r*   r5   D   s   
 
r5   c                   @  s$   e Zd ZU ejZded< ded< dS )SavedNotificationAction Literal[ActionType.NOTIFICATION]r,   r/   integrationN)r%   r&   r'   r    r"   r,   r-   r)   r)   r)   r*   r7   K   s   
 r7   c                   @  s0   e Zd ZU ejZded< ded< dZded< dS )SavedWebhookAction#Literal[ActionType.GENERIC_WEBHOOK]r,   r5   r9   NzTAnnotated[Optional[SerializedToJson[dict[str, Any]]], Field(alias='requestPayload')]request_payload)r%   r&   r'   r    r#   r,   r-   r<   r)   r)   r)   r*   r:   P   s
   
 r:   c                   @  s(   e Zd ZU ejZded< dZded< dS )SavedNoOpActionLiteral[ActionType.NO_OP]r,   T1Annotated[bool, BeforeValidator(default_if_none)]no_opN)r%   r&   r'   r    r$   r,   r-   r@   r)   r)   r)   r*   r=   ]   s   
 r=   T)frozenr0   )discriminatorztuple[type, ...]SavedActionTypesc                   @  s   e Zd ZU ded< dS )_BaseActionInputz)Annotated[ActionType, Field(frozen=True)]r,   N)r%   r&   r'   r-   r)   r)   r)   r*   rD   x   s   
 rD   c                   @  sp   e Zd ZU dZejZded< ded< 	 dZded< 	 dZ	d	ed
< 	 e
jZded< 	 edde
jddddZdS )SendNotificationz?Defines an automation action that sends a (Slack) notification.r8   r,   r   integration_id strtitlez.Annotated[str, Field(validation_alias='text')]messagezXAnnotated[AlertSeverity, BeforeValidator(upper_if_str), Field(validation_alias='level')]severity)rI   textlevelr9   r   rL   rM   r   returnr
   c                C  s   | |j |||dS )zIDefine a notification action that sends to the given (Slack) integration.)rF   rI   rJ   rK   r1   )clsr9   rI   rL   rM   r)   r)   r*   from_integration   s   
z!SendNotification.from_integrationN)
r9   r   rI   rH   rL   rH   rM   r   rN   r
   )r%   r&   r'   r(   r    r"   r,   r-   rI   rJ   r   INFOrK   classmethodrQ   r)   r)   r)   r*   rE   }   s"   
 
rE   c                   @  sT   e Zd ZU dZejZded< ded< 	 edddZ	d	ed
< 	 e
dddddZdS )SendWebhookz:Defines an automation action that sends a webhook request.r;   r,   r   rF   NrequestPayload)defaultalias*Optional[SerializedToJson[dict[str, Any]]]r<   )payloadr9   r   rY   rN   r
   c                C  s   | |j |dS )zFDefine a webhook action that sends to the given (webhook) integration.)rF   r<   rO   )rP   r9   rY   r)   r)   r*   rQ      s   zSendWebhook.from_integration)r9   r   rY   rX   rN   r
   )r%   r&   r'   r(   r    r#   r,   r-   r   r<   rS   rQ   r)   r)   r)   r*   rT      s   
 rT   c                   @  s,   e Zd ZU dZejZded< dZded< dS )	DoNothingz=Defines an automation action that intentionally does nothing.r>   r,   Tr?   r@   N)	r%   r&   r'   r(   r    r$   r,   r-   r@   r)   r)   r)   r*   rZ      s
   
 rZ   r,   InputActionTypesc                 c  s    | ]}|j V  qd S )N)r%   ).0rP   r)   r)   r*   	<genexpr>   s    r]   N)8r(   
__future__r   typingr   r   r   r   pydanticr   r   typing_extensionsr	   r
   r   wandb._pydanticr   r   r   r   
_generatedr   r   r   r   r   r   r   r   _validatorsr   r   r   r   r   integrationsr   r   r    r+   r/   r5   r7   r:   r=   SavedAction
__origin__rC   r-   rD   rE   rT   rZ   InputActionr[   __all__r)   r)   r)   r*   <module>   sb    (
(
