Skip to content

[auto-review #1417] fix otel test collection crash + demo formatting (CI) - #29

Open
Chrisclone wants to merge 1 commit into
christopherpestano:otel-draftingfrom
Chrisclone:auto-review/pr-1417-20260616T140001Z
Open

[auto-review #1417] fix otel test collection crash + demo formatting (CI)#29
Chrisclone wants to merge 1 commit into
christopherpestano:otel-draftingfrom
Chrisclone:auto-review/pr-1417-20260616T140001Z

Conversation

@Chrisclone

Copy link
Copy Markdown

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

  1. CI failure (real bug in diff) — tests/test_otel.py crashes collection in the minimal env.
    Line 14 was _OTEL_INSTALLED = find_spec('opentelemetry.sdk') is not None. importlib.util.find_spec on a dotted name imports the parent package to read its __path__, so when opentelemetry is not installed it raises ModuleNotFoundError instead of returning None. In the minimal matrix 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_otel wraps the same call in try/except ModuleNotFoundError (pixeltable/env.py:634-641) with a comment explaining it. The test just didn't mirror it.

  2. CI failure (real bug in diff) — static-checks fails on ruff format --check.
    otel_demo.py (committed at repo root) was not ruff-formatted: "Would reformat: otel_demo.py" -> exit 1. ruff check passes because it only targets pixeltable tests tool, but ruff format --check runs over the whole repo.

(The validate job failure is just the aggregate gate over the matrix; standard/ubuntu and macos passed because they install the [otel] extra. No separate fix needed.)

Changes made

  • tests/test_otel.py: extracted a small _otel_installed() helper that wraps find_spec('opentelemetry.sdk') in try/except ModuleNotFoundError, mirroring the env.py guard. Behavior is unchanged when the extra is installed.
  • otel_demo.py: applied ruff format (one line recombined). No logic change.

Validated locally

  • ruff format --check -> "469 files already formatted" (clean).
  • ruff check pixeltable tests tool and ruff check --select I -> "All checks passed!".
  • python -m py_compile tests/test_otel.py otel_demo.py -> OK.
  • Reproduced the original crash and confirmed the guard fixes it: find_spec('absent_pkg.sub') raises ModuleNotFoundError; the wrapped helper returns False.
  • Could not run the otel pytest suite locally — this base env has no built pixeltable._version (package not pip-installed), so import pixeltable fails at collection regardless of the change. The fix is purely import-time, exercised by the reproduction above; it should be confirmed by the minimal CI job on re-run.

False-positive risk / what to sanity-check

  • Low risk overall — both changes are mechanical and mirror existing in-repo patterns. The test fix only changes the no-extra code path (returns False instead of raising); when opentelemetry is installed it behaves exactly as before, so the otel tests still run on standard/macos.
  • Not addressed (flagging, not fixing): otel_demo.py and OTEL_PLAN.md live at the repo root, and otel_demo.py imports _double from tests.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 _double UDF out of tests/ before this merges. I left them in place since removal is a product call, not a CI fix.

🤖 Generated with Claude Code

- 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>
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.

1 participant