Skip to content

Add test to ensure all functions in beamline modules are devices or fixtures#1984

Draft
jacob720 wants to merge 1 commit intomainfrom
1981_check_beamline_module_functions
Draft

Add test to ensure all functions in beamline modules are devices or fixtures#1984
jacob720 wants to merge 1 commit intomainfrom
1981_check_beamline_module_functions

Conversation

@jacob720
Copy link
Contributor

Fixes #1981

Instructions to reviewer on how to test:

  1. Delete fixture or device decorator in a beamline module.
  2. Confirm test for that beamline fails.

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@jacob720 jacob720 requested a review from a team as a code owner March 20, 2026 16:24
@jacob720 jacob720 marked this pull request as draft March 20, 2026 16:24
@oliwenmandiamond
Copy link
Contributor

oliwenmandiamond commented Mar 20, 2026

This fails due to i23

def _is_i23_machine():
    """Devices using PVA can only connect from i23 machines, due to the absence of
    PVA gateways at present.
    """
    hostname = get_hostname()
    return hostname.startswith("i23-ws") or hostname.startswith("i23-control")


@devices.factory(skip=lambda: not _is_i23_machine())
def oav_pin_tip_detection() -> PinTipDetection:
    return PinTipDetection(
        f"{PREFIX.beamline_prefix}-DI-OAV-01:",
        "pin_tip_detection",
    )

So there does seem to be a use case for defining functions in the beamline module that aren't decorated. The only solution to this is to move this function and have it be imported instead

dodal/devices/beamlines/i23/utils -> is_i23_machine()

i23.py

from dodal.devices.beamlines.i23 import is_i23_machine

@devices.factory(skip=lambda: not _is_i23_machine())
def oav_pin_tip_detection() -> PinTipDetection:
    return PinTipDetection(
        f"{PREFIX.beamline_prefix}-DI-OAV-01:",
        "pin_tip_detection",
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test criterion to confirm decorators correct in beamline device definition script

2 participants