Commit 6b174ca
committed
standartize pyproject & speedup tests (#176)
* speedup tests
* fix pyproject
* Update optimizer_config.schema.json
* move optional dependencies
* fixes
* add xdist
* fix ci
* download data from hub in doc
* add caching
* add doc cache
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: voorhs <[email protected]>
# Conflicts:
# pyproject.toml
diff --git c/.github/workflows/build-docs.yaml i/.github/workflows/build-docs.yaml
index 82a6896..c9d2d31 100644
--- c/.github/workflows/build-docs.yaml
+++ i/.github/workflows/build-docs.yaml
@@ -36,9 +36,12 @@ jobs:
with:
python-version: "3.10"
- - name: setup poetry
- run: |
- curl -sSL https://install.python-poetry.org | python -
+ - name: Cache Hugging Face
+ id: cache-hf
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/huggingface
+ key: docs-cache-hf
- name: Install pandoc
run: |
@@ -46,23 +49,23 @@ jobs:
- name: Install dependencies
run: |
- poetry install --with docs
+ pip install .[docs]
- name: Run tests
if: github.event_name != 'workflow_dispatch'
run: |
echo "Testing documentation build..."
- make test-docs
+ python -m sphinx build -b doctest docs/source docs/build/html
- name: Build documentation
if: ${{ github.ref == 'refs/heads/dev' }} && github.event_name != 'workflow_dispatch'
run: |
- make docs
+ python -m sphinx build -b html docs/source docs/build/html
- name: build multiversion documentation
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
- make multi-version-docs
+ sphinx-multiversion docs/source docs/build/html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
diff --git c/.github/workflows/reusable-test.yaml i/.github/workflows/reusable-test.yaml
new file mode 100644
index 00000000..ac8f0b1
--- /dev/null
+++ i/.github/workflows/reusable-test.yaml
@@ -0,0 +1,46 @@
+name: Reusable Test Workflow
+
+on:
+ workflow_call:
+ inputs:
+ test_command:
+ required: true
+ type: string
+ description: 'Command to run tests'
+
+jobs:
+ test:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ ubuntu-latest ]
+ python-version: [ "3.10", "3.11", "3.12" ]
+ include:
+ - os: windows-latest
+ python-version: "3.10"
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Cache Hugging Face
+ id: cache-hf
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/huggingface
+ key: ${{ runner.os }}-hf
+
+ - name: Setup Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v5
+ with:
+ python-version: ${{ matrix.python-version }}
+ cache: "pip"
+
+ - name: Install dependencies
+ run: |
+ pip install .[test]
+
+ - name: Run tests
+ run: |
+ ${{ inputs.test_command }}
\ No newline at end of file
diff --git c/.github/workflows/test-inference.yaml i/.github/workflows/test-inference.yaml
index a68ef07..d89e450 100644
--- c/.github/workflows/test-inference.yaml
+++ i/.github/workflows/test-inference.yaml
@@ -8,31 +8,6 @@ on:
jobs:
test:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os: [ ubuntu-latest ]
- python-version: [ "3.10", "3.11", "3.12" ]
- include:
- - os: windows-latest
- python-version: "3.10"
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Setup Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
- with:
- python-version: ${{ matrix.python-version }}
- cache: "pip"
-
- - name: Install dependencies
- run: |
- pip install .
- pip install pytest pytest-asyncio
-
- - name: Run tests
- run: |
- pytest tests/pipeline/test_inference.py
+ uses: ./.github/workflows/reusable-test.yaml
+ with:
+ test_command: pytest -n auto tests/pipeline/test_inference.py
diff --git c/.github/workflows/test-nodes.yaml i/.github/workflows/test-nodes.yaml
index b101617..c191491 100644
--- c/.github/workflows/test-nodes.yaml
+++ i/.github/workflows/test-nodes.yaml
@@ -8,31 +8,6 @@ on:
jobs:
test:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os: [ ubuntu-latest ]
- python-version: [ "3.10", "3.11", "3.12" ]
- include:
- - os: windows-latest
- python-version: "3.10"
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Setup Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
- with:
- python-version: ${{ matrix.python-version }}
- cache: "pip"
-
- - name: Install dependencies
- run: |
- pip install .
- pip install pytest pytest-asyncio
-
- - name: Run tests
- run: |
- pytest tests/nodes
+ uses: ./.github/workflows/reusable-test.yaml
+ with:
+ test_command: pytest -n auto tests/nodes
diff --git c/.github/workflows/test-optimization.yaml i/.github/workflows/test-optimization.yaml
index 4625f39..ad3168d 100644
--- c/.github/workflows/test-optimization.yaml
+++ i/.github/workflows/test-optimization.yaml
@@ -8,31 +8,6 @@ on:
jobs:
test:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os: [ ubuntu-latest ]
- python-version: [ "3.10", "3.11", "3.12" ]
- include:
- - os: windows-latest
- python-version: "3.10"
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Setup Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
- with:
- python-version: ${{ matrix.python-version }}
- cache: "pip"
-
- - name: Install dependencies
- run: |
- pip install .
- pip install pytest pytest-asyncio
-
- - name: Run tests
- run: |
- pytest tests/pipeline/test_optimization.py
+ uses: ./.github/workflows/reusable-test.yaml
+ with:
+ test_command: pytest -n auto tests/pipeline/test_optimization.py
diff --git c/.github/workflows/test-presets.yaml i/.github/workflows/test-presets.yaml
index ab4a672..836c58f 100644
--- c/.github/workflows/test-presets.yaml
+++ i/.github/workflows/test-presets.yaml
@@ -8,31 +8,6 @@ on:
jobs:
test:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os: [ ubuntu-latest ]
- python-version: [ "3.10", "3.11", "3.12" ]
- include:
- - os: windows-latest
- python-version: "3.10"
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Setup Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
- with:
- python-version: ${{ matrix.python-version }}
- cache: "pip"
-
- - name: Install dependencies
- run: |
- pip install .
- pip install pytest pytest-asyncio
-
- - name: Run tests
- run: |
- pytest tests/pipeline/test_presets.py
+ uses: ./.github/workflows/reusable-test.yaml
+ with:
+ test_command: pytest -n auto tests/pipeline/test_presets.py
diff --git c/.github/workflows/typing.yml i/.github/workflows/typing.yml
index eb0c374..dfe873e 100644
--- c/.github/workflows/typing.yml
+++ i/.github/workflows/typing.yml
@@ -11,14 +11,9 @@ jobs:
python-version: "3.10"
cache: "pip"
- - name: Install Poetry
- run: |
- curl -sSL https://install.python-poetry.org | python3 -
- echo "$HOME/.poetry/bin" >> $GITHUB_PATH
-
- name: Install dependencies
run: |
- poetry install --with typing
+ pip install .[typing]
- name: Run mypy
- run: make typing
+ run: mypy autointent
diff --git c/.github/workflows/unit-tests.yaml i/.github/workflows/unit-tests.yaml
index 5883080..4d8164f 100644
--- c/.github/workflows/unit-tests.yaml
+++ i/.github/workflows/unit-tests.yaml
@@ -8,31 +8,6 @@ on:
jobs:
test:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- matrix:
- os: [ ubuntu-latest ]
- python-version: [ "3.10", "3.11", "3.12" ]
- include:
- - os: windows-latest
- python-version: "3.10"
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Setup Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
- with:
- python-version: ${{ matrix.python-version }}
- cache: "pip"
-
- - name: Install dependencies
- run: |
- pip install .
- pip install pytest pytest-asyncio
-
- - name: Run tests
- run: |
- pytest --ignore=tests/nodes --ignore=tests/pipeline
+ uses: ./.github/workflows/reusable-test.yaml
+ with:
+ test_command: pytest -n auto --ignore=tests/nodes --ignore=tests/pipeline
diff --git c/pyproject.toml i/pyproject.toml
index ab78c4d..0994407 100644
--- c/pyproject.toml
+++ i/pyproject.toml
@@ -48,6 +48,44 @@ dependencies = [
"codecarbon (==2.6)",
]
+[project.optional-dependencies]
+dev = [
+ "tach (>=0.11.3,<1.0.0)",
+ "ipykernel (>=6.29.5,<7.0.0)",
+ "ipywidgets (>=8.1.5,<9.0.0)",
+ "ruff (==0.8.4)",
+]
+test = [
+ "pytest (>=8.3.2,<9.0.0)",
+ "pytest-cov (>=5.0.0,<6.0.0)",
+ "coverage (>=7.6.1,<8.0.0)",
+ "pytest-asyncio (>=0.24.0,<1.0.0)",
+ "pytest-rerunfailures (>=15.0,<16.0)",
+ "pytest-xdist (>=3.6.1,<4.0.0)",
+]
+typing = [
+ "mypy (>=1,<2)",
+ "types-pyyaml (>=6.0.12.20240917,<7.0.0)",
+ "types-pygments (>=2.18.0.20240506,<3.0.0)",
+ "types-setuptools (>=75.2.0.20241019,<76.0.0)",
+ "joblib-stubs (>=1.4.2.5.20240918,<2.0.0)",
+]
+docs = [
+ "sphinx (>=8.1.3,<9.0.0)",
+ "pydata-sphinx-theme (>=0.16.0,<1.0.0)",
+ "jupytext (>=1.16.4,<2.0.0)",
+ "nbsphinx (>=0.9.5,<1.0.0)",
+ "sphinx-autodoc-typehints (>=2.5.0,<3.0.0)",
+ "sphinx-copybutton (>=0.5.2,<1.0.0)",
+ "sphinx-autoapi (>=3.3.3,<4.0.0)",
+ "ipykernel (>=6.29.5,<7.0.0)",
+ "tensorboardx (>=2.6.2.2,<3.0.0)",
+ "sphinx-multiversion (>=0.2.4,<1.0.0)",
+]
+dspy = [
+ "dspy (>=2.6.5,<3.0.0)",
+]
+
[project.urls]
Homepage = "https://deeppavlov.github.io/AutoIntent/"
Repository = "https://github.com/deeppavlov/AutoIntent"
@@ -57,56 +95,6 @@ Documentation = "https://deeppavlov.github.io/AutoIntent/"
"basic-aug" = "autointent.generation.utterances.basic.cli:main"
"evolution-aug" = "autointent.generation.utterances.evolution.cli:main"
-[tool.poetry.group.dev]
-optional = true
-
-[tool.poetry.group.dev.dependencies]
-ipykernel = "^6.29.5"
-ipywidgets = "^8.1.5"
-ruff = "==0.8.4"
-
-[tool.poetry.group.test]
-optional = true
-
-[tool.poetry.group.test.dependencies]
-pytest = "8.3.2"
-pytest-cov = "^5.0.0"
-coverage = "^7.6.1"
-pytest-asyncio = "^0.24.0"
-
-[tool.poetry.group.typing]
-optional = true
-
-[tool.poetry.group.typing.dependencies]
-mypy = "^1"
-types-pyyaml = "^6.0.12.20240917"
-types-pygments = "^2.18.0.20240506"
-types-setuptools = "^75.2.0.20241019"
-joblib-stubs = "^1.4.2.5.20240918"
-
-[tool.poetry.group.docs]
-optional = true
-
-[tool.poetry.group.docs.dependencies]
-sphinx = "^8.1.3"
-pydata-sphinx-theme = "^0.16.0"
-jupytext = "^1.16.4"
-nbsphinx = "^0.9.5"
-sphinx-autodoc-typehints = "^2.5.0"
-sphinx-copybutton = "^0.5.2"
-sphinx-autoapi = "^3.3.3"
-ipykernel = "^6.29.5"
-tensorboardx = "^2.6.2.2"
-sphinx-multiversion = "^0.2.4"
-
-[tool.poetry.group.dspy]
-optional = true
-
-
-[tool.poetry.group.dspy.dependencies]
-dspy = "^2.6.5"
-
-
[tool.ruff]
line-length = 120
indent-width = 4
@@ -148,11 +136,28 @@ build-backend = "poetry.core.masonry.api"
[tool.pytest.ini_options]
minversion = "8.0"
-addopts = "-ra" # `--cov` option breaks pycharm's test debugger
testpaths = [
"tests",
]
pythonpath = "autointent"
+# `--cov` option breaks pycharm's test debugger
+addopts = """
+ -ra
+ --reruns 3
+ --only-rerun requests.exceptions.ReadTimeout
+ --only-rerun huggingface_hub.errors.HfHubHTTPError
+ --only-rerun huggingface_hub.errors.LocalEntryNotFoundError
+ --only-rerun FileNotFoundError
+ --only-rerun OSError
+ --durations 5
+ --reruns-delay 10
+"""
+# --reruns 3 -> # Retry failed tests 3 times
+# requests.exceptions.ReadTimeout -> # HF Read timed out
+# huggingface_hub.errors.HfHubHTTPError -> # HF is unavailable
+# huggingface_hub.errors.LocalEntryNotFoundError -> # Gateway Time-out from HF
+# FileNotFoundError -> HF Cache is broken
+# --reruns-delay 10 -> Delay between reruns in seconds to avoid running into the same issue again
[tool.coverage.run]
branch = true
diff --git c/user_guides/advanced/01_data.py i/user_guides/advanced/01_data.py
index 27314a8..5177877 100644
--- c/user_guides/advanced/01_data.py
+++ i/user_guides/advanced/01_data.py
@@ -6,9 +6,8 @@ This chapter is a more detailed version of data chapter from basic user guide ab
"""
# %%
-import importlib.resources as ires
-
import datasets
+import huggingface_hub
from autointent import Dataset
@@ -180,7 +179,11 @@ The AutoIntent library includes sample datasets.
"""
# %%
-path_to_dataset = ires.files("tests.assets.data").joinpath("clinc_subset.json")
+path_to_dataset = huggingface_hub.hf_hub_download(
+ repo_id="DeepPavlov/clinc150_subset",
+ filename="clinc_subset.json",
+ repo_type="dataset",
+)
dataset = Dataset.from_json(path_to_dataset)
# %% [markdown]
diff --git c/user_guides/basic_usage/01_data.py i/user_guides/basic_usage/01_data.py
index a03f39b..f56294a 100644
--- c/user_guides/basic_usage/01_data.py
+++ i/user_guides/basic_usage/01_data.py
@@ -6,9 +6,8 @@ In this chapter you will learn how to manipulate intent classification data with
"""
# %%
-import importlib.resources as ires
-
import datasets
+import huggingface_hub
from autointent import Dataset
@@ -53,7 +52,11 @@ After you converted your labeled data into JSON, you can load it into AutoIntent
"""
# %%
-path_to_dataset = ires.files("tests.assets.data").joinpath("clinc_subset_unsplitted.json")
+path_to_dataset = huggingface_hub.hf_hub_download(
+ repo_id="DeepPavlov/clinc150_subset",
+ filename="clinc_subset_unsplitted.json",
+ repo_type="dataset",
+)
dataset = Dataset.from_json(path_to_dataset)
# %% [markdown]1 parent b9f81e5 commit 6b174ca
File tree
11 files changed
+141
-211
lines changed- .github/workflows
- user_guides
- advanced
- basic_usage
11 files changed
+141
-211
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
49 | | - | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
55 | | - | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
60 | | - | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
65 | | - | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | 14 | | |
20 | 15 | | |
21 | | - | |
| 16 | + | |
22 | 17 | | |
23 | 18 | | |
24 | | - | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments