Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move XRC callbacks to common #652

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

olliesilvester
Copy link
Contributor

@olliesilvester olliesilvester commented Nov 15, 2024

Fixes #214 and #215

Moves lots of the external_interaction code into common. Some main bits:

  • A common ThreeDGridScan which HyperionThreeDGridScan now inherits
  • Functions for talking to Nexus and ISPyB moved to common
  • All XRC and common callbacks moved to mx_bluesky common
  • XRC nexus callbacks now needs to know what type of parameters are being used. It accepts ThreeDGridScan any any children of this type

Probably difficult to review, sorry

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 97.83550% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.98%. Comparing base (9aa3698) to head (590b6c6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #652      +/-   ##
==========================================
- Coverage   85.00%   84.98%   -0.02%     
==========================================
  Files          98       96       -2     
  Lines        6548     6546       -2     
==========================================
- Hits         5566     5563       -3     
- Misses        982      983       +1     
Components Coverage Δ
i24 SSX 69.59% <ø> (ø)
hyperion 96.23% <100.00%> (-0.56%) ⬇️
other 96.97% <96.81%> (+1.99%) ⬆️

@olliesilvester olliesilvester marked this pull request as draft November 15, 2024 16:27
@olliesilvester
Copy link
Contributor Author

See #655 for sorting out the tests. Annoyingly, we might want to do this before merging, so we can be sure that this PR didn't break anything, but I don't want to hold up @noemifrisina 's work

@olliesilvester olliesilvester marked this pull request as ready for review November 15, 2024 17:33
@olliesilvester olliesilvester changed the title Begin moving callbacks to common Move XRC callbacks to common Nov 15, 2024
@noemifrisina
Copy link
Contributor

See #655 for sorting out the tests. Annoyingly, we might want to do this before merging, so we can be sure that this PR didn't break anything, but I don't want to hold up @noemifrisina 's work

If all the important bits have been moved and sorting out the tests is all that's left to this one, I think it would be worth it to sort out the tests before merging this. While that might take awhile, as you said at least we'd be reasonably sure things are still working after this PR. For my work, I can just make a new branch off this one in the meantime and make a start

@olliesilvester
Copy link
Contributor Author

See #655 for sorting out the tests. Annoyingly, we might want to do this before merging, so we can be sure that this PR didn't break anything, but I don't want to hold up @noemifrisina 's work

If all the important bits have been moved and sorting out the tests is all that's left to this one, I think it would be worth it to sort out the tests before merging this. While that might take awhile, as you said at least we'd be reasonably sure things are still working after this PR. For my work, I can just make a new branch off this one in the meantime and make a start

Cool, as long as it's not holding you up


if TYPE_CHECKING:
from event_model.documents import Event, EventDescriptor, RunStart

T = TypeVar("T", bound="ThreeDGridScan")


class GridscanNexusFileCallback(PlanReactiveCallback):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a particular reason why we're moving this particular nexus callback and not the rotation one too? Would it be worth making a nore general one from which both this and the rotation one in hyperion - and any other ones we need in the future - can inherit?
This would be a separate PR in any case, only trying to understand the what's going on...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there's no reason other than trying to not do everything at once. For now, I only need the bits in XRC, so I've only moved the parts needed for this

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. Sounds good to me, maybe add an issue if it doesn't exist already - or a comment about this on an existing one?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be possible for the nexus callbacks to be much more generic. I think we could even get away with one for all usecases see #364

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, as long as no one is waiting for this PR, I can include that here

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's going to be quite a big refactor, I would do it in a new PR

@@ -21,6 +28,7 @@
HardwareConstants,
)
from mx_bluesky.common.parameters.robot_load import RobotLoadAndEnergyChange
from mx_bluesky.hyperion.parameters.constants import CONST
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe import CONST as hyperion_const or something?

On a first read this threw me a bit because I was assuming CONST would be common and not hyperion specific...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch, I shouldn't be importing anything from Hyperion to mx_bluesky/common. We're meant to have linting rules which catches this, I'll check why it didn't work

@noemifrisina
Copy link
Contributor

On a first go through, looks okay, thank you. Will wait to finish review and approve till you're done with the tests. I'd say the fact that they pass right now is a good start though :)

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Couple of comments between meetings, not a full review

class HyperionGridCommon(GridCommon, WithHyperionFeatures):
# This class only exists so that we can properly select enable_dev_shm. Remove in
# https://github.com/DiamondLightSource/hyperion/issues/1395"""
class HyperionThreeDGridScan(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: ThreeDGridScan already inherits from:

    GridCommon,
    SpecifiedGrid,
    SplitScan,
    WithOptionalEnergyChange,

So we can drop the others here

)
parameters = HyperionThreeDGridScan.model_validate_json(hyperion_params)
parameters = self.param_type.model_validate_json(mx_bluesky_parameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could: Can we just always use do ThreeDGridScan.model_validate_json here? We don't need all the additional stuff from Hyperion anyway? Maybe we can get away with an even broader base class e.g. in ispyb_callback we just convert to a GridCommon. Basically the more broader the baseclass the more reusable this callback should be

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.

Move ispyb and nexus functions to mx_bluesky
3 participants