Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
python -m mypy thinc --no-implicit-reexport

tests:
name: ${{ matrix.os }} - Python ${{ matrix.python_version }}
name: ${{ matrix.os }} - Python ${{ matrix.python_version }} ${{ matrix.nightly }}
strategy:
fail-fast: false
matrix:
Expand All @@ -63,6 +63,11 @@ jobs:
- windows-latest
- windows-11-arm
python_version: ["3.10", "3.11", "3.12", "3.13"]
nightly: [""] # Use only official releases
include:
- os: ubuntu-latest
python_version: "3.13"
nightly: "nightly" # Use nightly wheels and git tips
exclude:
- os: windows-11-arm
python_version: "3.10"
Expand All @@ -83,9 +88,29 @@ jobs:
- name: Install build dependencies
run: python -m pip install --upgrade build pip wheel

- name: Install nightly build dependencies
if: matrix.nightly == 'nightly'
run: |
pip install --upgrade --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/ numpy blis

# Install dependencies for --no-isolation
pip install setuptools \
"cython>=3.0,<4.0" \
"cymem>=2.0.2,<3" \
"murmurhash>=1.0.2,<2"

# TODO this won't be necessary long term after release 3.0.13
# (replace with "preshed>=3.0.2,<3.1.0" above)
pip install git+https://github.com/explosion/preshed.git@v3.0.x

- name: Build sdist and wheel
if: matrix.nightly == ''
run: python -m build

- name: Build sdist and wheel (no build isolation)
if: matrix.nightly == 'nightly'
run: python -m build --no-isolation

- name: Delete source directory
run: rm -rf thinc
shell: bash
Expand All @@ -109,6 +134,35 @@ jobs:
- name: Install notebook test requirements
run: python -m ipykernel install --name thinc-notebook-tests --user

- name: Install nightly runtime dependencies
if: matrix.nightly == 'nightly'
run: |
pip install --upgrade --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/ numpy blis

# TODO this won't be necessary long term after release 3.0.13
pip install --upgrade git+https://github.com/explosion/preshed.git@v3.0.x

# TODO this won't be necessary long term after a free-threading release
# TODO merge https://github.com/ultrajson/ultrajson/pull/689
# pip install --upgrade git+https://github.com/ultrajson/ultrajson.git
pip install --upgrade git+https://github.com/crusaderky/ultrajson.git@free-threading

# FIXME msgpack-python is not fully compatible with free-threading at the
# moment of writing; naive pip install from git tip fails:
# https://github.com/msgpack/msgpack-python/issues/613

# TODO this won't be necessary long term after release 1.0.0
# FIXME confection git tip is broken
# pip install --upgrade git+https://github.com/explosion/confection.git

# TODO this won't be necessary long term after release 0.2.1
pip install --upgrade git+https://github.com/explosion/ml-datasets

# TODO this won't be necessary long term after release 3.0
# TODO merge https://github.com/explosion/srsly/pull/120
# pip install --upgrade git+https://github.com/explosion/srsly.git
pip install --upgrade git+https://github.com/crusaderky/srsly.git@ft

- name: List installed packages
run: python -m pip list

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ filterwarnings = [
"ignore:Module thinc was previously imported, but not measured:coverage.exceptions.CoverageWarning",
# https://github.com/coveragepy/coveragepy/issues/1790
"ignore:Plugin file tracers:coverage.exceptions.CoverageWarning",
# FIXME Pydantic V2 migration
"ignore::pydantic.warnings.PydanticDeprecatedSince20",
]
2 changes: 2 additions & 0 deletions thinc/tests/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ def dummy_model(name, layers):
assert a.layers[1].get_ref("y") == y_debug


# NumPy >=2.4 issues a warning when unpacking mnist pickle
@pytest.mark.filterwarnings("ignore::numpy.exceptions.VisibleDeprecationWarning")
@pytest.mark.xfail(
platform.system() == "Darwin",
reason="SSL: CERTIFICATE_VERIFY_FAILED",
Expand Down
23 changes: 4 additions & 19 deletions thinc/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import inspect
import pickle
from types import GeneratorType
from typing import Any, Callable, Dict, Iterable, List, Optional, Union

import catalogue
import numpy
import pytest

try:
from pydantic.v1 import BaseModel, PositiveInt, StrictBool, StrictFloat, constr
except ImportError:
from pydantic import BaseModel, PositiveInt, StrictBool, StrictFloat, constr # type: ignore
from pydantic import BaseModel, StrictBool

import thinc.config
from thinc.api import Config, Model, NumpyOps, RAdam
from thinc.config import ConfigValidationError
from thinc.types import Generator, Ragged
from thinc.util import partial

from .util import make_tempdir
from thinc.api import Config, Model, RAdam

EXAMPLE_CONFIG = """
[optimizer]
Expand Down Expand Up @@ -175,11 +160,11 @@ def test_objects_from_config():
}

@thinc.registry.optimizers.register("my_cool_optimizer.v1")
def make_my_optimizer(learn_rate: List[float], beta1: float):
def make_my_optimizer(learn_rate: list[float], beta1: float):
return RAdam(learn_rate, beta1=beta1)

@thinc.registry.schedules("my_cool_repetitive_schedule.v1")
def decaying(base_rate: float, repeat: int) -> List[float]:
def decaying(base_rate: float, repeat: int) -> list[float]:
return repeat * [base_rate]

optimizer = my_registry.resolve(config)["optimizer"]
Expand Down
7 changes: 1 addition & 6 deletions thinc/tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import numpy
import pytest

try:
from pydantic.v1 import ValidationError, create_model
except ImportError:
from pydantic import ValidationError, create_model # type: ignore

from pydantic import ValidationError, create_model

from thinc.types import (
Floats1d,
Expand Down
2 changes: 0 additions & 2 deletions thinc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
)

import numpy
from packaging.version import Version
from pydantic import ConfigDict, ValidationError, create_model
from wasabi import table # type: ignore

from .compat import (
Expand Down
Loading