Skip to content

Conversation

@rtuck99
Copy link
Contributor

@rtuck99 rtuck99 commented Dec 18, 2025

Fixes:

Requires:

Instructions to reviewer on how to test:

  1. Do thing x
  2. Confirm thing y happens

Checks for reviewer

  • Would the PR title make sense to a user on a set of release notes

@rtuck99 rtuck99 changed the base branch from hyperion_on_blueapi to hyperion-planrunner-refactor December 18, 2025 15:39
@rtuck99 rtuck99 force-pushed the hyperion-supervisor branch from 7f6606a to 285ca33 Compare December 18, 2025 15:56
@rtuck99 rtuck99 added the hyperion Issues for Hyperion, the Bluesky UDC stack label Dec 18, 2025
@rtuck99 rtuck99 force-pushed the hyperion-supervisor branch from 285ca33 to 17ede8b Compare December 18, 2025 16:49
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 99.15966% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.45%. Comparing base (6e45f38) to head (d0e35d7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1530      +/-   ##
==========================================
+ Coverage   92.29%   92.45%   +0.15%     
==========================================
  Files         144      146       +2     
  Lines        8167     8272     +105     
==========================================
+ Hits         7538     7648     +110     
+ Misses        629      624       -5     
Components Coverage Δ
i24 SSX 78.56% <ø> (ø)
hyperion 98.18% <99.15%> (+0.28%) ⬆️
other 98.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rtuck99 rtuck99 force-pushed the hyperion-supervisor branch from 17ede8b to fb6e53f Compare December 18, 2025 17:03
@rtuck99 rtuck99 marked this pull request as ready for review January 5, 2026 14:40
@rtuck99 rtuck99 requested a review from a team as a code owner January 5, 2026 14:40
@rtuck99 rtuck99 marked this pull request as draft January 5, 2026 14:41
@rtuck99 rtuck99 marked this pull request as ready for review January 5, 2026 15:28
@rtuck99 rtuck99 force-pushed the hyperion-planrunner-refactor branch from 0769d9d to 0671ffd Compare January 5, 2026 16:17
@rtuck99 rtuck99 force-pushed the hyperion-supervisor branch from d360a62 to 9ca88ac Compare January 5, 2026 16:24
@rtuck99 rtuck99 mentioned this pull request Jan 8, 2026
1 task
Copy link
Contributor

@jacob720 jacob720 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a couple of comments but happy to merge if you disagree


def parse_callback_dev_mode_arg() -> bool:
def parse_callback_args() -> CallbackArgs:
"""Returns the bool representing the 'dev_mode' argument."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could : Update this docstring to include the watchdog_port

instrument_session=instrument_session,
)
self._run_task_remotely(task_request)
case _:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It strikes me that currently if we add a plan that agamemnon can request, we'd have to make changes in 3 places:

  • SupvervisorRunner.decode_and_execute
  • InProcessRunner.decode_and_execute
  • create_parameters_from_agamemnon

Could we push some of this logic into new classes that extend or contain the parameter models?

Something like

class ExecutablePlan:
    @abstractmethod
    def execute_plan(self, context: BlueskyContext) -> MsgGenerator: ...

    @abstractmethod
    def get_task_request(self, instrument_session) -> TaskRequest: ...


class TaskRequestAndExecuteFromLoadCentreCollect(ExecutablePlan):
    def __init__(self, parameters: LoadCentreCollect):
        self.parameters = parameters

    def get_task_request(self, instrument_session):
        return TaskRequest(
            name="load_centre_collect",
            params={"parameters": self.parameters},
            instrument_session=instrument_session,
        )

    def execute_plan(self, context: BlueskyContext):
        devices: Any = create_devices(context)
        yield from self.execute_plan(
            partial(load_centre_collect_full, devices, self.parameters)
        )
        return self.parameters.visit


class TaskRequestFromUDCDefaultState(ExecutablePlan):
    def get_task_request(self, instrument_session):
        return TaskRequest(
            name="load_centre_collect",
            params={},
            instrument_session=instrument_session,
        )

    def execute_plan(self, context: BlueskyContext):
        udc_default_devices: UDCDefaultDevices = device_composite_from_context(
            context, UDCDefaultDevices
        )
        yield from move_to_udc_default_state(udc_default_devices)

etc.
Then we could get rid of the switch statements in SupvervisorRunner.decode_and_execute and InProcessRunner.decode_and_execute and instead have

def decode_and_execute(
    self, current_visit: str | None, parameter_list: Sequence[ExecutablePlan]
) -> MsgGenerator:
    for parameters in parameter_list:
        current_visit = self._run_task_remotely(parameters.get_task_request(instrument_session)) or current_visit
    return current_visit

or

def decode_and_execute(
    self, current_visit: str | None, parameter_list: Sequence[ExecutablePlan]
  ) -> MsgGenerator:
    for parameters in parameter_list:
        current_visit = parameters.execute_plan(self.context) or current_visit
    return current_visit

I might have misunderstood something and there may be good reasons to not do this but I thought it could be worth discussing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InProcessRunner will ultimately go away, once we are running happily in blueapi, we can delete it. The abstraction has been created so that we can temporarily switch between both setups. It is annoying that we have to have code that is very similar in both runner implementations, unfortunately there isn't a nice way around it with one method being a generator function and the other not.

It's probably unlikely we will add more plans for agamemnon to run. What is more likely is commissioning plans but these wouldn't be called by hyperion-supervisor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks for explaining

@rtuck99 rtuck99 force-pushed the hyperion-planrunner-refactor branch from 0671ffd to da524f4 Compare January 15, 2026 14:58
Base automatically changed from hyperion-planrunner-refactor to main January 15, 2026 15:13
@rtuck99 rtuck99 force-pushed the hyperion-supervisor branch from 60a3bdd to e80df89 Compare January 15, 2026 15:19
Make type-checking happy
@rtuck99 rtuck99 merged commit 628cb42 into main Jan 15, 2026
18 checks passed
@rtuck99 rtuck99 deleted the hyperion-supervisor branch January 15, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hyperion Issues for Hyperion, the Bluesky UDC stack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants