Viewing File: /opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/__pycache__/ray.cpython-312.pyc

�

_�*j����ddlZddlZddlZddlZddlmZmZddlmZm	Z	m
Z
ddlmZddl
mZmZmZmZmZ	ddlZddlmZddlmZerdd	lmZdd
lmZmZddl
mZdd�Zdd
�Zdd�Zdd�Z Gd�de	�Z!y#e$r	ed��wxYw)�N)�OP�
SPANSTATUS)�DidNotEnable�Integration�_check_minimum_version)�TransactionSource)�event_from_exception�logger�package_version�qualname_from_function�reraise)�remotezRay not installed.)�
TYPE_CHECKING)�Callable)�Any�Optional)�ExcInfoc�t�tj�j�rytjd�y)Nz[[Tracing] Sentry not initialized in ray cluster worker, performance data will be discarded.)�
sentry_sdk�
get_client�	is_activer
�debug���J/opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/ray.py�_check_sentry_initializedr s)������(�(�*��
�L�L�e�rc��tj|�}t|jj	��}tj
dtj
jd��}|r<|djtj
jur|jd|�n|j|�|j|��|_y)N�_sentry_tracing)�kind�default���)�
parameters)
�inspect�	signature�listr"�values�	Parameter�KEYWORD_ONLYr�VAR_KEYWORD�insert�append�replace�
__signature__)�funcr$�params�sentry_tracing_params    r�#_insert_sentry_tracing_in_signaturer1)s����!�!�$�'�I�
�)�&�&�-�-�/�
0�F�"�,�,��
�
�
�
+�
+�����&��*�/�/�W�%6�%6�%B�%B�B��
�
�b�.�/��
�
�*�+�"�*�*�f�*�=�D�rc�v��t�tj��	d							d�fd�
�}|t_y)Nc�v�����tj��r��g���i���Sd����fd�}��|��S|S)Nc�*����tj��r��i�����Stj��dd�							d�fd��}t	|��r	�|�}n��i���|�}|j
�						d��fd�}||_|S)N)rc���t�tj|xsitjt��tjtj��}tj|�5}	�|i|��}|jtj�cddd�S#t$rI|jtj�t!j"�}t%|�t'|�Y�\wxYw#1swYyxYw)N)�op�name�origin�source)rr�continue_tracer�QUEUE_TASK_RAYr�RayIntegrationr8r�TASK�start_transaction�
set_statusr�OK�	Exception�INTERNAL_ERROR�sys�exc_info�_capture_exceptionr
)r�f_args�f_kwargs�transaction�resultrD�user_fs      �r�new_funczH_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>.new_funcSs����*�+�(�7�7�#�)�r��(�(�/��7�)�0�0�,�1�1��� �1�1�+�>�+�+�!'��!<�8�!<��#�.�.�z�}�}�=�"�?�>��%�+�#�.�.�z�/H�/H�I�#&�<�<�>��*�8�4���*�	+��	?�>�s1�2C;�4'B&�C;�&AC8�5C;�7C8�8C;�;Dc�&��tjtjt	�	�t
j��5}tj�j�D��cic]\}}||��
}}}	�|i|�d|i��}|jtj�cddd�Scc}}w#t$rI|jtj�tj�}t!|�t#|�Y�bwxYw#1swYyxYw)z,
                Ray Client
                )r6r7r8rN)r�
start_spanr�QUEUE_SUBMIT_RAYrr<r8�get_current_scope�iter_trace_propagation_headersr?rr@rArBrCrDrEr
)
�args�kwargs�span�k�v�tracingrIrD�old_remote_methodrJs
        ��r�&_remote_method_with_header_propagationzf_patch_ray_remote.<locals>.new_remote.<locals>.wrapper.<locals>._remote_method_with_header_propagationws���� �*�*��*�*�/��7�)�0�0���%/�$@�$@�$B�$a�$a�$c��$c�D�A�q��1��$c���	+�!2�!�"�%+�"�=D�"�����
�
�
�6�"�)���
��%�+����
�(A�(A�B�#&�<�<�>��*�8�4���*�	+����sB�&D�%
B,�2D�6+B2�!D�,D�2AD�D�D�D�D)rFrrzOptional[dict[str, Any]]rGr�returnr)rQrrRrrYr)r#�isclass�	functools�wrapsr1r)	rJrK�rvrXrWrQ�frR�
old_remotes	`   @����r�wrapperz6_patch_ray_remote.<locals>.new_remote.<locals>.wrapperKs�������v�&�
3�z�4�2�6�2�6�:�:�
�_�_�V�
$�?C�
"��
"�!;�
"�"�
"��	
"�%�
"�6
0��9����)��0�Z��0��0��:�� "�	�	��
"��
"�(-�
"��
"�8?�B�I��Ir)rJ�Callable[..., Any]rYr)r#rZ)r^rQrRr`r_s``` �r�
new_remotez%_patch_ray_remote.<locals>.new_remote@sK����?�?�1��
�a�1�$�1�&�1�1�J	�J	�X
�=��1�:���Nr)N)r^zOptional[Callable[..., Any]]rQrrRrrYra)rr[r\�ray)rbr_s @r�_patch_ray_remoterd=sV����J��_�_�Z� �,0�Y�)�Y�9>�Y�JO�Y�	�Y�!�Y�v�C�Jrc��tj�}t||jdtj
d���\}}tj||��y)NF)�handled�type)�client_options�	mechanism)�hint)rrr	�optionsr<�
identifier�
capture_event)rDrR�client�eventrjs     rrErE�sK��
�
"�
"�
$�F�&���~�~��"�-�-�
��K�E�4����U��.rc�,�eZdZdZde��Zedd��Zy)r<rczauto.queue.Nc�N�td�}tt|�t�y)Nrc)rrr<rd)�versions r�
setup_oncezRayIntegration.setup_once�s��!�%�(���~�w�7��r�rYN)�__name__�
__module__�__qualname__rlr8�staticmethodrsrrrr<r<�s%���J��:�,�
'�F����rr<rt)r.rarYN)rDrrRrrYN)"r[r#rCr�sentry_sdk.constsrr�sentry_sdk.integrationsrrr�sentry_sdk.tracingr�sentry_sdk.utilsr	r
rrr
rcr�ImportError�typingr�collections.abcrrrrrr1rdrEr<rrr�<module>r�s�����
��,�U�U�0���-���!��(�$�(��>�(_�D/�	�[�	��s�-�
�+�
,�,�-�s�
A:�:B
Back to Directory File Manager