Skip to content

Commit 5ccd6af

Browse files
CI: switch to coverage-run pattern to dodge torch+pytest-cov segfault
The hosted Linux runner's torch + Python 3.12.13 + pytest-cov combination segfaults at conftest-import time when the coverage tracer starts before torch's C extension finishes initializing. PR-N1's first 2 CI runs both failed with: ImportError while loading conftest 'tests/conftest.py'. tests/conftest.py:14: in <module> import torch E ValueError: module functions cannot set METH_CLASS or METH_STATIC Segmentation fault (core dumped) The Mac M4 reviewer scripts already use 'coverage run -m pytest' + post-hoc 'coverage report --include' to avoid this race (commit 9d1a250 documented the workaround). Same pattern applied to the CI workflow here. Behavior preserved: 100% coverage gate on the same set of modules, junit.xml + coverage.xml artifacts as before. Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
1 parent 5adb4dc commit 5ccd6af

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ jobs:
8080
# ``inference_engine.session.coordinator`` and
8181
# ``inference_engine.session.generator`` — move to the
8282
# tests/integration/ suite, gated on Mac M4 / CUDA hosts.
83-
pytest \
83+
#
84+
# Coverage is invoked via ``coverage run -m pytest`` rather
85+
# than ``pytest --cov=`` to avoid a torch+pytest-cov race
86+
# at conftest-import time on the hosted Linux runner
87+
# (PR-N1 hit "module functions cannot set METH_CLASS or
88+
# METH_STATIC" / SIGSEGV when --cov= started the tracer
89+
# before torch's C extension finished initializing).
90+
# Same pattern Mac M4 reviewer scripts use.
91+
coverage run -m pytest \
8492
tests/inference_engine/server/ \
8593
tests/inference_engine/memory/ \
8694
tests/inference_engine/scheduler/ \
@@ -89,18 +97,13 @@ jobs:
8997
tests/sdk/python/ \
9098
tests/training/repr_align/ \
9199
tests/backends/mlx/test_env.py \
92-
--cov=inference_engine.server \
93-
--cov=inference_engine.memory \
94-
--cov=inference_engine.scheduler \
95-
--cov=inference_engine.pipeline \
96-
--cov=inference_engine.session.store \
97-
--cov=kakeya \
98-
--cov=training.repr_align \
99-
--cov-report=term \
100-
--cov-report=xml:coverage.xml \
101-
--cov-fail-under=100 \
102100
--junitxml=junit.xml \
103101
-v
102+
coverage report \
103+
--include='inference_engine/server/*,inference_engine/memory/*,inference_engine/scheduler/*,inference_engine/pipeline/*,inference_engine/session/store.py,sdks/python/kakeya/*,training/repr_align/*' \
104+
--fail-under=100
105+
coverage xml -o coverage.xml \
106+
--include='inference_engine/server/*,inference_engine/memory/*,inference_engine/scheduler/*,inference_engine/pipeline/*,inference_engine/session/store.py,sdks/python/kakeya/*,training/repr_align/*'
104107
105108
- name: Upload coverage artifact
106109
if: always()

0 commit comments

Comments
 (0)