Skip to content

Commit ac9663f

Browse files
authored
Tests and dependencies refresh (#964)
1 parent 3f79ad4 commit ac9663f

File tree

12 files changed

+100
-90
lines changed

12 files changed

+100
-90
lines changed

.github/workflows/tests.yml

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@ name: tests
22

33
on:
44
push:
5+
branches: [main, v8.3.x]
56
paths-ignore:
67
- "website/**"
78
- "*.md"
89
pull_request:
9-
types: [opened, synchronize, reopened, edited]
10+
branches: ["*"]
1011
paths-ignore:
1112
- "website/**"
1213
- "*.md"
14+
workflow_dispatch: # allows you to trigger manually
15+
16+
# When this workflow is queued, automatically cancel any previous running
17+
# or pending jobs from the same branch
18+
concurrency:
19+
group: tests-${{ github.ref }}
20+
cancel-in-progress: true
1321

1422
jobs:
1523
validate:
1624
name: Validate
17-
if: github.repository_owner == 'explosion'
1825
runs-on: ubuntu-latest
1926
steps:
2027
- name: Check out repo
@@ -35,26 +42,31 @@ jobs:
3542
python -m isort thinc --check
3643
- name: flake8
3744
run: |
38-
python -m pip install flake8==5.0.4
45+
python -m pip install flake8 -c requirements.txt
3946
python -m flake8 thinc --count --select=E901,E999,F821,F822,F823,W605 --show-source --statistics
47+
- name: mypy
48+
run: |
49+
python -m pip install mypy -c requirements.txt
50+
python -m pip install catalogue confection numpy packaging pydantic
51+
python -m mypy thinc --no-implicit-reexport
52+
4053
tests:
41-
name: Test
42-
needs: Validate
43-
if: github.repository_owner == 'explosion'
54+
name: ${{ matrix.os }} - Python ${{ matrix.python_version }}
4455
strategy:
4556
fail-fast: false
4657
matrix:
47-
os: [ubuntu-latest, windows-latest, macos-15-intel]
48-
python_version: ["3.12"]
49-
include:
50-
- os: windows-latest
51-
python_version: "3.10"
52-
- os: macos-15-intel
58+
os:
59+
- ubuntu-latest
60+
- ubuntu-24.04-arm
61+
- macos-15-intel
62+
- macos-latest
63+
- windows-latest
64+
- windows-11-arm
65+
python_version: ["3.10", "3.11", "3.12", "3.13"]
66+
exclude:
67+
- os: windows-11-arm
5368
python_version: "3.10"
54-
- os: ubuntu-latest
55-
python_version: "3.11"
56-
- os: windows-latest
57-
python_version: "3.11"
69+
5870
runs-on: ${{ matrix.os }}
5971
env:
6072
NOTEBOOK_KERNEL: "thinc-notebook-tests"
@@ -68,26 +80,11 @@ jobs:
6880
with:
6981
python-version: ${{ matrix.python_version }}
7082

71-
- name: Install dependencies
72-
run: |
73-
python -m pip install --upgrade pip setuptools wheel
74-
pip install -r requirements.txt
75-
76-
- name: Build sdist
77-
run: |
78-
# Remove the '.eggs' directory in case it's not empty
79-
# due to setuptools quirks
80-
rm -rf .eggs
81-
python setup.py build_ext --inplace
82-
rm -rf .eggs
83-
python setup.py sdist --formats=gztar
84-
shell: bash
83+
- name: Install build dependencies
84+
run: python -m pip install --upgrade build pip wheel
8585

86-
- name: Run mypy
87-
run: python -m mypy thinc --no-implicit-reexport
88-
if: |
89-
matrix.python_version != '3.6' &&
90-
matrix.python_version != '3.7'
86+
- name: Build sdist and wheel
87+
run: python -m build
9188

9289
- name: Delete source directory
9390
run: rm -rf thinc
@@ -99,28 +96,24 @@ jobs:
9996
pip freeze --exclude pywin32 > installed.txt
10097
pip uninstall -y -r installed.txt
10198
102-
- name: Install from sdist
103-
run: |
104-
SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1)
105-
PIP_CONSTRAINT="build-constraints.txt" pip install dist/$SDIST
99+
- name: Install from wheel
100+
run: pip install dist/*.whl
106101
shell: bash
107102

108103
- name: Test import
109104
run: python -c "import thinc"
110105

111106
- name: Install test requirements
112-
run: |
113-
pip install -r requirements.txt
107+
run: pip install -r requirements.txt
114108

115109
- name: Install notebook test requirements
116-
run: |
117-
pip install ipykernel pydot graphviz
118-
python -m ipykernel install --name thinc-notebook-tests --user
119-
if: matrix.python_version != '3.12'
110+
run: python -m ipykernel install --name thinc-notebook-tests --user
111+
112+
- name: List installed packages
113+
run: python -m pip list
120114

121115
- name: Run tests without extras
122-
run: |
123-
python -m pytest --pyargs thinc -Werror --cov=thinc --cov-report=term
116+
run: python -m pytest --pyargs thinc --cov=thinc --cov-report=term
124117

125118
# Notes on numpy requirements hacks:
126119
# 1. torch does not have a direct numpy requirement but is compiled
@@ -156,8 +149,8 @@ jobs:
156149
pip uninstall -y tensorflow
157150
pip install "thinc-apple-ops>=1.0.0,<2.0.0"
158151
python -m pytest --pyargs thinc_apple_ops
159-
if: matrix.os == 'macos-15-intel' && matrix.python_version == '3.10'
152+
if: runner.os == 'macOS' && matrix.python_version == '3.10'
160153

161154
- name: Run tests with thinc-apple-ops
162155
run: python -m pytest --pyargs thinc
163-
if: matrix.os == 'macos-15-intel' && matrix.python_version == '3.10'
156+
if: runner.os == 'macOS' && matrix.python_version == '3.10'

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ their favorite framework.
3636

3737
## 🚀 Quickstart
3838

39-
Thinc is compatible with **Python 3.6+** and runs on **Linux**, **macOS** and
40-
**Windows**. The latest releases with binary wheels are available from
39+
Thinc runs on **Linux**, **macOS** and **Windows**.
40+
The latest releases with binary wheels are available from
4141
[pip](https://pypi.python.org/pypi/thinc). Before you install Thinc and its
4242
dependencies, make sure that your `pip`, `setuptools` and `wheel` are up to
4343
date. For the most recent releases, pip 19.3 or newer is recommended.
@@ -121,8 +121,8 @@ the button next to the notebook name.
121121

122122
Thinc uses [`black`](https://github.com/psf/black) for auto-formatting,
123123
[`flake8`](http://flake8.pycqa.org/en/latest/) for linting and
124-
[`mypy`](https://mypy.readthedocs.io/en/latest/) for type checking. All code is
125-
written compatible with **Python 3.6+**, with type hints wherever possible. See
124+
[`mypy`](https://mypy.readthedocs.io/en/latest/) for type checking. All code
125+
includes type hints wherever possible. See
126126
the [type reference](https://thinc.ai/docs/api-types) for more details on
127127
Thinc's custom types.
128128

build-constraints.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,19 @@ repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest
6363

6464
[tool.isort]
6565
profile = "black"
66+
67+
[tool.pytest.ini_options]
68+
addopts = "--strict-markers --strict-config -v -r sxfE --color=yes --durations=10"
69+
xfail_strict = true
70+
markers = [
71+
"slow: test with long runtime",
72+
]
73+
filterwarnings = [
74+
"error",
75+
# This is triggered by pytest -p thinc.tests.enable_tensorflow
76+
# Not an issue as the coverage upon import is recorded during the
77+
# pytest run "without extras".
78+
"ignore:Module thinc was previously imported, but not measured:coverage.exceptions.CoverageWarning",
79+
# https://github.com/coveragepy/coveragepy/issues/1790
80+
"ignore:Plugin file tracers:coverage.exceptions.CoverageWarning",
81+
]

requirements.txt

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,29 @@ murmurhash>=1.0.2,<1.1.0
33
cymem>=2.0.2,<2.1.0
44
preshed>=3.0.2,<3.1.0
55
blis>=1.3.0,<1.4.0
6-
srsly>=2.4.0,<3.0.0
6+
srsly>=2.4.0,<3.1.0
77
wasabi>=0.8.1,<1.2.0
88
catalogue>=2.0.4,<2.1.0
9-
confection>=0.0.1,<1.0.0
10-
ml_datasets>=0.2.0,<0.3.0; python_version < "3.11"
9+
confection>=0.0.1,<1.1.0
10+
ml_datasets>=0.2.0,<0.3.0
1111
# Third-party dependencies
1212
pydantic>=2.0.0,<3.0.0
1313
numpy>=2.0.0,<3.0.0
1414
packaging>=20.0
15-
# Backports of modern Python features
16-
dataclasses>=0.6,<1.0; python_version < "3.7"
17-
typing_extensions>=3.7.4.1,<4.5.0; python_version < "3.8"
18-
contextvars>=2.4,<3; python_version < "3.7"
1915
# Development dependencies
20-
cython>=0.29.0
21-
hypothesis>=3.27.0,<6.72.2
16+
cython>=3.0,<4.0
17+
hypothesis>=3.27.0,<6.149
2218
pytest>=5.2.0,!=7.1.0
23-
pytest-cov>=2.7.0,<5.0.0
19+
pytest-cov>=2.7.0,<8.0.0
2420
coverage>=5.0.0,<8.0.0
25-
mock>=2.0.0,<3.0.0
26-
flake8>=3.5.0,<3.6.0
27-
mypy>=1.5.0,<1.6.0; platform_machine != "aarch64" and python_version >= "3.8"
28-
types-mock>=0.1.1
29-
types-contextvars>=0.1.2; python_version < "3.7"
30-
types-dataclasses>=0.1.3; python_version < "3.7"
31-
importlib_resources; python_version < "3.7"
21+
flake8==5.0.4
22+
mypy>=1.5.0,<1.6.0; platform_machine != "aarch64"
3223
# Executing notebook tests
33-
ipykernel>=5.1.4,<5.2.0
34-
nbconvert>=5.6.1,<6.5.0
35-
nbformat>=5.0.4,<5.2.0
24+
ipykernel>=5.1.4,<7.2
25+
pydot
26+
graphviz
27+
nbconvert>=5.6.1,<7.17
28+
nbformat>=5.0.4,<5.11
3629
# Test to_disk/from_disk against pathlib.Path subclasses
3730
pathy>=0.3.5
3831
black>=22.0,<23.0

setup.cfg

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ classifiers =
1717
Operating System :: Microsoft :: Windows
1818
Programming Language :: Cython
1919
Programming Language :: Python :: 3
20-
Programming Language :: Python :: 3.6
21-
Programming Language :: Python :: 3.7
22-
Programming Language :: Python :: 3.8
23-
Programming Language :: Python :: 3.9
2420
Programming Language :: Python :: 3.10
2521
Programming Language :: Python :: 3.11
2622
Programming Language :: Python :: 3.12
@@ -46,19 +42,15 @@ install_requires =
4642
cymem>=2.0.2,<2.1.0
4743
preshed>=3.0.2,<3.1.0
4844
wasabi>=0.8.1,<1.2.0
49-
srsly>=2.4.0,<3.0.0
45+
srsly>=2.4.0,<3.1.0
5046
catalogue>=2.0.4,<2.1.0
51-
confection>=0.0.1,<1.0.0
47+
confection>=0.0.1,<1.1.0
5248
# Third-party dependencies
5349
setuptools
54-
numpy>=1.19.0,<3.0.0
50+
numpy>=1.21.0,<3.0.0
5551
pydantic>=2.0.0,<3.0.0
5652
packaging>=20.0
57-
# Backports of modern Python features
58-
dataclasses>=0.6,<1.0; python_version < "3.7"
59-
typing_extensions>=3.7.4.1,<5.0.0; python_version < "3.8"
60-
contextvars>=2.4,<3; python_version < "3.7"
61-
53+
6254
[options.entry_points]
6355
pytest_randomly.random_seeder =
6456
thinc = thinc.api:fix_random_seed

thinc/tests/layers/test_basic_tagger.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def get_shuffled_batches(Xs, Ys, batch_size):
6363
@pytest.mark.parametrize(
6464
("depth", "width", "vector_width", "nb_epoch"), [(2, 32, 16, 5)]
6565
)
66+
@pytest.mark.xfail(reason="Flaky live download from the internet", strict=False)
6667
def test_small_end_to_end(depth, width, vector_width, nb_epoch, create_model, ancora):
6768
(train_X, train_Y), (dev_X, dev_Y) = ancora
6869
batch_size = 8

thinc/tests/layers/test_linear.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from unittest.mock import MagicMock
2+
13
import numpy
24
import pytest
35
from hypothesis import given, settings
4-
from mock import MagicMock
56
from numpy.testing import assert_allclose
67

78
from thinc.api import SGD, Dropout, Linear, chain

thinc/tests/layers/test_mnist.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import platform
2+
13
import pytest
24

35
from thinc.api import (
@@ -79,6 +81,11 @@ def create_model(request):
7981

8082

8183
@pytest.mark.slow
84+
@pytest.mark.xfail(
85+
platform.system() == "Darwin",
86+
reason="SSL: CERTIFICATE_VERIFY_FAILED",
87+
strict=False, # Works on macos-15-intel Python 3.10, for some reason
88+
)
8289
@pytest.mark.parametrize(("width", "nb_epoch", "min_score"), [(32, 20, 0.8)])
8390
def test_small_end_to_end(width, nb_epoch, min_score, create_model, mnist):
8491
batch_size = 128

thinc/tests/layers/test_with_debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from mock import MagicMock
1+
from unittest.mock import MagicMock
22

33
from thinc.api import Linear, with_debug
44

0 commit comments

Comments
 (0)