Fix #263: make sentry_sdk import optional (clean-install ModuleNotFoundError) - #271
Open
Diogo-Damasceno wants to merge 1 commit into
Open
Fix #263: make sentry_sdk import optional (clean-install ModuleNotFoundError)#271Diogo-Damasceno wants to merge 1 commit into
Diogo-Damasceno wants to merge 1 commit into
Conversation
…ModuleNotFoundError) telemetry.py imported sentry_sdk unconditionally at module top level, so a clean without sentry-sdk on the path raised ModuleNotFoundError on every import of deepteam.telemetry (issue confident-ai#263). - Wrap the sentry_sdk import in try/except and alias it to None when missing (matching the existing pattern used for opentelemetry/posthog). - Guard sentry_sdk.init(...) and sentry_sdk.capture_exception(...) on the optional alias so the module degrades gracefully instead of crashing. - Declare sentry-sdk, posthog and the opentelemetry packages as direct dependencies in pyproject.toml (they were only present in poetry.lock, so a fresh install could end up without them). Verified: tests/unit/test_telemetry_optional_sentry.py passes (2 passed). The test loads telemetry.py with sentry_sdk blocked and asserts the module imports without error; it fails against the old unconditional import, confirming the regression is covered.
|
@Diogo-Damasceno is attempting to deploy a commit to the Confident AI Team on Vercel. A member of the Team first needs to authorize it. |
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
Fixes #263 —
ModuleNotFoundError: No module named 'sentry_sdk'on a clean install.deepteam/telemetry.pyimportedsentry_sdkunconditionally at module top level. On a cleanpip install deepteamwheresentry-sdkwas not on the path, that single import raisedModuleNotFoundErrorand broke every import ofdeepteam.telemetry(and thus the package).Changes
sentry_sdkimport intry/exceptand alias it toNonewhen missing — matching the pattern already used foropentelemetry/posthog.sentry_sdk.init(...)andsentry_sdk.capture_exception(...)on the optional alias so the module degrades gracefully instead of crashing.sentry-sdk,posthogand theopentelemetry-*packages as direct dependencies inpyproject.toml. They were only present inpoetry.lock, so a fresh install could end up without them.Verification
tests/unit/test_telemetry_optional_sentry.py: loadstelemetry.pywithsentry_sdkblocked and asserts the module imports without error andsentry_sdk is None.blackapplied to match repo style.Note: this does not change telemetry behaviour when
sentry_sdkis present; it only removes the hard dependency that made the package unimportable without it.