Skip to content

Commit 5aa5cb4

Browse files
committed
Fix GitHub Actions widget test failures
- Add conditional skip for widget tests when dependencies unavailable - Update CI workflow to install widget dependencies - Widget tests now gracefully skip in environments without IPython/ipywidgets Resolves pytest failures in GitHub Actions CI environment.
1 parent 555aa25 commit 5aa5cb4

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Install dependencies
3232
run: |
3333
python -m pip install --upgrade pip
34-
pip install -e ".[dev,test,kubernetes]"
34+
pip install -e ".[dev,test,kubernetes,widget]"
3535
3636
- name: Lint with black
3737
run: |
@@ -70,7 +70,7 @@ jobs:
7070
- name: Install dependencies
7171
run: |
7272
python -m pip install --upgrade pip
73-
pip install -e ".[dev,test,kubernetes]"
73+
pip install -e ".[dev,test,kubernetes,widget]"
7474
7575
- name: Run integration tests
7676
run: |

tests/test_widget_fixes.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@
44

55
import importlib
66

7+
import pytest
8+
79
import clustrix.notebook_magic
810
from clustrix.config import ClusterConfig
911

12+
# Check if widget dependencies are available
13+
try:
14+
import IPython
15+
import ipywidgets
16+
WIDGET_DEPS_AVAILABLE = True
17+
except ImportError:
18+
WIDGET_DEPS_AVAILABLE = False
19+
1020
# Reload to ensure fresh state
1121
importlib.reload(clustrix.notebook_magic)
1222

1323
# Import after reload to get the refreshed module
1424
DEFAULT_CONFIGS = clustrix.notebook_magic.DEFAULT_CONFIGS
15-
ClusterConfigWidget = clustrix.notebook_magic.ClusterConfigWidget
25+
if WIDGET_DEPS_AVAILABLE:
26+
ClusterConfigWidget = clustrix.notebook_magic.ClusterConfigWidget
1627

1728

1829
class TestWidgetConfigurationFixes:
@@ -57,6 +68,7 @@ def test_cloud_provider_field_mapping(self):
5768
assert "hf_hardware" in hf_config
5869
assert "hf_sdk" in hf_config
5970

71+
@pytest.mark.skipif(not WIDGET_DEPS_AVAILABLE, reason="Widget dependencies not available")
6072
def test_widget_safe_value_setting(self):
6173
"""Test that widget safely handles values not in dropdown options."""
6274
widget = ClusterConfigWidget(auto_display=False)
@@ -87,6 +99,7 @@ def test_widget_safe_value_setting(self):
8799
assert widget.azure_region.value in widget.azure_region.options
88100
assert widget.azure_instance_type.value in widget.azure_instance_type.options
89101

102+
@pytest.mark.skipif(not WIDGET_DEPS_AVAILABLE, reason="Widget dependencies not available")
90103
def test_widget_save_load_cycle(self):
91104
"""Test that widget can save and load configurations correctly."""
92105
widget = ClusterConfigWidget(auto_display=False)
@@ -178,6 +191,7 @@ def test_cloud_provider_fields_in_config(self):
178191
assert hf_config.hf_username == "test-user"
179192
assert hf_config.hf_sdk == "gradio"
180193

194+
@pytest.mark.skipif(not WIDGET_DEPS_AVAILABLE, reason="Widget dependencies not available")
181195
def test_widget_dropdown_population(self):
182196
"""Test that widget properly populates dropdown options."""
183197
widget = ClusterConfigWidget(auto_display=False)
@@ -214,6 +228,7 @@ def test_no_name_description_in_default_configs(self):
214228
"description" not in test_config
215229
), f"Config '{config_name}' should not have 'description' field initially"
216230

231+
@pytest.mark.skipif(not WIDGET_DEPS_AVAILABLE, reason="Widget dependencies not available")
217232
def test_widget_cluster_type_change_updates_options(self):
218233
"""Test that changing cluster type updates dropdown options."""
219234
widget = ClusterConfigWidget(auto_display=False)

0 commit comments

Comments
 (0)