Skip to content

Commit

Permalink
DiamondLightSource/hyperion#1192 propagate emit arg in ispyb callbac …
Browse files Browse the repository at this point in the history
…init
  • Loading branch information
dperl-dls committed Feb 28, 2024
1 parent 2a0c334 commit 20e2d8e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Optional
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional

from hyperion.external_interaction.callbacks.plan_reactive_callback import (
PlanReactiveCallback,
Expand Down Expand Up @@ -29,12 +29,16 @@


class BaseISPyBCallback(PlanReactiveCallback):
def __init__(self) -> None:
def __init__(
self,
*,
emit: Callable[..., Any] | None = None,
) -> None:
"""Subclasses should run super().__init__() with parameters, then set
self.ispyb to the type of ispyb relevant to the experiment and define the type
for self.ispyb_ids."""
ISPYB_LOGGER.debug("Initialising ISPyB callback")
super().__init__(ISPYB_LOGGER)
super().__init__(log=ISPYB_LOGGER, emit=emit)
self.params: GridscanInternalParameters | RotationInternalParameters | None = (
None
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Callable

from hyperion.external_interaction.callbacks.ispyb_callback_base import (
BaseISPyBCallback,
Expand Down Expand Up @@ -38,8 +38,12 @@ class RotationISPyBCallback(BaseISPyBCallback):
Usually used as part of a RotationCallbackCollection.
"""

def __init__(self) -> None:
super().__init__()
def __init__(
self,
*,
emit: Callable[..., Any] | None = None,
) -> None:
super().__init__(emit=emit)
self.last_sample_id: str | None = None
self.ispyb_ids: IspybIds = IspybIds()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from time import time
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Callable

import numpy as np
from dodal.devices.zocalo.zocalo_results import ZOCALO_READING_PLAN_NAME
Expand Down Expand Up @@ -49,7 +49,11 @@ class GridscanISPyBCallback(BaseISPyBCallback):
Usually used as part of an FGSCallbackCollection.
"""

def __init__(self) -> None:
def __init__(
self,
*,
emit: Callable[..., Any] | None = None,
) -> None:
super().__init__()
self.params: GridscanInternalParameters
self.ispyb: StoreGridscanInIspyb
Expand Down

0 comments on commit 20e2d8e

Please sign in to comment.