[auto-review #1417] fix otel test collection crash + demo formatting (CI) - #29
Open
Chrisclone wants to merge 1 commit into
Open
Conversation
- tests/test_otel.py: guard find_spec('opentelemetry.sdk') against
ModuleNotFoundError. On a dotted name, find_spec imports the parent
package and raises (rather than returning None) when `opentelemetry`
is absent, crashing collection in the `minimal` CI env. Mirror the
existing guard in Env._maybe_enable_otel (pixeltable/env.py:634-641).
- otel_demo.py: apply `ruff format` (was failing `ruff format --check`
in static-checks).
Co-Authored-By: Claude Opus 4.8 (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.
Auto-review of pixeltable#1417 (otel-drafting)
Targets Chris's PR: pixeltable#1417 (base
otel-drafting).Scope of this review was CI failures + high-level architecture only. The OTEL design itself looks solid (see notes at the bottom); this PR only fixes the two CI breakages.
Issues found
CI failure (real bug in diff) —
tests/test_otel.pycrashes collection in theminimalenv.Line 14 was
_OTEL_INSTALLED = find_spec('opentelemetry.sdk') is not None.importlib.util.find_specon a dotted name imports the parent package to read its__path__, so whenopentelemetryis not installed it raisesModuleNotFoundErrorinstead of returningNone. In theminimalmatrix job (no[otel]extra) this aborts collection of the whole test module:ModuleNotFoundError: No module named 'opentelemetry'->Interrupted: 1 error during collection(exit 2).Notably, the production code already handles this exact gotcha —
Env._maybe_enable_otelwraps the same call intry/except ModuleNotFoundError(pixeltable/env.py:634-641) with a comment explaining it. The test just didn't mirror it.CI failure (real bug in diff) —
static-checksfails onruff format --check.otel_demo.py(committed at repo root) was not ruff-formatted: "Would reformat: otel_demo.py" -> exit 1.ruff checkpasses because it only targetspixeltable tests tool, butruff format --checkruns over the whole repo.(The
validatejob failure is just the aggregate gate over the matrix;standard/ubuntuandmacospassed because they install the[otel]extra. No separate fix needed.)Changes made
tests/test_otel.py: extracted a small_otel_installed()helper that wrapsfind_spec('opentelemetry.sdk')intry/except ModuleNotFoundError, mirroring the env.py guard. Behavior is unchanged when the extra is installed.otel_demo.py: appliedruff format(one line recombined). No logic change.Validated locally
ruff format --check-> "469 files already formatted" (clean).ruff check pixeltable tests toolandruff check --select I-> "All checks passed!".python -m py_compile tests/test_otel.py otel_demo.py-> OK.find_spec('absent_pkg.sub')raisesModuleNotFoundError; the wrapped helper returnsFalse.pixeltable._version(package not pip-installed), soimport pixeltablefails at collection regardless of the change. The fix is purely import-time, exercised by the reproduction above; it should be confirmed by theminimalCI job on re-run.False-positive risk / what to sanity-check
Falseinstead of raising); whenopentelemetryis installed it behaves exactly as before, so the otel tests still run onstandard/macos.otel_demo.pyandOTEL_PLAN.mdlive at the repo root, andotel_demo.pyimports_doublefromtests.test_hooks(a demo depending on the test suite). For a draft that's fine, but you'll probably want to relocate the demo (e.g.docs/sample-apps/) and drop the plan doc / move the_doubleUDF out oftests/before this merges. I left them in place since removal is a product call, not a CI fix.🤖 Generated with Claude Code