Skip to content

fix: parallelism environment variable should be reset - #408

Merged
stephantul merged 1 commit into
mainfrom
fix-mp
Nov 5, 2026
Merged

stephantul merged 1 commit into
mainfrom
fix-mp

Conversation

@stephantul

Copy link
Copy Markdown
Contributor

Multiprocessing turned off tokenizers parallelism, but we never turned it back on.

@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects the shared encoding path used by `StaticModel` callers.

The restore logic needs coordination across overlapping calls before merging.

Reviews (1) · Last reviewed commit: "fix: parallelism environment variable sh..." · Reviewed by Greptile

Comment thread model2vec/model.py Resolved
Comment thread tests/test_model.py
Comment on lines +130 to +131
model.encode(["word1 word2"] * 15_000, use_multiprocessing=True)
assert os.environ.get("TOKENIZERS_PARALLELISM") == previous

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed calls lack cleanup coverage

The new test checks restoration only after a successful encode. Add a case where a batch raises, then check that the original environment value is restored and the exception still reaches the caller. Otherwise, moving cleanup outside finally would pass this test while leaving parallelism disabled after failed requests.

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
model2vec/model.py 97.60% <100.00%> (+0.04%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stephantul
stephantul merged commit 4910be5 into main Nov 5, 2026
12 checks passed
@stephantul
stephantul deleted the fix-mp branch November 5, 2026 15:56
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