Skip to content

Commit

Permalink
Attempted fix for the CI seg faults.
Browse files Browse the repository at this point in the history
Seems to work after we switch to xvfb-run and set runs-on to
ubuntu-20.04
  • Loading branch information
canismarko committed Nov 15, 2023
1 parent 0627544 commit 6188651
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
defaults:
run:
shell: bash -l {0}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
max-parallel: 5
steps:
Expand All @@ -29,8 +29,8 @@ jobs:
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
- name: Setup X virtual frame buffer
run: Xvfb $DISPLAY &
# - name: Setup X virtual frame buffer
# run: Xvfb $DISPLAY &
- name: Install haven
run: pip install -e .
- name: Environment info
Expand All @@ -45,4 +45,4 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: pytest --timeout=120 src/firefly/tests/test_run_browser.py src/firefly/tests/test_voltmeters.py src/firefly/tests/test_xrf_detector_display.py
run: xvfb-run python -m pytest -vv --timeout=120 src/firefly/tests/test_run_browser.py src/firefly/tests/test_voltmeters.py src/firefly/tests/test_xrf_detector_display.py
3 changes: 0 additions & 3 deletions src/firefly/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@ def _prepare_device_windows(self, device_label: str, attr_name: str):
window_slots = []
setattr(self, f"{attr_name}_window_slots", window_slots)
setattr(self, f"{attr_name}_windows", {})
# if attr_name == "ion_chamber":
# breakpoint()
for device in devices:
# Check that we don't already have actions set
# Create the window action
action = QtWidgets.QAction(self)
action.setObjectName(f"actionShow_{attr_name}_{device.name}")
Expand Down
15 changes: 9 additions & 6 deletions src/firefly/tests/test_xrf_detector_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from firefly.xrf_roi import XRFROIDisplay


detectors = ['xspress',]


@pytest.fixture()
def xrf_display(ffapp, request):
"""Parameterized fixture for creating a display based on a specific
Expand All @@ -29,10 +32,10 @@ def xrf_display(ffapp, request):
plot_widget.update_spectrum(1, spectra[1])
plot_widget.update_spectrum(2, spectra[2])
plot_widget.update_spectrum(3, spectra[3])
return display
yield display


@pytest.mark.parametrize("det_fixture", ["dxp", "xspress"])
@pytest.mark.parametrize("det_fixture", detectors)
def test_open_xrf_detector_viewer_actions(ffapp, qtbot, det_fixture, request):
sim_det = request.getfixturevalue(det_fixture)
# Get the area detector parts ready
Expand All @@ -44,15 +47,15 @@ def test_open_xrf_detector_viewer_actions(ffapp, qtbot, det_fixture, request):
assert "FireflyMainWindow_xrf_detector_vortex_me4" in ffapp.windows.keys()


@pytest.mark.parametrize("xrf_display", ["dxp", "xspress"], indirect=True)
@pytest.mark.parametrize("xrf_display", detectors, indirect=True)
def test_roi_widgets(xrf_display):
xrf_display.draw_roi_widgets(2)
# Check that the widgets were drawn
assert len(xrf_display.roi_displays) == xrf_display.device.num_rois
disp = xrf_display.roi_displays[0]


@pytest.mark.parametrize("xrf_display", ["dxp", "xspress"], indirect=True)
@pytest.mark.parametrize("xrf_display", detectors, indirect=True)
def test_roi_element_comboboxes(ffapp, qtbot, xrf_display):
# Check that the comboboxes have the right number of entries
element_cb = xrf_display.ui.mca_combobox
Expand All @@ -61,7 +64,7 @@ def test_roi_element_comboboxes(ffapp, qtbot, xrf_display):
assert roi_cb.count() == xrf_display.device.num_rois


@pytest.mark.parametrize("det_fixture", ["dxp", "xspress"])
@pytest.mark.parametrize("det_fixture", detectors)
def test_roi_selection(ffapp, qtbot, det_fixture, request):
det = request.getfixturevalue(det_fixture)
display = XRFROIDisplay(macros={"DEV": det.name, "NUM": 2, "MCA": 2, "ROI": 2})
Expand All @@ -78,7 +81,7 @@ def test_roi_selection(ffapp, qtbot, det_fixture, request):
assert f"background: {display.selected_background}" not in display.styleSheet()


@pytest.mark.parametrize("xrf_display", ["dxp", "xspress"], indirect=True)
@pytest.mark.parametrize("xrf_display", detectors, indirect=True)
def test_all_rois_selection(xrf_display):
"""Are all the other ROIs disabled when one is selected?"""
roi_display = xrf_display.roi_displays[0]
Expand Down
48 changes: 24 additions & 24 deletions src/haven/instrument/xspress.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,30 @@
class ChannelSignal(MultiDerivedSignal):
"""A high/low range limit channel for an ROI."""

def set(
self,
value: OphydDataType,
*,
timeout: Optional[float] = None,
settle_time: Optional[float] = None,
) -> StatusBase:
# Check for existing signals and, if necessary, wait them out
signals = [
self.parent.hi_chan,
self.parent.lo_chan,
self.parent.size,
self.parent._lo_chan,
]

def get_threads():
thds = [sig._set_thread for sig in signals if sig._set_thread]
return [th for th in thds if th is not None]

while len(threads := get_threads()) > 0:
for th in threads:
th.join()
# Set the signal like normal
return super().set(value, timeout=timeout, settle_time=settle_time)
# def set(
# self,
# value: OphydDataType,
# *,
# timeout: Optional[float] = None,
# settle_time: Optional[float] = None,
# ) -> StatusBase:
# # Check for existing signals and, if necessary, wait them out
# signals = [
# self.parent.hi_chan,
# self.parent.lo_chan,
# self.parent.size,
# self.parent._lo_chan,
# ]

# def get_threads():
# thds = [sig._set_thread for sig in signals if sig._set_thread]
# return [th for th in thds if th is not None]

# while len(threads := get_threads()) > 0:
# for th in threads:
# th.join()
# # Set the signal like normal
# return super().set(value, timeout=timeout, settle_time=settle_time)


class ROI(ROIMixin):
Expand Down

0 comments on commit 6188651

Please sign in to comment.