Repository navigation
fix: parallelism environment variable should be reset #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import numpy as np | ||
|
|
@@ -112,6 +113,24 @@ def test_encode_multiprocessing( | |
| assert encoded.shape == (15000, 2) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("previous", [None, "true"]) | ||
| def test_encode_multiprocessing_restores_tokenizers_parallelism( | ||
| mock_vectors: np.ndarray, | ||
| mock_tokenizer: Tokenizer, | ||
| mock_config: dict[str, str], | ||
| monkeypatch: pytest.MonkeyPatch, | ||
| previous: str | None, | ||
| ) -> None: | ||
| """Test that multiprocessing encoding restores TOKENIZERS_PARALLELISM.""" | ||
| if previous is None: | ||
| monkeypatch.delenv("TOKENIZERS_PARALLELISM", raising=False) | ||
| else: | ||
| monkeypatch.setenv("TOKENIZERS_PARALLELISM", previous) | ||
| model = StaticModel(vectors=mock_vectors, tokenizer=mock_tokenizer, config=mock_config) | ||
| model.encode(["word1 word2"] * 15_000, use_multiprocessing=True) | ||
| assert os.environ.get("TOKENIZERS_PARALLELISM") == previous | ||
|
Comment on lines
+130
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new test checks restoration only after a successful |
||
|
|
||
|
|
||
| def test_encode_as_sequence_max_length( | ||
| mock_vectors: np.ndarray, mock_tokenizer: Tokenizer, mock_config: dict[str, str] | ||
| ) -> None: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.