Skip to content

Commit 84c109e

Browse files
authored
Merge pull request #889 from adrianeboyd/chore/update-develop-for-v8.2-2
Update develop for v8.2
2 parents 52b23f9 + 2fc7f8f commit 84c109e

File tree

199 files changed

+45615
-20919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+45615
-20919
lines changed

.github/ISSUE_TEMPLATE/01_bugs.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: "\U0001F6A8 Submit a Bug Report"
3+
about: Use this template if you came across a bug or unexpected behaviour differing from the docs.
4+
---
5+
6+
## How to reproduce the behaviour
7+
8+
<!-- Include a code example or the steps that led to the problem. Please try to be as specific as possible. -->
9+
10+
## Your Environment
11+
12+
<!-- Include details of your environment. -->
13+
14+
- Operating System:
15+
- Python Version Used:
16+
- Thinc Version Used:
17+
- Environment Information:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--- Provide a general summary of your changes in the title. -->
2+
3+
## Description
4+
5+
<!--- Use this section to describe your changes. If your changes required
6+
testing, include information about the testing environment and the tests you
7+
ran. If your test fixes a bug reported in an issue, don't forget to include the
8+
issue number. If your PR is still a work in progress, that's totally fine – just
9+
include a note to let us know. -->
10+
11+
### Types of change
12+
13+
<!-- What type of change does your PR cover? Is it a bug fix, an enhancement
14+
or new feature, or a change to the documentation? -->
15+
16+
## Checklist
17+
18+
<!--- Before you submit the PR, go over this checklist and make sure you can
19+
tick off all the boxes. [] -> [x] -->
20+
21+
- [ ] I confirm that I have the right to submit this contribution under the project's MIT license.
22+
- [ ] I ran the tests, and all new and existing tests passed.
23+
- [ ] My changes don't require a change to the documentation, or if they do, I've added all required information.

.github/workflows/autoblack.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ jobs:
1212
if: github.repository_owner == 'explosion'
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1616
with:
1717
ref: ${{ github.head_ref }}
18-
- uses: actions/setup-python@v2
19-
- run: pip install black
18+
- uses: actions/setup-python@v4
19+
- run: pip install black -c requirements.txt
2020
- name: Auto-format code if needed
2121
run: black thinc
2222
# We can't run black --check here because that returns a non-zero excit
2323
# code and makes GitHub think the action failed
2424
- name: Check for modified files
2525
id: git-check
26-
run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
26+
run: echo modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi) >> $GITHUB_OUTPUT
2727
- name: Create Pull Request
2828
if: steps.git-check.outputs.modified == 'true'
2929
uses: peter-evans/create-pull-request@v3

.github/workflows/explosionbot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ on:
88

99
jobs:
1010
explosion-bot:
11-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-latest
1212
steps:
1313
- name: Dump GitHub context
1414
env:
1515
GITHUB_CONTEXT: ${{ toJson(github) }}
1616
run: echo "$GITHUB_CONTEXT"
17-
- uses: actions/checkout@v1
18-
- uses: actions/setup-python@v1
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-python@v4
1919
- name: Install and run explosion-bot
2020
run: |
2121
pip install git+https://${{ secrets.EXPLOSIONBOT_TOKEN }}@github.com/explosion/explosion-bot
@@ -24,4 +24,4 @@ jobs:
2424
INPUT_TOKEN: ${{ secrets.EXPLOSIONBOT_TOKEN }}
2525
INPUT_BK_TOKEN: ${{ secrets.BUILDKITE_SECRET }}
2626
ENABLED_COMMANDS: "test_gpu,test_slow,test_slow_gpu"
27-
ALLOWED_TEAMS: "spacy-maintainers"
27+
ALLOWED_TEAMS: "spacy-maintainers"

.github/workflows/tests.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "website/**"
7+
- "*.md"
8+
pull_request:
9+
types: [opened, synchronize, reopened, edited]
10+
paths-ignore:
11+
- "website/**"
12+
- "*.md"
13+
14+
jobs:
15+
validate:
16+
name: Validate
17+
if: github.repository_owner == 'explosion'
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out repo
21+
uses: actions/checkout@v3
22+
23+
- name: Configure Python version
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.7"
27+
architecture: x64
28+
29+
- name: black
30+
run: |
31+
python -m pip install black -c requirements.txt
32+
python -m black thinc --check
33+
- name: isort
34+
run: |
35+
python -m pip install isort -c requirements.txt
36+
python -m isort thinc --check
37+
- name: flake8
38+
run: |
39+
python -m pip install flake8==5.0.4
40+
python -m flake8 thinc --count --select=E901,E999,F821,F822,F823,W605 --show-source --statistics
41+
tests:
42+
name: Test
43+
needs: Validate
44+
if: github.repository_owner == 'explosion'
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
os: [ubuntu-latest, windows-latest, macos-latest]
49+
python_version: ["3.11"]
50+
include:
51+
- os: windows-2019
52+
python_version: "3.6"
53+
- os: macos-latest
54+
python_version: "3.7"
55+
- os: ubuntu-latest
56+
python_version: "3.8"
57+
- os: windows-latest
58+
python_version: "3.9"
59+
- os: macos-latest
60+
python_version: "3.10"
61+
62+
runs-on: ${{ matrix.os }}
63+
env:
64+
NOTEBOOK_KERNEL: "thinc-notebook-tests"
65+
66+
steps:
67+
- name: Check out repo
68+
uses: actions/checkout@v3
69+
70+
- name: Configure Python version
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: ${{ matrix.python_version }}
74+
architecture: x64
75+
76+
- name: Install dependencies
77+
run: |
78+
python -m pip install --upgrade pip setuptools wheel
79+
pip install -r requirements.txt
80+
81+
- name: Build sdist
82+
run: |
83+
python setup.py build_ext --inplace
84+
python setup.py sdist --formats=gztar
85+
86+
- name: Run mypy
87+
run: python -m mypy thinc --no-implicit-reexport
88+
if: matrix.python_version != '3.6'
89+
90+
- name: Delete source directory
91+
run: rm -rf thinc
92+
shell: bash
93+
94+
- name: Uninstall all packages
95+
run: |
96+
python -m pip freeze
97+
pip freeze --exclude pywin32 > installed.txt
98+
pip uninstall -y -r installed.txt
99+
100+
- name: Install from sdist
101+
run: |
102+
SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1)
103+
PIP_CONSTRAINT="build-constraints.txt" pip install dist/$SDIST
104+
shell: bash
105+
106+
- name: Test import
107+
run: python -c "import thinc"
108+
109+
- name: Run tests without extras
110+
run: |
111+
pip install -r requirements.txt
112+
pip install ipykernel pydot graphviz
113+
python -m ipykernel install --name thinc-notebook-tests --user
114+
python -m pytest --pyargs thinc -Werror --cov=thinc --cov-report=term
115+
116+
# Notes on numpy requirements hacks:
117+
# 1. torch does not have a direct numpy requirement but is compiled
118+
# against a newer version than the oldest supported numpy for windows and
119+
# python 3.10; this version of numpy would not work with
120+
# tensorflow~=2.5.0 as specified above, but there is no release for
121+
# python 3.10 anyway
122+
# 2. restrict to numpy<1.24.0 due to mxnet incompatibility
123+
# 3. forbid torch!=1.13.0 due to segfaults with numpy<1.24.0
124+
# Note: some of these pip install commands are known to fail for some platforms.
125+
# To continue despite errors as in azure pipelines, remove -e from the default
126+
# bash flags.
127+
- name: Install extras for testing
128+
run: |
129+
pip install "protobuf~=3.20.0" "tensorflow~=2.5.0"
130+
pip install "mxnet; sys_platform != 'win32'"
131+
pip install "torch!=1.13.0" --extra-index-url https://download.pytorch.org/whl/cpu
132+
pip install "numpy~=1.23.0; python_version=='3.10' and sys_platform=='win32'"
133+
pip install "numpy<1.24.0"
134+
pip install -r requirements.txt
135+
pip uninstall -y mypy
136+
shell: bash --noprofile --norc -o pipefail {0}
137+
138+
- name: Run tests with extras
139+
run: python -m pytest --pyargs thinc --cov=thinc --cov-report=term
140+
141+
- name: Run tests for thinc-apple-ops
142+
run: |
143+
pip uninstall -y tensorflow
144+
pip install thinc-apple-ops
145+
python -m pytest --pyargs thinc_apple_ops
146+
if: matrix.os == 'macos-latest' && matrix.python_version == '3.10'
147+
148+
- name: Run tests with thinc-apple-ops
149+
run: python -m pytest --pyargs thinc
150+
if: matrix.os == 'macos-latest' && matrix.python_version == '3.10'

README.md

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44

55
### From the makers of [spaCy](https://spacy.io) and [Prodigy](https://prodi.gy)
66

7-
[Thinc](https://thinc.ai) is a **lightweight deep learning library** that offers an elegant,
8-
type-checked, functional-programming API for **composing models**, with support
9-
for layers defined in other frameworks such as **PyTorch, TensorFlow and MXNet**. You
10-
can use Thinc as an interface layer, a standalone toolkit or a flexible way to
11-
develop new models. Previous versions of Thinc have been running quietly in
12-
production in thousands of companies, via both [spaCy](https://spacy.io) and
13-
[Prodigy](https://prodi.gy). We wrote the new version to let users **compose,
14-
configure and deploy custom models** built with their favorite framework.
15-
16-
[![Azure Pipelines](https://img.shields.io/azure-devops/build/explosion-ai/public/7/master.svg?logo=azure-pipelines&style=flat-square)](https://dev.azure.com/explosion-ai/public/_build?definitionId=7)
7+
[Thinc](https://thinc.ai) is a **lightweight deep learning library** that offers
8+
an elegant, type-checked, functional-programming API for **composing models**,
9+
with support for layers defined in other frameworks such as **PyTorch,
10+
TensorFlow and MXNet**. You can use Thinc as an interface layer, a standalone
11+
toolkit or a flexible way to develop new models. Previous versions of Thinc have
12+
been running quietly in production in thousands of companies, via both
13+
[spaCy](https://spacy.io) and [Prodigy](https://prodi.gy). We wrote the new
14+
version to let users **compose, configure and deploy custom models** built with
15+
their favorite framework.
16+
17+
[![tests](https://github.com/explosion/thinc/actions/workflows/tests.yml/badge.svg)](https://github.com/explosion/thinc/actions/workflows/tests.yml)
1718
[![Current Release Version](https://img.shields.io/github/v/release/explosion/thinc.svg?include_prereleases&sort=semver&style=flat-square&logo=github)](https://github.com/explosion/thinc/releases)
1819
[![PyPi Version](https://img.shields.io/pypi/v/thinc.svg?include_prereleases&sort=semver&style=flat-square&logo=pypi&logoColor=white)](https://pypi.python.org/pypi/thinc)
1920
[![conda Version](https://img.shields.io/conda/vn/conda-forge/thinc.svg?style=flat-square&logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/thinc)
@@ -23,18 +24,20 @@ configure and deploy custom models** built with their favorite framework.
2324

2425
## 🔥 Features
2526

26-
- **Type-check** your model definitions with custom types and [`mypy`](https://mypy.readthedocs.io/en/latest/) plugin.
27+
- **Type-check** your model definitions with custom types and
28+
[`mypy`](https://mypy.readthedocs.io/en/latest/) plugin.
2729
- Wrap **PyTorch**, **TensorFlow** and **MXNet** models for use in your network.
28-
- Concise **functional-programming** approach to model definition, using composition rather than inheritance.
30+
- Concise **functional-programming** approach to model definition, using
31+
composition rather than inheritance.
2932
- Optional custom infix notation via **operator overloading**.
3033
- Integrated **config system** to describe trees of objects and hyperparameters.
3134
- Choice of **extensible backends**.
3235
- **[Read more &rarr;](https://thinc.ai/docs)**
3336

3437
## 🚀 Quickstart
3538

36-
Thinc is compatible with **Python 3.6+** and runs on **Linux**,
37-
**macOS** and **Windows**. The latest releases with binary wheels are available from
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
3841
[pip](https://pypi.python.org/pypi/thinc). Before you install Thinc and its
3942
dependencies, make sure that your `pip`, `setuptools` and `wheel` are up to
4043
date. For the most recent releases, pip 19.3 or newer is recommended.
@@ -44,15 +47,23 @@ pip install -U pip setuptools wheel
4447
pip install thinc
4548
```
4649

47-
See the [extended installation docs](https://thinc.ai/docs/install#extended) for details on optional dependencies for different backends and GPU. You might also want to [set up static type checking](https://thinc.ai/docs/install#type-checking) to take advantage of Thinc's type system.
50+
See the [extended installation docs](https://thinc.ai/docs/install#extended) for
51+
details on optional dependencies for different backends and GPU. You might also
52+
want to
53+
[set up static type checking](https://thinc.ai/docs/install#type-checking) to
54+
take advantage of Thinc's type system.
4855

4956
> ⚠️ If you have installed PyTorch and you are using Python 3.7+, uninstall the
50-
> package `dataclasses` with `pip uninstall dataclasses`, since it may have
51-
> been installed by PyTorch and is incompatible with Python 3.7+.
57+
> package `dataclasses` with `pip uninstall dataclasses`, since it may have been
58+
> installed by PyTorch and is incompatible with Python 3.7+.
5259
5360
### 📓 Selected examples and notebooks
5461

55-
Also see the [`/examples`](examples) directory and [usage documentation](https://thinc.ai/docs) for more examples. Most examples are Jupyter notebooks – to launch them on [Google Colab](https://colab.research.google.com) (with GPU support!) click on the button next to the notebook name.
62+
Also see the [`/examples`](examples) directory and
63+
[usage documentation](https://thinc.ai/docs) for more examples. Most examples
64+
are Jupyter notebooks – to launch them on
65+
[Google Colab](https://colab.research.google.com) (with GPU support!) click on
66+
the button next to the notebook name.
5667

5768
| Notebook | Description |
5869
| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -63,15 +74,20 @@ Also see the [`/examples`](examples) directory and [usage documentation](https:/
6374

6475
**[View more &rarr;](examples)**
6576

66-
[colab]: https://gistcdn.githack.com/ines/dcf354aa71a7665ae19871d7fd14a4e0/raw/461fc1f61a7bc5860f943cd4b6bcfabb8c8906e7/colab-badge.svg
77+
[colab]:
78+
https://gistcdn.githack.com/ines/dcf354aa71a7665ae19871d7fd14a4e0/raw/461fc1f61a7bc5860f943cd4b6bcfabb8c8906e7/colab-badge.svg
6779
[intro_to_thinc]: examples/00_intro_to_thinc.ipynb
68-
[intro_to_thinc_colab]: https://colab.research.google.com/github/explosion/thinc/blob/master/examples/00_intro_to_thinc.ipynb
80+
[intro_to_thinc_colab]:
81+
https://colab.research.google.com/github/explosion/thinc/blob/master/examples/00_intro_to_thinc.ipynb
6982
[transformers_tagger_bert]: examples/02_transformers_tagger_bert.ipynb
70-
[transformers_tagger_bert_colab]: https://colab.research.google.com/github/explosion/thinc/blob/master/examples/02_transformers_tagger_bert.ipynb
83+
[transformers_tagger_bert_colab]:
84+
https://colab.research.google.com/github/explosion/thinc/blob/master/examples/02_transformers_tagger_bert.ipynb
7185
[pos_tagger_basic_cnn]: examples/03_pos_tagger_basic_cnn.ipynb
72-
[pos_tagger_basic_cnn_colab]: https://colab.research.google.com/github/explosion/thinc/blob/master/examples/03_pos_tagger_basic_cnn.ipynb
86+
[pos_tagger_basic_cnn_colab]:
87+
https://colab.research.google.com/github/explosion/thinc/blob/master/examples/03_pos_tagger_basic_cnn.ipynb
7388
[parallel_training_ray]: examples/04_parallel_training_ray.ipynb
74-
[parallel_training_ray_colab]: https://colab.research.google.com/github/explosion/thinc/blob/master/examples/04_parallel_training_ray.ipynb
89+
[parallel_training_ray_colab]:
90+
https://colab.research.google.com/github/explosion/thinc/blob/master/examples/04_parallel_training_ray.ipynb
7591

7692
### 📖 Documentation & usage guides
7793

@@ -103,7 +119,12 @@ Also see the [`/examples`](examples) directory and [usage documentation](https:/
103119

104120
## 🐍 Development notes
105121

106-
Thinc uses [`black`](https://github.com/psf/black) for auto-formatting, [`flake8`](http://flake8.pycqa.org/en/latest/) for linting and [`mypy`](https://mypy.readthedocs.io/en/latest/) for type checking. All code is written compatible with **Python 3.6+**, with type hints wherever possible. See the [type reference](https://thinc.ai/docs/api-types) for more details on Thinc's custom types.
122+
Thinc uses [`black`](https://github.com/psf/black) for auto-formatting,
123+
[`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
126+
the [type reference](https://thinc.ai/docs/api-types) for more details on
127+
Thinc's custom types.
107128

108129
### 👷‍♀️ Building Thinc from source
109130

@@ -138,12 +159,16 @@ python setup.py build_ext --inplace
138159

139160
### 🚦 Running tests
140161

141-
Thinc comes with an [extensive test suite](thinc/tests). The following should all pass and not report any warnings or errors:
162+
Thinc comes with an [extensive test suite](thinc/tests). The following should
163+
all pass and not report any warnings or errors:
142164

143165
```bash
144166
python -m pytest thinc # test suite
145167
python -m mypy thinc # type checks
146168
python -m flake8 thinc # linting
147169
```
148170

149-
To view test coverage, you can run `python -m pytest thinc --cov=thinc`. We aim for a 100% test coverage. This doesn't mean that we meticulously write tests for every single line – we ignore blocks that are not relevant or difficult to test and make sure that the tests execute all code paths.
171+
To view test coverage, you can run `python -m pytest thinc --cov=thinc`. We aim
172+
for a 100% test coverage. This doesn't mean that we meticulously write tests for
173+
every single line – we ignore blocks that are not relevant or difficult to test
174+
and make sure that the tests execute all code paths.

0 commit comments

Comments
 (0)