Skip to content

Commit 69cc206

Browse files
committed
test on 3.11
We don't have aiohttp support yet, due to which we have to install without cythonized extension. Similarly, hydra does not yet support 3.11 (given it's track record, it'll be almost a year we'll see the wheels for it). dvc-hdfs/pyarrow is not there yet, we'll usually see a release 2-3 months after official reelase. dvc-hdfs is skipped in 3.11 in extras_requires. `--set-params` fails with hydra being not available.
1 parent b376044 commit 69cc206

File tree

9 files changed

+56
-11
lines changed

9 files changed

+56
-11
lines changed

.github/workflows/tests.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
matrix:
4444
os: [ubuntu-20.04, windows-latest, macos-latest]
4545
pyv: ["3.8", "3.9", "3.10"]
46+
include:
47+
- {os: ubuntu-latest, pyv: "3.11-dev"}
48+
4649
steps:
4750
- uses: actions/checkout@v3
4851
with:
@@ -68,6 +71,8 @@ jobs:
6871
run: |
6972
pip install --upgrade pip setuptools wheel
7073
pip install -e ".[dev]"
74+
env:
75+
AIOHTTP_NO_EXTENSIONS: ${{ matrix.pyv == '3.11-dev' && '1' }}
7176
- name: run tests
7277
timeout-minutes: 40
7378
run: >-

dvc/repo/experiments/queue/base.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
import sys
34
from abc import ABC, abstractmethod
45
from dataclasses import asdict, dataclass
56
from typing import (
@@ -524,7 +525,12 @@ def _update_params(self, params: Dict[str, List[str]]):
524525
"""
525526
logger.debug("Using experiment params '%s'", params)
526527

527-
from dvc.utils.hydra import apply_overrides
528+
try:
529+
from dvc.utils.hydra import apply_overrides
530+
except ImportError:
531+
if sys.version_info >= (3, 11):
532+
logger.error("`--set-param` is not supported in Python>=3.11")
533+
raise
528534

529535
for path, overrides in params.items():
530536
apply_overrides(path, overrides)

pyproject.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ log_level = "debug"
3333
addopts = "-ra"
3434
markers = [
3535
"needs_internet: Might need network access for the tests",
36-
"vscode: Tests verifying contract between DVC and VSCode plugin",
37-
"studio: Tests verifying contract between DVC and Studio"
36+
"vscode: Tests verifying contract between DVC and VSCode plugin",
37+
"studio: Tests verifying contract between DVC and Studio",
38+
"requires_hydra: Tests need hydra and will be skipped if not installed",
3839
]
3940
xfail_strict = true
4041

setup.cfg

+3-5
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@ install_requires =
6262
rich>=10.13.0
6363
pyparsing>=2.4.7
6464
typing-extensions>=3.7.4
65-
fsspec[http]>=2021.10.1
66-
aiohttp-retry>=2.4.5
6765
scmrepo==0.0.25
6866
dvc-render==0.0.9
6967
dvc-task==0.1.2
7068
dvclive>=0.10.0
7169
dvc-data==0.2.0
72-
dvc-http==2.19.0
73-
hydra-core>=1.1.0
70+
dvc-http==2.19.1
71+
hydra-core>=1.1.0; python_version < '3.11'
7472

7573
[options.extras_require]
7674
all =
@@ -91,7 +89,7 @@ dev =
9189
azure = dvc-azure==2.19.0
9290
gdrive = dvc-gdrive==2.19.0
9391
gs = dvc-gs==2.19.0
94-
hdfs = dvc-hdfs==2.19.0
92+
hdfs = dvc-hdfs==2.19.0; python_version < '3.11'
9593
oss = dvc-oss==2.19.0
9694
s3 = dvc-s3==2.19.0
9795
ssh = dvc-ssh==2.19.0

tests/conftest.py

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def pytest_runtest_setup(item):
127127
# so we rerun them in case it fails.
128128
item.add_marker(pytest.mark.flaky(max_runs=5, min_passes=1))
129129

130+
if "requires_hydra" in item.keywords:
131+
pytest.importorskip("hydra")
132+
130133

131134
@pytest.fixture(scope="session")
132135
def test_config(request):

tests/func/experiments/conftest.py

+19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1+
import sys
12
from textwrap import dedent
23

34
import pytest
45

56
from tests.func.test_repro_multistage import COPY_SCRIPT
67
from tests.unit.repo.experiments.conftest import test_queue # noqa
78

9+
10+
@pytest.fixture(autouse=True)
11+
def mock_dvc_exp_run(mocker):
12+
from dvc.repo.experiments.queue.base import BaseStashQueue
13+
14+
original = BaseStashQueue._update_params
15+
16+
def update_params(*args):
17+
if sys.version_info >= (3, 11):
18+
pytest.importorskip("hydra")
19+
return original(*args)
20+
21+
mocker.patch(
22+
"dvc.repo.experiments.queue.base.BaseStashQueue._update_params",
23+
wraps=update_params,
24+
)
25+
26+
827
DEFAULT_ITERATIONS = 2
928
CHECKPOINT_SCRIPT_FORMAT = dedent(
1029
"""\

tests/func/test_live.py

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def test_live_provides_metrics(tmp_dir, dvc, live_stage):
127127
assert "logs/images/1/image.jpg" in files
128128

129129

130+
@pytest.mark.requires_hydra
130131
@pytest.mark.parametrize("typ", ("live", "live_no_cache"))
131132
def test_experiments_track_summary(tmp_dir, scm, dvc, live_stage, typ):
132133
live_stage(**{typ: "logs"})
@@ -188,6 +189,7 @@ def checkpoints_metric(show_results, metric_file, metric_name):
188189
]
189190

190191

192+
@pytest.mark.requires_hydra
191193
@pytest.mark.parametrize("typ", ("live", "live_no_cache"))
192194
def test_live_checkpoints_resume(
193195
tmp_dir, scm, dvc, live_checkpoint_stage, typ

tests/func/utils/test_hydra.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import pytest
22

33
from dvc.exceptions import InvalidArgumentError
4-
from dvc.utils.hydra import apply_overrides
4+
5+
pytest.importorskip("hydra")
56

67

78
@pytest.mark.parametrize("suffix", ["yaml", "toml", "json"])
@@ -90,6 +91,8 @@
9091
],
9192
)
9293
def test_apply_overrides(tmp_dir, suffix, overrides, expected):
94+
from dvc.utils.hydra import apply_overrides
95+
9396
if suffix == "toml":
9497
if overrides in [
9598
["foo=baz"],
@@ -114,6 +117,8 @@ def test_apply_overrides(tmp_dir, suffix, overrides, expected):
114117
[["foobar=2"], ["lorem=3,2"], ["+lorem=3"], ["foo[0]=bar"]],
115118
)
116119
def test_invalid_overrides(tmp_dir, overrides):
120+
from dvc.utils.hydra import apply_overrides
121+
117122
params_file = tmp_dir / "params.yaml"
118123
params_file.dump(
119124
{"foo": [{"bar": 1}, {"baz": 2}], "goo": {"bag": 3.0}, "lorem": False}

tests/unit/fs/test_fs.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
import pytest
2-
from dvc_hdfs import HDFSFileSystem
32
from dvc_http import HTTPFileSystem, HTTPSFileSystem
43
from dvc_s3 import S3FileSystem
54
from dvc_ssh import SSHFileSystem
65

76
from dvc.config import RemoteNotFoundError
87
from dvc.fs import LocalFileSystem, get_fs_cls, get_fs_config
98

9+
try:
10+
from dvc_hdfs import HDFSFileSystem
11+
except ImportError:
12+
url_cls_pairs = []
13+
else:
14+
url_cls_pairs = [("hdfs://example.com/dir/path", HDFSFileSystem)]
15+
1016

1117
@pytest.mark.parametrize(
1218
"url, cls",
1319
[
20+
*url_cls_pairs,
1421
("s3://bucket/path", S3FileSystem),
1522
("ssh://example.com:/dir/path", SSHFileSystem),
16-
("hdfs://example.com/dir/path", HDFSFileSystem),
1723
("http://example.com/path/to/file", HTTPFileSystem),
1824
("https://example.com/path/to/file", HTTPSFileSystem),
1925
("path/to/file", LocalFileSystem),

0 commit comments

Comments
 (0)