发布

  • [OPIK-3909] [P SDK] Add support for File-like objects when creating an Attachment (#4973)

    frostbyte_neo 发布于 2026-01-29 16:25:42 +00:00

    • [OPIK-3909] Add support for handling raw bytes in attachments and improve MIME type inference.
    • Enhanced Attachment class to support raw byte data.
    • Added logic in converters.attachment_to_message to handle bytes, create temporary files, and infer application/octet-stream MIME type by default.
    • Introduced new unit tests for various scenarios involving byte-based attachments, including MIME type inference, temporary file cleanup, and error handling.
    • [OPIK-3909] Improve error handling for temporary file creation in attachment converters
    • Updated _write_file_like_to_temp_file to raise OSError instead of returning None to ensure error propagation.
    • Refactored the attachment_to_message logic to handle and test the raised error effectively.
    • Adjusted related unit tests to validate the updated behavior with pytest.raises.
    • [OPIK-3909] Ensure temp_file is properly closed in _write_file_like_to_temp_file using finally block.

    • [OPIK-3909] Add docstring for _write_file_like_to_temp_file

    • Documented the function to describe behavior, arguments, and returned value.
    • [OPIK-4051] Add E2E test for validating span attachment upload and verification logic

    • [OPIK-3909] Add docstring to test_opik_client_span__attachment_with_file_like_data for improved clarity on span creation with file-like data.

    • [OPIK-3909] Update tracing documentation to include examples for file path, raw bytes, and generated content attachments.

    下载附件