Skip to content

Conversation

@mikebranc
Copy link
Contributor

@mikebranc mikebranc commented Dec 19, 2025

User description

Shortcut:

Description:
All SDK errors are caught by catch_log.py which takes the logs and logs them to a specific catch_log logger which required the developer to configure their code like this if they wanted to see logs:

import logging

# Get the exact logger that catch_log.py uses
galileo_logger = logging.getLogger('galileo.utils.catch_log')
galileo_logger.setLevel(logging.WARNING)
galileo_logger.addHandler(logging.StreamHandler())

There is little documentation on this, just this sdk method which isn't super helpful

This PR makes errors nosier by having them logged with warnings.warn() as opposed to having the user have to configure this unique catch_log.
Tests:

  • Unit Tests Added
  • E2E Test Added (if it's a user-facing feature, or fixing a bug)


Generated description

Below is a concise technical summary of the changes proposed in this PR:
Enhance the galileo-python SDK's error handling by modifying the warn_catch_exception and async_warn_catch_exception decorators in catch_log.py to emit visible warnings using warnings.warn(). This change ensures that exceptions caught within the SDK are more readily apparent to users without requiring specific logging configurations, improving the default observability experience.

TopicDetails
LLM Span Test Update Update add_llm_span calls in batch logger tests to include the model parameter, ensuring test compatibility and completeness.
Modified files (1)
  • tests/test_logger_batch.py
Latest Contributors(2)
UserCommitDate
pratyusha@galileo.aifeat-Phase-1-Distribut...December 12, 2025
jonathanrhone@rungalil...fix-Redact-un-conclude...November 03, 2025
Error Visibility Improve error visibility by emitting warnings for exceptions caught within the SDK's warn_catch_exception and async_warn_catch_exception decorators, ensuring users are notified without requiring specific logging configurations.
Modified files (1)
  • src/galileo/utils/catch_log.py
Latest Contributors(2)
UserCommitDate
pratyusha@galileo.aifeat-Phase-1-Distribut...December 12, 2025
jimbobbennett@mac.comfix-Fixing-docstrings-369October 15, 2025
This pull request is reviewed by Baz. Review like a pro on (Baz).

@mikebranc mikebranc changed the title Update error handling to log with warnings.warn() feat: Update error handling to log with warnings.warn() Dec 19, 2025
except exception as err:
logger.warning(f"Error occurred during execution: {f.__name__}: {err}")
# Emit a warning that's visible by default (no logging config needed)
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Failed check: pre-commit / pre-commit
I’ve attached the relevant part of the log for your convenience:
pre-commit hook made changes to file: warnings.warn() call was reformatted from multi-line to single-line format in the warn_catch_exception function


Finding type: Log Error

def wrapper(f: Callable) -> Callable:
@functools.wraps(f)
async def inner(*args: Any, **kwargs: Any) -> Any:
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Failed check: pre-commit / pre-commit
I’ve attached the relevant part of the log for your convenience:
pre-commit hook made changes to file: warnings.warn() call was reformatted from multi-line to single-line format in the async_warn_catch_exception function


Finding type: Log Error

@mikebranc mikebranc force-pushed the feat/update-error-handling branch from b3a8402 to 9896e4a Compare December 19, 2025 19:34
# Emit a warning that's visible by default (no logging config needed)
warnings.warn(
f"Galileo: {f.__name__} failed: {err}",
RuntimeWarning,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Failed check: pre-commit / pre-commit
I’ve attached the relevant part of the log for your convenience:
pre-commit hook made changes to file: warnings.warn() call was reformatted from multi-line to single-line format (lines 355-359 collapsed to line 360)


Finding type: Log Error

@mikebranc mikebranc force-pushed the feat/update-error-handling branch from 9896e4a to 2fced79 Compare December 19, 2025 19:49
from typing import Any, Callable


def warn_catch_exception(logger: Logger = logging.getLogger(__name__), exception: type[Exception] = Exception) -> Any:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing support for the standard logger interface is not the correct approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I added this back in addition to the warnings.warn() but sounds like we'll want to think about this a bit more deeply

@mikebranc mikebranc force-pushed the feat/update-error-handling branch from 2fced79 to 6c437bd Compare December 19, 2025 21:56
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.98%. Comparing base (1a11fe9) to head (6c437bd).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #442   +/-   ##
=======================================
  Coverage   82.98%   82.98%           
=======================================
  Files          89       89           
  Lines        7980     8024   +44     
=======================================
+ Hits         6622     6659   +37     
- Misses       1358     1365    +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants