Skip to content

Commit e0e9d18

Browse files
authored
ci: try to fix test-full (#868)
* ci: try to fix test-full also use 3.12 to run full tests * fix mypy errors * hf: fix deprecated arguments in transformers.TrainingArguments * tests: adjust assertions in test_huggingface_log_model Due to huggingface/transformers#36219.
1 parent d23d73c commit e0e9d18

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,27 @@ jobs:
2727
- name: Set up Python
2828
uses: actions/setup-python@v5
2929
with:
30-
python-version: "3.9"
31-
cache: "pip"
32-
cache-dependency-path: setup.cfg
30+
python-version: "3.12"
3331

34-
- name: Upgrade pip
35-
run: |
36-
python -m pip install --upgrade pip wheel
37-
pip --version
32+
- uses: astral-sh/setup-uv@v6
33+
with:
34+
enable-cache: true
35+
cache-suffix: ${{ matrix.pyv }}
36+
cache-dependency-glob: pyproject.toml
3837

39-
- run: python -m pip install pre-commit
38+
- name: Full install
39+
run: uv pip install -e '.[dev]' --system
4040

4141
- uses: actions/cache@v4
4242
with:
4343
path: ~/.cache/pre-commit/
4444
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
4545

4646
- name: pre-commit
47-
run: |
48-
pre-commit run --show-diff-on-failure --color=always --all-files
49-
50-
- name: Full install
51-
run: pip install -e '.[dev]'
47+
run: uv tool run pre-commit run --show-diff-on-failure --color=always --all-files
5248

5349
- name: mypy
54-
run: |
55-
python -m mypy
50+
run: mypy
5651

5752
- name: Run tests
5853
run: pytest -v tests --cov --cov-report=xml --cov-config=pyproject.toml

examples/DVCLive-HuggingFace.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
"lr = 3e-4\n",
201201
"\n",
202202
"training_args = TrainingArguments(\n",
203-
" evaluation_strategy=\"epoch\",\n",
203+
" eval_strategy=\"epoch\",\n",
204204
" learning_rate=lr,\n",
205205
" logging_strategy=\"epoch\",\n",
206206
" num_train_epochs=5,\n",
@@ -243,7 +243,7 @@
243243
"lr = 1e-4\n",
244244
"\n",
245245
"training_args = TrainingArguments(\n",
246-
" evaluation_strategy=\"epoch\",\n",
246+
" eval_strategy=\"epoch\",\n",
247247
" learning_rate=lr,\n",
248248
" logging_strategy=\"epoch\",\n",
249249
" num_train_epochs=5,\n",

src/dvclive/fabric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def log_metrics(
9090

9191
for metric_name, metric_val in metrics.items():
9292
val = metric_val
93-
if is_tensor(val):
94-
val = val.cpu().detach().item() # type: ignore[union-attr]
93+
if is_tensor(val): # type: ignore[unreachable]
94+
val = val.cpu().detach().item() # type: ignore[union-attr,unreachable]
9595
name = standardize_metric_name(metric_name, __name__)
9696
if Metric.could_log(val):
9797
self.experiment.log_metric(name=name, val=val)

src/dvclive/huggingface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def on_save(
6262
**kwargs,
6363
):
6464
if self._log_model == "all" and state.is_world_process_zero:
65+
assert args.output_dir is not None # noqa: S101
6566
self.live.log_artifact(args.output_dir)
6667

6768
def on_train_end(
@@ -79,6 +80,7 @@ def on_train_end(
7980
eval_dataset=["fake"],
8081
)
8182
name = "best" if args.load_best_model_at_end else "last"
83+
assert args.output_dir is not None # noqa: S101
8284
output_dir = os.path.join(args.output_dir, name)
8385
fake_trainer.save_model(output_dir)
8486
self.live.log_artifact(output_dir, name=name, type="model", copy=True)

tests/frameworks/test_huggingface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def model():
9999
def args():
100100
return TrainingArguments(
101101
"foo",
102-
evaluation_strategy="epoch",
102+
eval_strategy="epoch",
103103
num_train_epochs=2,
104104
save_strategy="epoch",
105105
report_to="none", # Disable auto-reporting to avoid duplication
@@ -175,7 +175,7 @@ def test_huggingface_log_model(
175175
trainer.train()
176176

177177
expected_call_count = {
178-
"all": 3,
178+
"all": 2,
179179
True: 1,
180180
False: 0,
181181
None: 0,

0 commit comments

Comments
 (0)