Capture and add warnings separately in AnalyticResult from standard error in analytic results#110
Conversation
…rror in analytic results
There was a problem hiding this comment.
Pull request overview
This PR updates the data function execution pipeline so Python warnings are captured and surfaced separately from standard error in AnalyticResult, aligning with the goal of not mixing warning output into stderr.
Changes:
- Added warning capture during script execution (
warnings.catch_warnings(record=True)), plusAnalyticResult.has_warningsandAnalyticResult.warnings. - Updated summary formatting to emit a dedicated
Warnings:section. - Expanded/updated tests and golden outputs to validate warnings vs. stderr separation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
spotfire/data_function.py |
Captures warnings during script execution, stores them on AnalyticResult, and prints them under a new Warnings: section in the summary. |
spotfire/test/test_data_function.py |
Extends test harness to assert has_warnings/has_stderr and adds new warnings-related test cases. |
spotfire/test/files/data_function/warning_pysrv79.txt |
Updates golden output header from Standard error: to Warnings:. |
spotfire/test/files/data_function/table_metadata.txt |
Updates golden output header from Standard error: to Warnings: for pandas metadata warning case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| buf.write("\nStandard error:\n") | ||
| buf.write(result.std_err_out) | ||
| if result.has_warnings: | ||
| buf.write("\nWarnings:\n") |
There was a problem hiding this comment.
Do we need more stronger protocol identification ? If I print warnings in the log/print(Warnings:) will it create problem ?
There was a problem hiding this comment.
This is added to show warnings at client when enable debug logging for data function, along with other debug logs warning also get displayed. Python service or client glue code will retrieve warnings from AnalyticResult.warnings (field in AnalyticResult class)
We may remove this "Warnings:" from debug logging once client starts showing warnings for python data functions.
Previously, warnings were written to the standard error stream. A new warnings field has now been added to AnalyticResult so that warnings can be returned separately instead of being mixed with standard error output.