Commit graph

2844 commits

Author SHA1 Message Date
Joe Knapper
a506625e40 Treat cancellation and other errors differently 2025-04-07 14:22:43 +01:00
Joe Knapper
9995e5b3bb Import custom Mapping error from camera_stage_mapping 2025-04-07 14:18:07 +01:00
jaknapper
67443ff939 Capture ValueErrors, which covers most CSM errors, not all Exceptions 2025-04-03 13:52:04 +01:00
jaknapper
46d513d9e6 Catch cancelled and other errors in single line 2025-04-02 18:25:35 +01:00
Joe Knapper
79b396a66f CSM always returns to start on error 2025-04-02 17:54:12 +01:00
Julian Stirling
550c977f59 Merge branch 'split-ruff-ci' into 'v3'
Split up ruff format and lint

See merge request openflexure/openflexure-microscope-server!226
2025-04-02 13:41:35 +00:00
Julian Stirling
32f2a7ce70 Fix spurious line endings, don't allow ruff-format to fail anymore 2025-04-02 14:25:22 +01:00
Julian Stirling
928d5ef300 Try pinning pydantic version as server now fails tests with error 2025-04-02 14:05:38 +01:00
Julian Stirling
336b504377 Split up ruff format and lint allowing format to fail 2025-04-02 13:39:12 +01:00
Julian Stirling
9fb417e4e6 Edit v3 branch readme as we make it the Default branch to point people to master if they are looking for v2 code 2025-02-21 10:40:25 +00:00
Richard Bowman
e8ae496d08 Use published packages
I've published [pre]releases on PyPI. This commit uses the mos recent releases of labthings-picamera2 and camera-stage-mapping.
2024-12-18 14:26:15 +00:00
Richard Bowman
83e10b125b Fix return type annotation for autofocus 2024-12-18 14:23:58 +00:00
Richard Bowman
db11e03321 Constrain numpy < 2
picamera2 fails to import with numpy 2.
2024-12-18 14:23:44 +00:00
Richard Bowman
d9c8a083fd Merge branch 'v3-ci-and-tests' into 'v3'
Add more unit tests and fix CI

See merge request openflexure/openflexure-microscope-server!194
2024-12-03 14:42:48 +00:00
Richard Bowman
1d59cddac1 Disable pytest code quality report
Code quality report plugin clashes with the version of pytest specced in labthings.

If we resolve this upstream, we can re-enable it.
2024-12-03 14:19:36 +00:00
Richard Bowman
c3cd30b642 Only rebuild docker for changes
Docker is now only rebuilt when it's changed, and on `v3`  branch.

I've also added code quality reporting for pytest.
2024-12-03 12:54:34 +00:00
Richard Bowman
71e6d84aa4 Build docker image and run ruff/pytest 2024-12-03 12:18:45 +00:00
Richard Bowman
77794c94eb Update documentation on dependencies/dev tools 2024-12-03 11:18:24 +00:00
Richard Bowman
9fd8fc37f1 Formatted with Ruff 2024-12-03 06:46:08 +00:00
Richard Bowman
27aec769a2 Linter fixes
NB I have permitted bare except: blocks in smart_scan. This should be reverted.
2024-12-03 06:43:45 +00:00
Richard Bowman
57177c6a56 Sped up camera and got CSM passing
Using lower resolution helps speed it up, and skipping CSM settling time makes a big difference.
2024-12-03 06:35:16 +00:00
Richard Bowman
1e7069b375 Add more tests, speed up dummy stage
I've sped up the stage motion, to run tests in a more reasonable time.

CSM doesn't yet calibrate in the test - I suspect debugging of capture_array
is needed.
2024-12-03 00:16:26 +00:00
Richard Bowman
728aa12d07 Add more unit tests
I'm now testing camera metadata and stage functionality. This is only using
the simulated HW - but it's a start.

It would be good to add tests for the
camera-stage mapping Thing, though
that may require speeding up the stage.
2024-12-02 23:26:32 +00:00
Richard Bowman
4d4ca831b3 Merge branch 'v3-camera-protocol' into 'v3'
Formal Protocol for camera and stage interfaces

See merge request openflexure/openflexure-microscope-server!192
2024-11-29 13:13:09 +00:00
Richard Bowman
58066f1948 Add a first unit test
This checks that the server can start
and perform an autofocus.
Autofocus in turn will test the camera and stage dependencies.
2024-11-29 13:03:36 +00:00
Richard Bowman
bccb1ee923 Stub class for camera protocol
As with the previous commit, this adds a concrete stub Thing to enable
DirectThingClient generation, so we
can depend on the camera.
2024-11-29 12:53:42 +00:00
Richard Bowman
a0fbbc3e40 Convert Stage to a Protocol
The Stage is now implemented as a runtime-checkable Protocol.

Part of this led to the realisation that we can't create a DirectThingClient
based on a Protocol, only on a concrete Thing. While it might be
a good idea to address that in LabThings in due course, for now
we work around it by creating both a Protocol and a stub class. The stub class implements the protocol, and
can be used to declare a dependency.
2024-11-29 12:53:04 +00:00
Richard Bowman
2e2e877d75 JPEGBlob class definition
Static type checking is easier if JPEGBlob is declared as a class, rather than
being created with a function.
2024-11-29 12:19:05 +00:00
Richard Bowman
adbb805556 Formal Protocol for camera interface
I've now split the base camera code into a runtime-checkable Protocol
and a concrete base class (which is optional). This removes the requirement
for cameras to subclass `openflexure_microscope.things.camera.Camera`
and instead uses duck typing that should
work both statically and dynamically.

As part of this, I've moved the commonly-used dependencies
on the camera inside `openflexure_microscope.things.camera` for consistency, and to make it easy to update them if it changes in the future.
2024-11-29 11:26:38 +00:00
Richard Bowman
42b4c1246e Merge branch 'v3-update-labthings' into 'v3'
Migrate to new Blob type and update imports

See merge request openflexure/openflexure-microscope-server!191
2024-11-29 09:04:44 +00:00
Richard Bowman
1ba799de22 Migrate to new Blob type and update imports
This now uses the latest version of labthings-fastapi.
2024-11-28 17:35:56 +00:00
Richard Bowman
aa42e93154 Correct command in README 2024-11-28 11:14:27 +00:00
Richard Bowman
6f761b0b81 Merge branch 'v3-configurable-server' into 'v3'
Add configurability to the server

See merge request openflexure/openflexure-microscope-server!181
2024-11-28 10:45:35 +00:00
Richard Bowman
78edb078b5 Update readme with instructions on how to run the server. 2024-11-28 10:37:46 +00:00
Richard Bowman
b8ca12314c Lock labthings/picamera2 deps
v0.0.7 of labthings includes breaking changes, we're not ready for that yet.
2024-11-28 10:30:53 +00:00
Richard Bowman
5c4ff203d7 Fix full config file
The full config file now uses the correct syntax for loading the picamera2
and sangaboard Things, and uses the default system-level settings folder.
2024-11-28 10:26:56 +00:00
Richard Bowman
7b584d3e64 Add labthings version constraint 2024-11-16 10:58:31 +00:00
Richard Bowman
e17d6e5e8f Update README and correct syntax of full config 2024-11-16 10:56:10 +00:00
Richard Bowman
868aa0598c Simulation mode
I successfully calibrated and used the camera-stage mapping.
2024-11-02 00:10:25 +00:00
Richard Bowman
2019234ad1 Close OpenCV camera cleanly 2024-08-09 02:50:39 +01:00
Richard Bowman
7fb4417ebe Configuration files and other tweaks
The OFM server can now be run in "stub" mode on
my development machine, using an OpenCV
camera feed.
2024-08-09 02:42:32 +01:00
Richard Bowman
2268425bf3 Depend only on generic Camera and Stage
I've now defined parent classes for camera and stage, and depend only on those. This allows
proper typing while enabling the actual hardware
classes to be swapped.

The interfaces definitely aren't final - this is a first
draft, largely to enable me to test out the concept
of a configuration server.
2024-08-09 02:41:39 +01:00
Richard Bowman
aa49cfcba3 Search the package for static files
This isn't foolproof: a zipped package will break it.
If that's something we want to support, we might
need to extract the folder to a temp location.
2024-08-09 02:39:04 +01:00
Richard Bowman
e3e248c46e Move server config to a config file
Currently this is "just" a LabThings config file.
2024-08-09 01:51:11 +01:00
Richard Bowman
b7f9f6cbaf Fix import from LabThings 2024-08-09 01:50:46 +01:00
Richard Bowman
5279dffe6a Dummy stage class 2024-08-09 01:12:16 +01:00
Richard Bowman
3f92ed8266 Add a stub OpenCV-based camera
This allows the server to run on a laptop, to some extent. I've not tested if this will make the whole
web app work properly.

As StreamingPiCamera2 is hardcoded in various places, this certainly doesn't make cameras totally
interchangeable - but it is a step towards that.
2024-08-09 00:52:31 +01:00
Richard Bowman
c32b44d1a6 Refactor server into submodule 2024-08-09 00:49:24 +01:00
Richard Bowman
3abddc3b39 Fix labthings dependency
I changed the labthings package such that it will
only install the client dependencies by default.
This is now fixed by requiring the [server] extras.
In the future we might split labthings into client
and server packages.
2024-07-18 13:17:26 +01:00
Joe Knapper
c2b54da4a1 More explantion of building webapp in README 2024-06-10 11:27:30 +00:00