2023-03-13 12:13:47 +00:00
|
|
|
name: tests
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2024-09-14 09:07:23 +00:00
|
|
|
tags-ignore:
|
|
|
|
- '**'
|
2023-03-13 12:13:47 +00:00
|
|
|
branches-ignore:
|
|
|
|
- "spacy.io"
|
|
|
|
- "nightly.spacy.io"
|
|
|
|
- "v2.spacy.io"
|
|
|
|
paths-ignore:
|
|
|
|
- "*.md"
|
|
|
|
- "*.mdx"
|
2023-03-17 09:59:53 +00:00
|
|
|
- "website/**"
|
2023-03-13 12:13:47 +00:00
|
|
|
pull_request:
|
|
|
|
types: [opened, synchronize, reopened, edited]
|
2023-03-17 09:01:49 +00:00
|
|
|
paths-ignore:
|
|
|
|
- "*.md"
|
|
|
|
- "*.mdx"
|
2023-03-17 09:59:53 +00:00
|
|
|
- "website/**"
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
validate:
|
|
|
|
name: Validate
|
2023-03-27 10:44:04 +00:00
|
|
|
if: github.repository_owner == 'explosion'
|
2023-03-13 12:13:47 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Check out repo
|
2024-04-29 11:28:46 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: Configure Python version
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
2024-10-01 11:21:10 +00:00
|
|
|
python-version: "3.10"
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: black
|
|
|
|
run: |
|
|
|
|
python -m pip install black -c requirements.txt
|
|
|
|
python -m black spacy --check
|
2023-06-15 22:10:25 +00:00
|
|
|
- name: isort
|
|
|
|
run: |
|
|
|
|
python -m pip install isort -c requirements.txt
|
|
|
|
python -m isort spacy --check
|
2023-03-13 12:13:47 +00:00
|
|
|
- name: flake8
|
|
|
|
run: |
|
|
|
|
python -m pip install flake8==5.0.4
|
|
|
|
python -m flake8 spacy --count --select=E901,E999,F821,F822,F823,W605 --show-source --statistics
|
2023-07-19 10:03:31 +00:00
|
|
|
- name: cython-lint
|
|
|
|
run: |
|
|
|
|
python -m pip install cython-lint -c requirements.txt
|
|
|
|
# E501: line too log, W291: trailing whitespace, E266: too many leading '#' for block comment
|
|
|
|
cython-lint spacy --ignore E501,W291,E266
|
|
|
|
|
2023-03-13 12:13:47 +00:00
|
|
|
tests:
|
|
|
|
name: Test
|
|
|
|
needs: Validate
|
|
|
|
strategy:
|
2023-05-26 08:57:02 +00:00
|
|
|
fail-fast: true
|
2023-03-13 12:13:47 +00:00
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
2024-10-01 13:28:22 +00:00
|
|
|
python_version: ["3.9", "3.10", "3.11", "3.12"]
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out repo
|
2024-04-29 11:28:46 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: Configure Python version
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python_version }}
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
python -m pip install -U build pip setuptools
|
|
|
|
python -m pip install -U -r requirements.txt
|
|
|
|
|
|
|
|
- name: Build sdist
|
|
|
|
run: |
|
|
|
|
python -m build --sdist
|
|
|
|
|
|
|
|
- name: Run mypy
|
|
|
|
run: |
|
|
|
|
python -m mypy spacy
|
2023-09-22 15:13:49 +00:00
|
|
|
if: matrix.python_version != '3.7'
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: Delete source directory and .egg-info
|
|
|
|
run: |
|
|
|
|
rm -rf spacy *.egg-info
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Uninstall all packages
|
|
|
|
run: |
|
|
|
|
python -m pip freeze
|
|
|
|
python -m pip freeze --exclude pywin32 > installed.txt
|
|
|
|
python -m pip uninstall -y -r installed.txt
|
|
|
|
|
|
|
|
- name: Install from sdist
|
|
|
|
run: |
|
|
|
|
SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1)
|
|
|
|
SPACY_NUM_BUILD_JOBS=2 python -m pip install dist/$SDIST
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Test import
|
|
|
|
run: python -W error -c "import spacy"
|
|
|
|
|
2023-08-09 11:43:50 +00:00
|
|
|
- name: "Test download CLI"
|
|
|
|
run: |
|
|
|
|
python -m spacy download ca_core_news_sm
|
|
|
|
python -m spacy download ca_core_news_md
|
|
|
|
python -c "import spacy; nlp=spacy.load('ca_core_news_sm'); doc=nlp('test')"
|
|
|
|
if: matrix.python_version == '3.9'
|
|
|
|
|
|
|
|
- name: "Test download_url in info CLI"
|
|
|
|
run: |
|
|
|
|
python -W error -m spacy info ca_core_news_sm | grep -q download_url
|
|
|
|
if: matrix.python_version == '3.9'
|
|
|
|
|
|
|
|
- name: "Test no warnings on load (#11713)"
|
|
|
|
run: |
|
|
|
|
python -W error -c "import ca_core_news_sm; nlp = ca_core_news_sm.load(); doc=nlp('test')"
|
|
|
|
if: matrix.python_version == '3.9'
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: "Test convert CLI"
|
|
|
|
run: |
|
|
|
|
python -m spacy convert extra/example_data/ner_example_data/ner-token-per-line-conll2003.json .
|
2023-03-13 14:14:46 +00:00
|
|
|
if: matrix.python_version == '3.9'
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: "Test debug config CLI"
|
|
|
|
run: |
|
|
|
|
python -m spacy init config -p ner -l ca ner.cfg
|
|
|
|
python -m spacy debug config ner.cfg --paths.train ner-token-per-line-conll2003.spacy --paths.dev ner-token-per-line-conll2003.spacy
|
2023-03-13 14:14:46 +00:00
|
|
|
if: matrix.python_version == '3.9'
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: "Test debug data CLI"
|
|
|
|
run: |
|
|
|
|
# will have errors due to sparse data, check for summary in output
|
|
|
|
python -m spacy debug data ner.cfg --paths.train ner-token-per-line-conll2003.spacy --paths.dev ner-token-per-line-conll2003.spacy | grep -q Summary
|
2023-03-13 14:14:46 +00:00
|
|
|
if: matrix.python_version == '3.9'
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: "Test train CLI"
|
|
|
|
run: |
|
|
|
|
python -m spacy train ner.cfg --paths.train ner-token-per-line-conll2003.spacy --paths.dev ner-token-per-line-conll2003.spacy --training.max_steps 10 --gpu-id -1
|
2023-03-13 14:14:46 +00:00
|
|
|
if: matrix.python_version == '3.9'
|
2023-03-13 12:13:47 +00:00
|
|
|
|
2023-08-09 11:43:50 +00:00
|
|
|
- name: "Test assemble CLI"
|
|
|
|
run: |
|
|
|
|
python -c "import spacy; config = spacy.util.load_config('ner.cfg'); config['components']['ner'] = {'source': 'ca_core_news_sm'}; config.to_disk('ner_source_sm.cfg')"
|
|
|
|
PYTHONWARNINGS="error,ignore::DeprecationWarning" python -m spacy assemble ner_source_sm.cfg output_dir
|
|
|
|
if: matrix.python_version == '3.9'
|
|
|
|
|
|
|
|
- name: "Test assemble CLI vectors warning"
|
|
|
|
run: |
|
|
|
|
python -c "import spacy; config = spacy.util.load_config('ner.cfg'); config['components']['ner'] = {'source': 'ca_core_news_md'}; config.to_disk('ner_source_md.cfg')"
|
|
|
|
python -m spacy assemble ner_source_md.cfg output_dir 2>&1 | grep -q W113
|
|
|
|
if: matrix.python_version == '3.9'
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: "Install test requirements"
|
|
|
|
run: |
|
|
|
|
python -m pip install -U -r requirements.txt
|
|
|
|
|
|
|
|
- name: "Run CPU tests"
|
|
|
|
run: |
|
|
|
|
python -m pytest --pyargs spacy -W error
|
2023-04-28 12:29:51 +00:00
|
|
|
if: "!(startsWith(matrix.os, 'macos') && matrix.python_version == '3.11')"
|
2023-03-13 12:13:47 +00:00
|
|
|
|
|
|
|
- name: "Run CPU tests with thinc-apple-ops"
|
|
|
|
run: |
|
|
|
|
python -m pip install 'spacy[apple]'
|
|
|
|
python -m pytest --pyargs spacy
|
2023-03-14 15:06:08 +00:00
|
|
|
if: startsWith(matrix.os, 'macos') && matrix.python_version == '3.11'
|