diff --git a/scripts/zenodo/upload_to_zenodo.py b/scripts/zenodo/upload_to_zenodo.py index aa30ce18..64eefdeb 100644 --- a/scripts/zenodo/upload_to_zenodo.py +++ b/scripts/zenodo/upload_to_zenodo.py @@ -1,5 +1,4 @@ import os -import requests from argparse import ArgumentParser, Namespace from zenodo import Zenodo import yaml diff --git a/src/openflexure_microscope_server/server.py b/src/openflexure_microscope_server/server.py index b1800181..027fcf22 100644 --- a/src/openflexure_microscope_server/server.py +++ b/src/openflexure_microscope_server/server.py @@ -1,10 +1,6 @@ from __future__ import annotations import logging -import importlib.resources -import os.path from fastapi import Response -from fastapi.staticfiles import StaticFiles -from fastapi.responses import FileResponse, RedirectResponse from labthings_fastapi.thing_server import ThingServer from labthings_sangaboard import SangaboardThing from labthings_picamera2.thing import StreamingPiCamera2 @@ -42,6 +38,7 @@ app = thing_server.app # This is necessary until Connect is rebuilt. @app.get("/routes") def routes_stub() -> dict[str, dict]: + """A stub list of routes, used by OF Connect to identify the microscope""" fake_routes = [ "/api/v2/", "/api/v2/streams/snapshot", @@ -54,5 +51,6 @@ class JPEGResponse(Response): @app.get("/api/v2/streams/snapshot") @app.head("/api/v2/streams/snapshot") async def thumbnail() -> JPEGResponse: + """A low-resolution snapshot, for compatibility with OF connect""" blob = await thing_server.things["/camera/"].lores_mjpeg_stream.grab_frame() - return JPEGResponse(blob) \ No newline at end of file + return JPEGResponse(blob) diff --git a/src/openflexure_microscope_server/things/camera_stage_mapping.py b/src/openflexure_microscope_server/things/camera_stage_mapping.py index a29454b2..6a649e9f 100644 --- a/src/openflexure_microscope_server/things/camera_stage_mapping.py +++ b/src/openflexure_microscope_server/things/camera_stage_mapping.py @@ -10,24 +10,18 @@ and return the calibration data. This module is only intended to be called from the OpenFlexure Microscope server, and depends on that server and its underlying LabThings library. """ -import io -import json import logging -import os import time -from typing import Annotated, Any, Callable, Dict, List, NamedTuple, Optional, Tuple +from typing import Annotated, Any, Callable, Dict, List, Mapping, NamedTuple, Optional, Sequence, Tuple from fastapi import Depends, HTTPException import numpy as np from pydantic import BaseModel -import PIL from camera_stage_mapping.camera_stage_calibration_1d import ( calibrate_backlash_1d, image_to_stage_displacement_from_1d, ) from camera_stage_mapping.camera_stage_tracker import Tracker -from camera_stage_mapping.closed_loop_move import closed_loop_move, closed_loop_scan -from camera_stage_mapping.scan_coords_times import ordered_spiral from labthings_picamera2.thing import StreamingPiCamera2 from labthings_sangaboard import SangaboardThing @@ -53,8 +47,10 @@ class HardwareInterfaceModel(BaseModel): def make_hardware_interface(stage: Stage, camera: Camera) -> HardwareInterfaceModel: """Construct the functions we need to interface with the hardware""" axes = stage.axis_names - pos2dict = lambda pos: {k: p for k, p in zip(axes, pos)} - dict2pos = lambda posd: tuple(posd[k] for k in axes if k in posd) + def pos2dict(pos: Sequence[float]) -> Mapping[str, float]: + return {k: p for k, p in zip(axes, pos)} + def dict2pos(posd: Mapping[str, float]) -> Sequence[float]: + return tuple(posd[k] for k in axes if k in posd) def move(pos: CoordinateType) -> None: current_pos = stage.position new_pos = pos2dict(pos) diff --git a/src/openflexure_microscope_server/things/settings_manager.py b/src/openflexure_microscope_server/things/settings_manager.py index ecaf4c9c..1769b3e4 100644 --- a/src/openflexure_microscope_server/things/settings_manager.py +++ b/src/openflexure_microscope_server/things/settings_manager.py @@ -6,12 +6,11 @@ for code that currently lives in clients but needs to persist settings on the server. """ from collections.abc import Mapping -from typing import Any, Mapping, MutableMapping, Optional, Sequence +from typing import Any, MutableMapping, Optional, Sequence from fastapi import HTTPException from labthings_fastapi.dependencies.metadata import GetThingStates from labthings_fastapi.thing import Thing from labthings_fastapi.decorators import thing_action, thing_property -from pydantic import BaseModel def recursive_update(old_dict: MutableMapping, update: Mapping): diff --git a/tests/test_capture_manager.py b/tests/test_capture_manager.py index 8a1260d3..16fb768b 100644 --- a/tests/test_capture_manager.py +++ b/tests/test_capture_manager.py @@ -1,5 +1,4 @@ import os -from typing import Type import pytest from freezegun import freeze_time diff --git a/tests/test_json.py b/tests/test_json.py index 0e365e6a..0bd53f9f 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -1,8 +1,6 @@ import json -import re import uuid from fractions import Fraction -from uuid import uuid3 import numpy as np import pytest