Repository navigation
Enhance logging throughout the package for improved debugging and logging - #311
Merged
nikhil-sarin merged 16 commits intoJan 31, 2026
Merged
Conversation
…itoring Added comprehensive logging to improve observability and debugging across the codebase: Core modules: - result.py: Added logging for file I/O operations, transient reconstruction, and error handling - model_library.py: Added logging during model dictionary construction and module loading - sed.py: Added error logging for bandpass wavelength range mismatches and validation failures - constraints.py: Added warning logs for physical constraint violations (energy, distance, timing) Data retrieval modules: - batse.py: Added logging for data downloads, FITS conversions, and trigger number lookups - directory.py: Added logging for directory structure creation and validation - utils.py: Added logging for GRB trigger number lookups with error handling Transient classes: - kilonova.py, supernova.py, tde.py: Added initialization and directory setup logging - prompt.py: Added extensive logging for BATSE data loading, channel selection, and instrument validation Logging improvements include: - INFO level: Successful operations, initialization, data retrieval confirmations - DEBUG level: Detailed operation steps, intermediate values, reconstruction details - WARNING level: Constraint violations, fallback behaviors - ERROR level: Failed operations, validation errors, missing data before exceptions All modified files pass syntax validation.
Add common test-generated data directories to prevent accidental commits: - GRBData/ - supernova/ - kilonova/ - tidal_disruption_event/ - spectrum/ These directories are created during test runs when data is downloaded or simulated, and should not be tracked in version control.
Constraint functions are called with array inputs during bilby prior sampling, causing TypeError when trying to format arrays with f-string format specifiers. Removed verbose logging from these hot-path functions to fix test failures and avoid excessive log output during sampling.
Added extensive unit tests to cover the new logging functionality: result_test.py: - Tests for read_in_result with various file formats (JSON, HDF5, pickle, gzip) - Error cases: file not found, invalid extension, missing extension - Transient reconstruction success and failure paths - Plotting with stored model selection transient_test.py: - TestKilonovaTransient: Initialization with logging validation - TestSupernovaTransient: Initialization with logging validation - TestTDETransient: Initialization with logging validation - TestPromptTimeSeriesTransient: BATSE/Swift initialization, invalid instrument error handling, data loading get_data_test.py: - TestUtilsLogging: Trigger number lookup errors, BATSE trigger lookup - TestBATSEDataGetterLogging: Data collection success/failure, CSV conversion - TestDirectoryLogging: Invalid bin size error, spectrum directory creation utils_test.py: - TestSEDErrorHandling: Zero-point system validation, wavelength range mismatch errors These tests exercise: - INFO level logging for successful operations - ERROR level logging before exceptions - DEBUG level logging for detailed operations - WARNING level logging for constraint violations - All error handling code paths with proper logging
The tests were failing because batse_prompt_directory_structure internally calls get_batse_trigger_from_grb when no trigger is provided. Added mock for get_batse_trigger_from_grb to prevent actual trigger table lookups during tests.
Patch functions where they are imported (redback.transient.prompt) rather than where they are defined. Also mock _set_data to avoid event table lookups.
…d code - Add tests for plot_spectrum, plot_residual, plot_multiband_lightcurve, plot_data, and plot_multiband methods - Add tests for edge cases in read_in_result (no extension, unsupported type) - Remove unreachable code path for None extension (os.path.splitext always returns string) - Achieves 100% test coverage for result.py
Separate entries that were incorrectly concatenated without newlines.
…JF3e3 Resolved conflicts prioritizing master's changes: - .gitignore: Use master's comprehensive coverage ignores - test/result_test.py: Use master's comprehensive test suite - test/transient_test.py: Use master's base, append logging tests - test/get_data_test.py: Append logging tests to master's version - test/utils_test.py: Append SED error handling tests to master's version Retained all logging-related test classes: - TestKilonovaTransient, TestSupernovaTransient, TestTDETransient - TestPromptTimeSeriesTransient with proper mock patching - TestBATSEDataGetterLogging, TestDirectoryLogging, TestUtilsLogging - TestSEDErrorHandling
nikhil-sarin
force-pushed
the
claude/improve-logging-011CUyArWBWkX7cyfVNJF3e3
branch
from
November 21, 2025 15:34
82c6de6 to
0fe017c
Compare
Master's tests were failing because logging code checks file existence. Add mock for os.path.exists(return_value=True) to all read tests. Add label and model attributes to all mock RedbackResult objects to support the success logging message.
…JF3e3 # Conflicts: # redback/model_library.py
nikhil-sarin
marked this pull request as ready for review
January 31, 2026 22:58
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.
Added comprehensive logging to improve observability and debugging across the codebase:
Core modules:
Data retrieval modules:
Transient classes:
Logging improvements include:
All modified files pass syntax validation.