Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Jul 31, 2024
1 parent dfe09ea commit ee1bfbb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 27 deletions.
12 changes: 7 additions & 5 deletions src/blueapi/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
from blueapi import __version__
from blueapi.cli.format import OutputFormat
from blueapi.client.client import BlueapiClient
from blueapi.client.event_bus import (AnyEvent, BlueskyStreamingError,
EventBusClient)
from blueapi.client.event_bus import AnyEvent, BlueskyStreamingError, EventBusClient
from blueapi.client.rest import BlueskyRemoteControlError
from blueapi.config import ApplicationConfig, ConfigLoader
from blueapi.core import DataEvent
from blueapi.messaging import MessageContext
from blueapi.messaging.stomptemplate import StompMessagingTemplate
from blueapi.service.main import start
from blueapi.service.openapi import (DOCS_SCHEMA_LOCATION, generate_schema,
print_schema_as_yaml,
write_schema_as_yaml)
from blueapi.service.openapi import (
DOCS_SCHEMA_LOCATION,
generate_schema,
print_schema_as_yaml,
write_schema_as_yaml,
)
from blueapi.worker import ProgressEvent, Task, WorkerEvent

from .scratch import setup_scratch
Expand Down
19 changes: 13 additions & 6 deletions src/blueapi/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
from blueapi.config import ApplicationConfig
from blueapi.core.bluesky_types import DataEvent
from blueapi.messaging import MessageContext, StompMessagingTemplate
from blueapi.service.model import (DeviceModel, DeviceResponse,
EnvironmentResponse, PlanModel,
PlanResponse, TaskResponse, WorkerTask)
from blueapi.service.model import (
DeviceModel,
DeviceResponse,
EnvironmentResponse,
PlanModel,
PlanResponse,
TaskResponse,
WorkerTask,
)
from blueapi.worker import Task, TrackableTask, WorkerEvent, WorkerState
from blueapi.worker.event import ProgressEvent, TaskStatus

from .event_bus import (AnyEvent, BlueskyStreamingError, EventBusClient,
OnAnyEvent)
from .event_bus import AnyEvent, BlueskyStreamingError, EventBusClient, OnAnyEvent
from .rest import BlueapiRestClient, BlueskyRemoteControlError


Expand Down Expand Up @@ -356,7 +361,9 @@ def _wait_for_reload(
# Poll until the environment is restarted or the timeout is reached
status = self._rest.get_environment()
if status.error_message is not None:
raise BlueskyRemoteControlError(f"Error reloading environment: {status.error_message}")
raise BlueskyRemoteControlError(
f"Error reloading environment: {status.error_message}"
)
elif status.initialized:
return status
time.sleep(polling_interval)
Expand Down
26 changes: 21 additions & 5 deletions src/blueapi/service/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from contextlib import asynccontextmanager

from fastapi import (BackgroundTasks, Body, Depends, FastAPI, HTTPException,
Request, Response, status)
from fastapi import (
BackgroundTasks,
Body,
Depends,
FastAPI,
HTTPException,
Request,
Response,
status,
)
from pydantic import ValidationError
from starlette.responses import JSONResponse
from super_state_machine.errors import TransitionError
Expand All @@ -11,9 +19,17 @@
from blueapi.worker import Task, TrackableTask, WorkerState
from blueapi.worker.event import TaskStatusEnum

from .model import (DeviceModel, DeviceResponse, EnvironmentResponse,
PlanModel, PlanResponse, StateChangeRequest, TaskResponse,
TasksListResponse, WorkerTask)
from .model import (
DeviceModel,
DeviceResponse,
EnvironmentResponse,
PlanModel,
PlanResponse,
StateChangeRequest,
TaskResponse,
TasksListResponse,
WorkerTask,
)
from .runner import WorkerDispatcher

REST_API_VERSION = "0.0.5"
Expand Down
3 changes: 1 addition & 2 deletions src/blueapi/service/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from typing import Any

from blueapi.config import ApplicationConfig
from blueapi.service.interface import (InitialisationException, start_worker,
stop_worker)
from blueapi.service.interface import InitialisationException, start_worker, stop_worker
from blueapi.service.model import EnvironmentResponse

# The default multiprocessing start method is fork
Expand Down
3 changes: 1 addition & 2 deletions tests/service/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

from blueapi.core.bluesky_types import Plan
from blueapi.service import main
from blueapi.service.model import (DeviceModel, PlanModel, StateChangeRequest,
WorkerTask)
from blueapi.service.model import DeviceModel, PlanModel, StateChangeRequest, WorkerTask
from blueapi.worker.event import WorkerState
from blueapi.worker.task import Task
from blueapi.worker.worker import TrackableTask
Expand Down
15 changes: 8 additions & 7 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@
from blueapi.client.rest import BlueskyRemoteControlError
from blueapi.config import ScratchConfig, ScratchRepository
from blueapi.core.bluesky_types import Plan
from blueapi.service.model import (DeviceModel, DeviceResponse,
EnvironmentResponse, PlanModel,
PlanResponse)
from blueapi.service.model import (
DeviceModel,
DeviceResponse,
EnvironmentResponse,
PlanModel,
PlanResponse,
)


@pytest.fixture
Expand Down Expand Up @@ -252,10 +256,7 @@ def test_env_timeout(mock_sleep: Mock, runner: CliRunner):
assert call.request.url == "http://localhost:8000/environment"

# Check the output for the timeout message
assert (
result.output
== "Reloading environment\n"
)
assert result.output == "Reloading environment\n"
assert (
result.exit_code == 1
) # Assuming your command exits successfully even on timeout for simplicity
Expand Down

0 comments on commit ee1bfbb

Please sign in to comment.