Add log_stream API for logging binary streams as artifacts#19104
Add log_stream API for logging binary streams as artifacts#19104harupy merged 14 commits intomlflow:masterfrom
log_stream API for logging binary streams as artifacts#19104Conversation
ff8a089 to
e8f88a3
Compare
Resolves mlflow#19050 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
e8f88a3 to
ecb5ce4
Compare
|
Documentation preview for 52d92db is available at: More info
|
log_stream API for logging file-like objects as artifacts
Simplify log_stream to only support binary streams (IO[bytes]). This removes the text stream (IO[str]) handling which adds complexity without significant benefit since users can easily convert text to bytes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
log_stream API for logging file-like objects as artifactslog_stream API for logging binary streams as artifacts
| # TODO: The current implementation creates a temporary file. Consider adding | ||
| # a direct upload API to artifact repositories to avoid this overhead. |
There was a problem hiding this comment.
Other log-in-memory-object APIs (e.g., log_text) can benefit from this too.
|
/review ✅ Review completed. Review OutputNow I'll review the changes carefully against the Python style guide and general code quality standards. Let me analyze the PR changes: Style Guide Checklist:
Code Quality Review: Looking at the implementation, I found one issue:
However, after carefully reviewing all the added lines (marked with +), I don't see any style guide violations or significant code quality issues. The code:
No issues found. |
|
/resolve ✅ Workflow completed successfully. Claude OutputPerfect! I've successfully resolved all 3 unresolved PR review comments. Here's a summary of what was done: SummaryI successfully addressed all unresolved PR review comments for PR #19104: Changes Made:
Review Comments Resolved:
Commit Details:
The changes have been committed locally but not pushed to the remote repository, as per the instructions. The commit is ready for you to push when appropriate. |
Add @experimental(version="3.8.0") decorator to log_stream API in both MlflowClient and fluent API as requested in review comments. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new mlflow.log_stream() API that allows logging binary file-like objects (e.g., io.BytesIO) directly as artifacts without needing to create temporary files manually. This addresses issue #19050 by providing a convenient method for users who work with in-memory binary streams.
Key Changes:
- New
log_stream()API in both fluent (mlflow.log_stream) and client (MlflowClient().log_stream) interfaces - Chunked reading (8KB) to handle large streams efficiently without excessive memory usage
- Comprehensive test coverage including subdirectories, empty streams, and large content
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/tracking/test_tracking.py | Adds three test functions covering various scenarios: subdirectory handling, empty streams, and large content to verify chunked reading |
| mlflow/tracking/fluent.py | Implements the fluent API log_stream() function with proper documentation and type hints, following the same pattern as log_text() and log_dict() |
| mlflow/tracking/client.py | Implements the client API log_stream() method with chunked reading logic (8KB chunks) and comprehensive documentation |
| mlflow/init.py | Exports log_stream function in both the import statement and __all__ list for public API access |
| docs/api_reference/api_inventory.txt | Adds API documentation entries for both mlflow.log_stream and MlflowClient.log_stream |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/autoformat |
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
|
Will this land in next release? |
|
/resolve ✅ Workflow completed successfully. Claude OutputExcellent! I've successfully addressed both PR review comments: SummaryI resolved 2 unresolved PR review comments:
All changes have been committed locally with DCO sign-off. The commit passed all pre-commit checks including ruff, format, and other linters. The changes are ready but have not been pushed (as per instructions). |
🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
Signed-off-by: Harutaka Kawamura <hkawamura0130@gmail.com>
…19104) Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> Signed-off-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com> Signed-off-by: Harutaka Kawamura <hkawamura0130@gmail.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: mlflow-app[bot] <mlflow-app[bot]@users.noreply.github.com>
Related Issues/PRs
Resolves #19050
What changes are proposed in this pull request?
Add a new
mlflow.log_streamAPI that allows logging binary file-like objects (e.g.,io.BytesIO) directly as artifacts without needing to create temporary files manually.The API:
io.BufferedIOBase | io.RawIOBase)mlflow.log_stream) and client API (MlflowClient().log_stream)How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
Add
mlflow.log_streamAPI for logging binary file-like objects (e.g.,io.BytesIO) as artifacts without creating temporary files.What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingHow should the PR be classified in the release notes? Choose one:
rn/feature- A new user-facing feature worth mentioning in the release notesShould this PR be included in the next patch release?
🤖 Generated with Claude Code