Skip to content

Commit

Permalink
fixing some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Sep 11, 2024
1 parent c30d06b commit 2b7946a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
27 changes: 15 additions & 12 deletions src/blueapi/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
from blueapi.client.client import BlueapiClient
from blueapi.client.event_bus import AnyEvent, BlueskyStreamingError, EventBusClient
from blueapi.client.rest import BlueskyRemoteControlError
from blueapi.config import ApplicationConfig, ConfigLoader
from blueapi.config import (
ApplicationConfig,
BasicAuthentication,
ConfigLoader,
StompConfig,
)
from blueapi.core import DataEvent
from blueapi.service.main import start
from blueapi.service.openapi import (
Expand Down Expand Up @@ -146,19 +151,17 @@ def get_devices(obj: dict) -> None:
def listen_to_events(obj: dict) -> None:
"""Listen to events output by blueapi"""
config: ApplicationConfig = obj["config"]
if config.stomp is not None:
event_bus_client = EventBusClient(
MessagingTemplate.for_broker(
broker=Broker(
host=config.stomp.host,
port=config.stomp.port,
auth=config.stomp.auth,
)
assert config is ApplicationConfig, "config is not ApplicationConfig"
assert config.stomp is StompConfig, "stomp is not StompConfig"
event_bus_client = EventBusClient(
MessagingTemplate.for_broker(
broker=Broker(
host=config.stomp.host,
port=config.stomp.port,
auth=config.stomp.auth,
)
)
else:
raise RuntimeError("Message bus needs to be configured")

)
fmt = obj["fmt"]

def on_event(
Expand Down
21 changes: 10 additions & 11 deletions src/blueapi/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from bluesky_stomp.messaging import MessageContext, MessagingTemplate
from bluesky_stomp.models import Broker

from blueapi.config import ApplicationConfig
from blueapi.config import ApplicationConfig, StompConfig
from blueapi.core.bluesky_types import DataEvent
from blueapi.service.model import (
DeviceModel,
Expand Down Expand Up @@ -40,17 +40,16 @@ def __init__(
@classmethod
def from_config(cls, config: ApplicationConfig) -> "BlueapiClient":
rest = BlueapiRestClient(config.api)
if config.stomp is not None:
template = MessagingTemplate.for_broker(
broker=Broker(
host=config.stomp.host,
port=config.stomp.port,
auth=config.stomp.auth,
)
events = None
assert config.stomp is StompConfig, "StompConfig is wrong"
template = MessagingTemplate.for_broker(
broker=Broker(
host=config.stomp.host,
port=config.stomp.port,
auth=config.stomp.auth,
)
events = EventBusClient(template)
else:
events = None
)
events = EventBusClient(template)
return cls(rest, events)

def get_plans(self) -> PlanResponse:
Expand Down
2 changes: 1 addition & 1 deletion src/blueapi/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def my_plan(a: int, b: str):
if not is_bluesky_plan_generator(plan):
raise TypeError(f"{plan} is not a valid plan generator function")

model = create_model( # type: ignore
model = create_model(
plan.__name__,
__config__=BlueapiPlanModelConfig,
**self._type_spec_for_function(plan),
Expand Down

0 comments on commit 2b7946a

Please sign in to comment.