Skip to content

Commit 7ca400b

Browse files
committed
pull dev
2 parents fd607ac + 86384cf commit 7ca400b

File tree

23 files changed

+673
-263
lines changed

23 files changed

+673
-263
lines changed

.github/workflows/build-docs.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,36 @@ jobs:
3636
with:
3737
python-version: "3.10"
3838

39-
- name: setup poetry
40-
run: |
41-
curl -sSL https://install.python-poetry.org | python -
39+
- name: Cache Hugging Face
40+
id: cache-hf
41+
uses: actions/cache@v4
42+
with:
43+
path: ~/.cache/huggingface
44+
key: docs-cache-hf
4245

4346
- name: Install pandoc
4447
run: |
4548
sudo apt install pandoc
4649
4750
- name: Install dependencies
4851
run: |
49-
poetry install --with docs
52+
pip install .[docs]
5053
5154
- name: Run tests
5255
if: github.event_name != 'workflow_dispatch'
5356
run: |
5457
echo "Testing documentation build..."
55-
make test-docs
58+
python -m sphinx build -b doctest docs/source docs/build/html
5659
5760
- name: Build documentation
5861
if: ${{ github.ref == 'refs/heads/dev' }} && github.event_name != 'workflow_dispatch'
5962
run: |
60-
make docs
63+
python -m sphinx build -b html docs/source docs/build/html
6164
6265
- name: build multiversion documentation
6366
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
6467
run: |
65-
make multi-version-docs
68+
sphinx-multiversion docs/source docs/build/html
6669
6770
- name: Deploy to GitHub Pages
6871
uses: peaceiris/actions-gh-pages@v3
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Reusable Test Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
test_command:
7+
required: true
8+
type: string
9+
description: 'Command to run tests'
10+
11+
jobs:
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ ubuntu-latest ]
18+
python-version: [ "3.10", "3.11", "3.12" ]
19+
include:
20+
- os: windows-latest
21+
python-version: "3.10"
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Cache Hugging Face
28+
id: cache-hf
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.cache/huggingface
32+
key: ${{ runner.os }}-hf
33+
34+
- name: Setup Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
cache: "pip"
39+
40+
- name: Install dependencies
41+
run: |
42+
pip install .[test]
43+
44+
- name: Run tests
45+
run: |
46+
${{ inputs.test_command }}

.github/workflows/test-inference.yaml

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
os: [ ubuntu-latest ]
16-
python-version: [ "3.10", "3.11", "3.12" ]
17-
include:
18-
- os: windows-latest
19-
python-version: "3.10"
20-
21-
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v4
24-
25-
- name: Setup Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: "pip"
30-
31-
- name: Install dependencies
32-
run: |
33-
pip install .
34-
pip install pytest pytest-asyncio
35-
36-
- name: Run tests
37-
run: |
38-
pytest tests/pipeline/test_inference.py
11+
uses: ./.github/workflows/reusable-test.yaml
12+
with:
13+
test_command: pytest -n auto tests/pipeline/test_inference.py

.github/workflows/test-nodes.yaml

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
os: [ ubuntu-latest ]
16-
python-version: [ "3.10", "3.11", "3.12" ]
17-
include:
18-
- os: windows-latest
19-
python-version: "3.10"
20-
21-
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v4
24-
25-
- name: Setup Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: "pip"
30-
31-
- name: Install dependencies
32-
run: |
33-
pip install .
34-
pip install pytest pytest-asyncio
35-
36-
- name: Run tests
37-
run: |
38-
pytest tests/nodes
11+
uses: ./.github/workflows/reusable-test.yaml
12+
with:
13+
test_command: pytest -n auto tests/nodes

.github/workflows/test-optimization.yaml

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
os: [ ubuntu-latest ]
16-
python-version: [ "3.10", "3.11", "3.12" ]
17-
include:
18-
- os: windows-latest
19-
python-version: "3.10"
20-
21-
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v4
24-
25-
- name: Setup Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: "pip"
30-
31-
- name: Install dependencies
32-
run: |
33-
pip install .
34-
pip install pytest pytest-asyncio
35-
36-
- name: Run tests
37-
run: |
38-
pytest tests/pipeline/test_optimization.py
11+
uses: ./.github/workflows/reusable-test.yaml
12+
with:
13+
test_command: pytest -n auto tests/pipeline/test_optimization.py

.github/workflows/test-presets.yaml

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
os: [ ubuntu-latest ]
16-
python-version: [ "3.10", "3.11", "3.12" ]
17-
include:
18-
- os: windows-latest
19-
python-version: "3.10"
20-
21-
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v4
24-
25-
- name: Setup Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: "pip"
30-
31-
- name: Install dependencies
32-
run: |
33-
pip install .
34-
pip install pytest pytest-asyncio
35-
36-
- name: Run tests
37-
run: |
38-
pytest tests/pipeline/test_presets.py
11+
uses: ./.github/workflows/reusable-test.yaml
12+
with:
13+
test_command: pytest -n auto tests/pipeline/test_presets.py

.github/workflows/typing.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@ jobs:
1111
python-version: "3.10"
1212
cache: "pip"
1313

14-
- name: Install Poetry
15-
run: |
16-
curl -sSL https://install.python-poetry.org | python3 -
17-
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
18-
1914
- name: Install dependencies
2015
run: |
21-
poetry install --with typing
16+
pip install .[typing]
2217
2318
- name: Run mypy
24-
run: make typing
19+
run: mypy autointent

.github/workflows/unit-tests.yaml

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,6 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
os: [ ubuntu-latest ]
16-
python-version: [ "3.10", "3.11", "3.12" ]
17-
include:
18-
- os: windows-latest
19-
python-version: "3.10"
20-
21-
steps:
22-
- name: Checkout code
23-
uses: actions/checkout@v4
24-
25-
- name: Setup Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
cache: "pip"
30-
31-
- name: Install dependencies
32-
run: |
33-
pip install .
34-
pip install pytest pytest-asyncio
35-
36-
- name: Run tests
37-
run: |
38-
pytest --ignore=tests/nodes --ignore=tests/pipeline
11+
uses: ./.github/workflows/reusable-test.yaml
12+
with:
13+
test_command: pytest -n auto --ignore=tests/nodes --ignore=tests/pipeline

autointent/modules/__init__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,25 @@ def _create_modules_dict(modules: list[type[T]]) -> dict[str, type[T]]:
5454
)
5555

5656

57-
__all__ = [] # type: ignore[var-annotated]
57+
__all__ = [
58+
"AdaptiveDecision",
59+
"ArgmaxDecision",
60+
"BaseDecision",
61+
"BaseEmbedding",
62+
"BaseModule",
63+
"BaseRegex",
64+
"BaseScorer",
65+
"DNNCScorer",
66+
"DescriptionScorer",
67+
"JinoosDecision",
68+
"KNNScorer",
69+
"LinearScorer",
70+
"LogregAimedEmbedding",
71+
"MLKnnScorer",
72+
"RerankScorer",
73+
"RetrievalAimedEmbedding",
74+
"SimpleRegex",
75+
"SklearnScorer",
76+
"ThresholdDecision",
77+
"TunableDecision",
78+
]

autointent/modules/scoring/_bert.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ class BertScorer(BaseScorer):
3131

3232
def __init__(
3333
self,
34-
model_config: HFModelConfig | str | dict[str, Any] | None = None,
34+
classification_model_config: HFModelConfig | str | dict[str, Any] | None = None,
3535
num_train_epochs: int = 3,
3636
batch_size: int = 8,
3737
learning_rate: float = 5e-5,
3838
seed: int = 0,
3939
report_to: REPORTERS_NAMES | None = None, # type: ignore # noqa: PGH003
4040
) -> None:
41-
self.model_config = HFModelConfig.from_search_config(model_config)
41+
self.classification_model_config = HFModelConfig.from_search_config(classification_model_config)
4242
self.num_train_epochs = num_train_epochs
4343
self.batch_size = batch_size
4444
self.learning_rate = learning_rate
@@ -49,19 +49,19 @@ def __init__(
4949
def from_context(
5050
cls,
5151
context: Context,
52-
model_config: HFModelConfig | str | dict[str, Any] | None = None,
52+
classification_model_config: HFModelConfig | str | dict[str, Any] | None = None,
5353
num_train_epochs: int = 3,
5454
batch_size: int = 8,
5555
learning_rate: float = 5e-5,
5656
seed: int = 0,
5757
) -> "BertScorer":
58-
if model_config is None:
59-
model_config = context.resolve_embedder()
58+
if classification_model_config is None:
59+
classification_model_config = context.resolve_embedder()
6060

6161
report_to = context.logging_config.report_to
6262

6363
return cls(
64-
model_config=model_config,
64+
classification_model_config=classification_model_config,
6565
num_train_epochs=num_train_epochs,
6666
batch_size=batch_size,
6767
learning_rate=learning_rate,
@@ -70,7 +70,7 @@ def from_context(
7070
)
7171

7272
def get_embedder_config(self) -> dict[str, Any]:
73-
return self.model_config.model_dump()
73+
return self.classification_model_config.model_dump()
7474

7575
def fit(
7676
self,
@@ -81,7 +81,7 @@ def fit(
8181
self.clear_cache()
8282
self._validate_task(labels)
8383

84-
model_name = self.model_config.model_name
84+
model_name = self.classification_model_config.model_name
8585
self._tokenizer = AutoTokenizer.from_pretrained(model_name)
8686

8787
label2id = {i: i for i in range(self._n_classes)}
@@ -95,11 +95,11 @@ def fit(
9595
problem_type="multi_label_classification" if self._multilabel else "single_label_classification",
9696
)
9797

98-
use_cpu = self.model_config.device == "cpu"
98+
use_cpu = self.classification_model_config.device == "cpu"
9999

100100
def tokenize_function(examples: dict[str, Any]) -> dict[str, Any]:
101101
return self._tokenizer( # type: ignore[no-any-return]
102-
examples["text"], return_tensors="pt", **self.model_config.tokenizer_config.model_dump()
102+
examples["text"], return_tensors="pt", **self.classification_model_config.tokenizer_config.model_dump()
103103
)
104104

105105
dataset = Dataset.from_dict({"text": utterances, "labels": labels})
@@ -148,7 +148,9 @@ def predict(self, utterances: list[str]) -> npt.NDArray[Any]:
148148
all_predictions = []
149149
for i in range(0, len(utterances), self.batch_size):
150150
batch = utterances[i : i + self.batch_size]
151-
inputs = self._tokenizer(batch, return_tensors="pt", **self.model_config.tokenizer_config.model_dump())
151+
inputs = self._tokenizer(
152+
batch, return_tensors="pt", **self.classification_model_config.tokenizer_config.model_dump()
153+
)
152154
inputs = {k: v.to(device) for k, v in inputs.items()}
153155
with torch.no_grad():
154156
outputs = self._model(**inputs)

0 commit comments

Comments
 (0)