Skip to content

Commit 7a17a2b

Browse files
committed
Test for deprecation warnings
1 parent 63279ab commit 7a17a2b

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

kernels/tests/test_func.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pathlib import Path
2+
13
import pytest
24
import torch
35
import torch.nn.functional as F
@@ -15,6 +17,7 @@
1517
use_kernel_mapping,
1618
use_kernelized_func,
1719
)
20+
from kernels.layer.func import LockedFuncRepository
1821

1922

2023
# A function + layer that we can map arbitrary functions to for testing.
@@ -38,6 +41,7 @@ def identity(x):
3841
assert isinstance(identity, nn.Module)
3942

4043

44+
@pytest.mark.filterwarnings("ignore:.*will be removed in kernels 0.17:DeprecationWarning")
4145
def test_deprecated_decorator():
4246
@use_kernel_func_from_hub("identity_func")
4347
def identity(x):
@@ -47,11 +51,13 @@ def identity(x):
4751
assert isinstance(identity, nn.Module)
4852

4953

54+
@pytest.mark.filterwarnings("ignore:.*will be removed in kernels 0.17:DeprecationWarning")
5055
def test_deprecated_func_repository_requires_version_or_revision():
5156
with pytest.raises(ValueError, match="Either a revision or a version must be specified"):
5257
FuncRepository("kernels-test/flattened-build", func_name="silu_and_mul")
5358

5459

60+
@pytest.mark.filterwarnings("ignore:.*will be removed in kernels 0.17:DeprecationWarning")
5561
def test_deprecated_func_repository(device):
5662
model = SurpriseMe()
5763

@@ -110,6 +116,7 @@ def test_kernel_func_with_layer():
110116
assert model(x) is x
111117

112118

119+
@pytest.mark.filterwarnings("ignore:.*will be removed in kernels 0.17:DeprecationWarning")
113120
def test_deprecated_local_kernel_func(device):
114121
model = SurpriseMe()
115122

@@ -138,6 +145,32 @@ def test_deprecated_local_kernel_func(device):
138145
assert model(x) is x
139146

140147

148+
def test_deprecated_kernel_func():
149+
with pytest.deprecated_call(match="kernels 0.17"):
150+
FuncRepository("kernels-test/flattened-build", func_name="silu_and_mul", version=1)
151+
152+
project_dir = Path(__file__).parent / "layer_locking"
153+
with pytest.deprecated_call(match="kernels 0.17"):
154+
LockedFuncRepository(
155+
"kernels-test/versions",
156+
func_name="version",
157+
lockfile=project_dir / "kernels.lock",
158+
)
159+
160+
with pytest.deprecated_call(match="kernels 0.17"):
161+
LocalFuncRepository(
162+
# We are never loading the kernel, so we can just use an invalid path.
163+
repo_path=Path("."),
164+
func_name="silu_and_mul",
165+
)
166+
167+
with pytest.deprecated_call(match="kernels 0.17"):
168+
169+
@use_kernel_func_from_hub("deprecated")
170+
def deprecated_func(x):
171+
return x
172+
173+
141174
def test_use_kernelized_func_used_on_non_kernelized_func():
142175
def not_kernelized(x):
143176
return x

0 commit comments

Comments
 (0)