fix(session-replay): keep xgboost off the temporal worker import path#68269
Merged
Conversation
xgboost dlopens libomp at import time, and on macOS dev machines without an OpenMP runtime (no homebrew libomp) that raises XGBoostError while the shared temporal worker imports the surfacing scoring package — crash-looping the whole worker and taking every product's workflows down with it. The warmup_best_effort guard never gets a chance to run because the failure happens at module import. Import xgboost lazily inside the two functions that use it, so a missing OpenMP runtime only fails surfacing scoring activities at runtime instead of preventing the worker from booting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
|
Reviews (1): Last reviewed commit: "fix(session-replay): keep xgboost off th..." | Re-trigger Greptile |
mayteio
approved these changes
Jul 3, 2026
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.

Problem
xgboost dlopens libomp at import time. On a macOS dev machine without an OpenMP runtime (no homebrew
libomp),import xgboostraisesXGBoostError— and since the shared temporal worker imports the surfacing scoring package at module load (worker.py→surfacing_scoring_sweep.metrics→ package__init__→activities→scorer→import xgboost), the whole dev temporal worker crash-loops and every product's workflows stop running. The existingwarmup_best_effort()guard never runs because the failure happens before the worker can boot.Changes
Defer
import xgboostinto the two functions that actually use it (_load_booster,predict), with aTYPE_CHECKINGimport for annotations. A missing OpenMP runtime now fails surfacing scoring activities at runtime (logged, retried per policy) instead of preventing the worker from importing at all — matching the intentwarmup_best_effort()already documents.How did you test this code?
posthog.temporal.session_replay.surfacing_scoring_sweepunder Django no longer putsxgboostinsys.modules(it previously crashed outright on a machine without libomp).ruff check/ruff formatclean.test_scorer.pycan't run on the affected machine (it genuinely needs xgboost); CI runs it with libomp present, and no behavior inside the functions changed — only the import site moved.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Built with Claude Code. Found while debugging why a fresh onboarding cloud run sat queued forever locally: phrocs showed the temporal worker crash-looping on this import. Chose the lazy-import route (sanctioned for heavy/optional native deps,
noqa: PLC0415) over adding libomp to the flox manifest — the worker staying up matters for everyone; provisioning the OpenMP runtime for people who actually run scoring locally can be a separate devex change.🤖 Generated with Claude Code