-
Notifications
You must be signed in to change notification settings - Fork 3
Add examples for caching stdout/stderr and log output #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: dahong67 <[email protected]>
Co-authored-by: dahong67 <[email protected]>
dahong67
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot let's try to avoid using temporary files to accomplish this. For stdout and stderr, let's suggest using IOCapture.jl. For the logs, let's suggest using a SimpleLogger with an IOBuffer (if that works).
Note that redirecting stdio to an IOBuffer seems to not yet be supported: JuliaLang/julia#12711
Let's also mention the following alternatives (if they work - please check):
- using Suppressor.jl instead of IOCapture.jl
- using Logging2.jl to redirect to an IOBuffer-backed SimpleLogger
- using the file-based approach already in this PR
Other relevant refs:
…ring Co-authored-by: dahong67 <[email protected]>
Updated the example to use IOCapture.jl for capturing stdout/stderr (avoiding temporary files) and SimpleLogger with IOBuffer for logs. The file-based approach with Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: dahong67 <[email protected]>
dahong67
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this is looking great! Let's split this into two examples:
- one that saves what was printed to stdout/stderr
- one that saves things from the logging system
Co-authored-by: dahong67 <[email protected]>
Split into two separate examples as requested. The first example shows caching stdout/stderr output using IOCapture.jl, and the second example shows caching log messages using SimpleLogger with IOBuffer. Both include alternative file-based approaches. Changes in commit 129f84f. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
cd("/home/REDACTED/work/CacheVariables.jl/CacheVariables.jl/test")
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #30 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 57 57
=========================================
Hits 57 57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good now, let's merge!
Issue #21 requests examples showing how to cache printed output and logs alongside computation results.
Changes
Added two separate, focused examples to the README demonstrating output capture:
Example 1: Caching printed output (stdout/stderr)
Primary Approach (IOCapture.jl)
IOCapture.jlto capture stdout/stderr without temporary filesAlternative Approach (File-based)
redirect_stdioto capture stdout/stderr to temporary filesmktempdirfor automatic cleanup of temporary filesExample 2: Caching log messages
Primary Approach (IOBuffer)
Logging.SimpleLoggerwithIOBufferto capture structured logs (@info, @warn, etc.)Alternative Approach (File-based)
SimpleLoggerwith file I/O for loggingmktempdirfor automatic cleanupExample (stdout/stderr)
Example (logging)
Subsequent runs load both the computation result and all captured output from cache. Both examples include alternative file-based approaches for users who prefer them or need more control.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.