Skip to content

Commit de56169

Browse files
committed
fix: skip GPU-dependent tests in CI and fix conftest loading
1 parent 09e57f2 commit de56169

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ jobs:
9191
#
9292
- name: PKG-TEST
9393
run: |
94-
uv run pytest --noconftest -m "not requires_data" tests
94+
uv run pytest -m "not requires_data and not requires_gpu" tests

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
3232
- name: Run tests
3333
run: |
34-
uv run pytest tests
34+
uv run pytest -m "not requires_data and not requires_gpu" tests
3535
3636
- name: Build and deploy docs
3737
run: |

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ collect_ignore = [] # 之前setup.py已删除,保留配置项以备将来使
157157
markers = [
158158
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
159159
"requires_data: marks tests that require downloading external data",
160+
"requires_gpu: marks tests that require GPU/CUDA (deselect with '-m \"not requires_gpu\"')",
160161
]
161162

162163
# black 代码格式化配置

tests/test_cudnnlstm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from torchhydro.models.cudnnlstm import CudnnLstmModel, CudnnLstm
1515

1616

17+
@pytest.mark.requires_gpu
1718
def test_mc_dropout_eval():
1819
# Monte Carlo Dropout sampling during evaluation
1920
model = CudnnLstmModel(
@@ -128,6 +129,7 @@ def test_reset_mask_with_zero_dropout():
128129
), "mask_w_hh should have the same shape as w_hh"
129130

130131

132+
@pytest.mark.requires_gpu
131133
def test_forward_with_mc_dropout():
132134
model = CudnnLstm(input_size=10, hidden_size=20, dr=0.5)
133135
model = model.to("cuda:0")
@@ -141,6 +143,7 @@ def test_forward_with_mc_dropout():
141143
assert cy.shape == (1, 5, 20), "Cell state shape mismatch"
142144

143145

146+
@pytest.mark.requires_gpu
144147
def test_forward_with_dropout():
145148
model = CudnnLstm(input_size=10, hidden_size=20, dr=0.5)
146149
input_data = torch.randn(20, 5, 10) # [seq_len, batch_size, input_size]
@@ -154,6 +157,7 @@ def test_forward_with_dropout():
154157
assert cy.shape == (1, 5, 20), "Cell state shape mismatch"
155158

156159

160+
@pytest.mark.requires_gpu
157161
def test_forward_with_zero_dropout():
158162
model = CudnnLstm(input_size=10, hidden_size=20, dr=0.0)
159163
input_data = torch.randn(20, 5, 10) # [seq_len, batch_size, input_size]
@@ -167,6 +171,7 @@ def test_forward_with_zero_dropout():
167171
assert cy.shape == (1, 5, 20), "Cell state shape mismatch"
168172

169173

174+
@pytest.mark.requires_gpu
170175
def test_forward_with_dropout_false():
171176
model = CudnnLstm(input_size=10, hidden_size=20, dr=0.5)
172177
input_data = torch.randn(20, 5, 10) # [seq_len, batch_size, input_size]
@@ -180,6 +185,7 @@ def test_forward_with_dropout_false():
180185
assert cy.shape == (1, 5, 20), "Cell state shape mismatch"
181186

182187

188+
@pytest.mark.requires_gpu
183189
def test_forward_with_initial_states():
184190
model = CudnnLstm(input_size=10, hidden_size=20, dr=0.5)
185191
input_data = torch.randn(20, 5, 10) # [seq_len, batch_size, input_size]

tests/test_train_camelspro_mtl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from torchhydro.trainers.trainer import train_and_evaluate
1717

1818

19+
@pytest.mark.requires_gpu
1920
def test_cuda_available():
2021
assert torch.cuda.is_available()
2122

0 commit comments

Comments
 (0)