Skip to content

Commit 31646a4

Browse files
authored
Merge pull request #1136 from crusaderky/pytest-run-parallel
Free-threading tests
2 parents 135747f + bcd44b9 commit 31646a4

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

.github/workflows/wheel.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,36 @@ jobs:
138138
if: runner.os == 'Windows'
139139
run: echo "digests=$(sha256sum python/wheelhouse/* | base64 -w0)" >> $GITHUB_OUTPUT
140140

141+
free-threading:
142+
needs: [build_wheels]
143+
runs-on: ubuntu-latest
144+
steps:
145+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
146+
with:
147+
sparse-checkout: |
148+
python/test
149+
data/botchan.txt
150+
151+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
152+
with:
153+
python-version: "3.13t"
154+
155+
- name: Download all artifacts
156+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
157+
with:
158+
path: python/wheelhouse
159+
merge-multiple: true
160+
161+
- name: Install sentencepiece wheel
162+
run: pip install --find-links=python/wheelhouse sentencepiece
163+
164+
- name: Install test dependencies
165+
run: pip install pytest pytest-run-parallel
166+
167+
- name: Run free-threading tests
168+
working-directory: python
169+
run: pytest -v --parallel-threads 4
170+
141171
gather-digests:
142172
needs: [build_wheels]
143173
outputs:

python/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*.so
22
/build
33
/*.pickle
4-
/m_*
5-
/m.*
4+
/m*.model
5+
/m*.vocab
66
/src/sentencepiece/package_data

python/test/sentencepiece_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,12 +779,13 @@ def test_batch(self):
779779
self.assertEqual(e1, e3)
780780

781781
def test_pickle(self):
782-
with open('sp.pickle', 'wb') as f:
782+
tid = threading.get_native_id()
783+
with open(f'sp_{tid}.pickle', 'wb') as f:
783784
pickle.dump(self.sp_, f)
784785

785786
id1 = self.sp_.encode('hello world.', out_type=int)
786787

787-
with open('sp.pickle', 'rb') as f:
788+
with open(f'sp_{tid}.pickle', 'rb') as f:
788789
sp = pickle.load(f)
789790

790791
id2 = sp.encode('hello world.', out_type=int)

0 commit comments

Comments
 (0)