-
[OPIK-3909] [P SDK] Add support for File-like objects when creating an Attachment (#4973)
发布于
2026-01-29 16:25:42 +00:00 - [OPIK-3909] Add support for handling raw bytes in attachments and improve MIME type inference.
- Enhanced
Attachmentclass to support raw byte data. - Added logic in
converters.attachment_to_messageto handle bytes, create temporary files, and inferapplication/octet-streamMIME 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_fileto raiseOSErrorinstead of returningNoneto ensure error propagation. - Refactored the
attachment_to_messagelogic to handle and test the raised error effectively. - Adjusted related unit tests to validate the updated behavior with
pytest.raises.
-
[OPIK-3909] Ensure
temp_fileis properly closed in_write_file_like_to_temp_fileusingfinallyblock. -
[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_datafor 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.
下载附件