feat: Capture solver log in SolverMetrics#23
Open
FBumann wants to merge 2 commits intofeature/solving-metricsfrom
Open
feat: Capture solver log in SolverMetrics#23FBumann wants to merge 2 commits intofeature/solving-metricsfrom
FBumann wants to merge 2 commits intofeature/solving-metricsfrom
Conversation
Store the solver log output as a string in Result.solver_log and Model.solver_log, making it programmatically accessible after solving. When no log_fn is provided, a temporary file is used to capture the log and cleaned up afterwards. When log_fn is provided, the file contents are read into solver_log as well. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Prevents potential NameError if NamedTemporaryFile creation fails or if the solver raises an exception. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
solver_log: str | Nonefield toSolverMetricsfor programmatic access to solver output after solvingModel.solve(), capture the solver log from a temp file (or user-providedlog_fn) and attach it to metricsPath.unlink(missing_ok=True))finallyso it's available even when the solver failsBlocked by
Changes proposed in this Pull Request
linopy/constants.py: Addsolver_logfield toSolverMetrics, with truncated display in__repr__linopy/model.py: Create temp log file whenlog_fnis not provided, read log intosolver_logon metrics after solvingtest/test_optimization.py: Addtest_solver_log_capturedandtest_solver_log_with_log_fntestsChecklist
doc.doc/release_notes.rstof the upcoming release is included.Test plan
test_solver_log_captured— verifiessolver_metrics.solver_logis non-empty after solve (all solver/io_api combos)test_solver_log_with_log_fn— verifies log capture whenlog_fnis explicitly providedtest_solver_metrics.pytests still pass🤖 Generated with Claude Code