Commit graph

770 commits

Author SHA1 Message Date
Richard Bowman
1f558bbeb7 OpenAPI Validation Fixes
OpenAPI validation seems to have become stricter about checking for None defaults
in parameters that don't allow None. I have
modified two things as a result:

1. StageTypeProperty (used to pick between SangaStage and SangaDeltaStage)
now defaults to SangaStage (which is the
original behaviour anyway)
2. It is now allowed to pass x,y,z=None when making a move - this is the same as
not passing the respective argument, so the
function already correctly handled this case.
2023-03-22 08:58:04 +00:00
Joe Knapper
f6691cbc11 Update openapi.py with live links to WoT documentation 2023-03-21 15:05:21 +00:00
Richard Bowman
106b50d333 Format fixes from black 2022-08-09 13:17:45 +01:00
Richard Bowman
9dbb083ee7 More Marshmallow argument updates 2022-08-09 13:16:10 +01:00
Richard Bowman
e22f36b308 Start explicit metadata argument for marshmallow
A side effect of re-locking dependencies is having a newer marshmallow.
This deprecates having `description=` as a keyword, and puts it in a
separate metadata arg instead.

This commit is the start of my search-and-replaceing to update to the new
format.
2022-08-09 12:52:57 +01:00
Richard Bowman
78ef9c531b Format fixes from black 2022-08-09 09:37:03 +01:00
Richard Bowman
a9fff24848 Explicitly specify encoding
The update to pylint means we were failing because open()
doesn't specify the encoding everywhere.  I have now specified utf-8
everywhere.  This was patchy before, and is default behaviour on the
Pi.  There's a slim chance it will cause some issues on Windows, but
that shouldn't affect anyone outside the developers.

I've also ignored a couple of new spurious warnings, and explicitly
ignored some unused variables.
2022-08-09 07:16:44 +01:00
Richard Bowman
e356d11e7e Linter/type checking fixes 2022-04-20 13:31:33 +01:00
Richard Bowman
18145d4b67 Refactored new (and some old) code to tidy up scan function
I have:
* Moved the autofocus and focus-prediction code into a
new `FocusManager` class.  This hopefully keeps the logic relating to
axial motion in one place.
* Moved set-up code relating to autofocus and background detection
into separate functions.
* Changed the scan path from a ragged list-of-lists to a one dimensional
list.  I've left the old 2D function and added a new 1D function that
calls it and coverts, so it's not a breaking change.

The actual sequence of moves executed, and the accompanying logic, is
unchanged from the previous commit.  I've tested this a couple of times,
on my microscope with actual hardware.
I don't think it's necessary to test more widely as this is only a
refactoring change, not an algorithm change.

The shift from 2D to 1D scan path was one I initially decided against,
because I was trying to keep the new code as small as possible, and
avoid refactoring what's already there.  Since I'm doing that anyway,
I have taken the opportunity to eliminate the concept of scan
"lines".

The old behaviour was to always use the position of the last point
as the starting point for the next autofocus.  There was an exception
to this for raster scans, where the big jump used the first point
of the last line instead.  The new behaviour always uses the closest
point, which reproduces this behaviour without the need for a hard
coded exception.

If the "fast" scan axis (y) has a longer step size than the "slow"
scan axis (x), we may base the autofocus off the previous row, rather
than the previous point in the current row.  I don't see that this
should be any less reliable than the current behaviour, and is
arguably better.  It's also unlikely to be noticed, because our
default scan settings have longer spacing in X.  I think the
reduced complexity of the code is definitely worth the small
chance of changing some edge-case behaviour.
2022-04-20 13:14:23 +01:00
Richard Bowman
7f66235cac Lint and type fixes 2022-04-06 23:36:55 +01:00
Richard Bowman
333b52aa9b background detect and better focus handling
The primary change here is that there's now an option
to skip autofocus if the background detect plugin says
the current image is background.

I have also overhauled the way it picks the next Z position
based on Joe's code; instead of just using the last point, it will
pick the closest point where we have a successful autofocus
recorded.  This will usually be the last point, except for raster
scans where it neatly reproduces the behaviour of the old code
but without needing to treat it as a special case (when we jump
back to the start of a line, it will use the z position of the start
of the previous line, rather than the end of the previous line).

This does represent a minor change to previous behaviour, but
it should not break anything that isn't already broken, i.e. it might
cause slightly odd behaviour if autofocus gives random results -
but probably indistinguishable from the current behaviour.
2022-04-06 23:15:25 +01:00
Richard Bowman
23bf3410f3 Code formatting fixes from black 2022-01-13 14:47:38 +00:00
Joe Knapper
2d494b41d9 Added docstring for measure_settling_time and hold 2022-01-11 15:46:15 +00:00
Joe Knapper
ecbdd8a5bf Added measure_settling_time function to autofocus 2021-12-01 13:09:32 +00:00
Kaspar Emanuel
13f7252dd7 Move Vue app to a js directory 2021-09-16 15:13:17 +01:00
Richard Bowman
515bee1422 Merge branch 'check-error-in-task-submitter-response' into 'master'
Move error handling for taskSubmitter

See merge request openflexure/openflexure-microscope-server!138
2021-09-07 14:57:25 +00:00
Richard
3d33218072 Move error handling for taskSubmitter
taskSubmitter ended up in a confused state if the initial POST request
encountered an error.
I've updated `startPolling` to return a Promise, and moved the
error handling code to the top level.

This doesn't change anything for the case where we get a non-error
response to the POST request, but means that e.g. 400 errors
get caught and displayed properly.
2021-08-26 23:12:47 +01:00
Richard
ae96340d79 Remove unused import 2021-08-23 20:53:04 +01:00
Richard Bowman
6a484514a9 Remove vestigial error handling code
LabThings now handles HTTPErrors properly, so I am removing
this copy-pasted workaround.
2021-08-23 16:08:50 +01:00
Richard Bowman
3e02fe4790 Merge branch 'static-docs' into 'master'
Improved API docs

See merge request openflexure/openflexure-microscope-server!133
2021-08-17 11:33:40 +00:00
Richard Bowman
040d7d4ba6 Fix action wrapper
The action wrapper was using an unbound function - it
now passes the extension object as self.

We were incorrectly passing endpoint names as positional arguments -
this is fixed and I now use a keyword argument.
2021-08-17 12:11:20 +01:00
Richard
b7c15886e9 Use neater spread operator to copy objects
Rather than Object.assign, I now use the ... operator to
ensure that dictionaries don't pollute each other in computed
properties.
2021-08-09 21:57:52 +01:00
Richard
332ecad19b Update caniuse-lite 2021-08-02 10:31:07 +01:00
Richard
3cdfd52a77 Added controls for smart stack 2021-07-25 09:14:33 +01:00
Richard
9fa545f3fa Typing fix
mypy doesn't like adding attributes to functions, so
I have used the described_operation decorator to
add type hints to the functions.
2021-07-25 03:38:20 +01:00
Richard
a8b1efb7cd Removed openapi endpoints (now in LabThings) 2021-07-25 01:23:44 +01:00
Richard
7b54abc210 blackened 2021-07-19 22:22:58 +01:00
Richard
34af06b1d1 Document route parameter in nested dictionaries 2021-07-19 22:21:39 +01:00
Richard
ec992c083f Describe filename param in capture download 2021-07-19 21:40:28 +01:00
Richard
36be07b276 Responses and parameters for zipbuilder 2021-07-19 21:32:08 +01:00
Richard
ba0f78df84 fix typing in autofocus
I have an Optional dz, which is then
populated with a default if it's None.
I've added an explicit cast() to explain this to mypy.
2021-07-19 21:18:25 +01:00
Richard
72f3c11fdd linting and typing fixes 2021-07-19 20:29:13 +01:00
Richard
b7c9d3b73b Sorted remaining content_type issues and blackened 2021-07-19 20:09:09 +01:00
Richard
38fbe530d2 Fix externalDocs entries
My externalDocs entries in the "tags" metadata section
of the OpenAPI description were not valid.
This is now fixed.
2021-07-19 11:56:40 +01:00
Richard
077d6fdc4b Added OpenAPI validation from apispec 2021-07-19 11:50:50 +01:00
Richard
6a7c305468 Started adding more content to openapi 2021-07-14 19:15:26 +01:00
Richard
48fa1842a9 Fixed stage schemas
If missing=None, we need to specify allow_None=False
in order to generate valid OpenAPI.
This may also be fixed by an upstream change in LabThings.

Also, OneOf was being used incorrectly in StageTypeProperty.
2021-07-13 22:53:35 +01:00
Richard
50ad9d4369 Fixed content dicts to be valid OpenAPI
For functions that return JPEGs, we were
 using "content_type": "image/jpeg"
 instead we should use "content": { "image/jpeg": {}}
2021-07-13 22:52:10 +01:00
Richard
9892c7079a moved find_microscope into functions 2021-07-13 22:50:42 +01:00
Richard
00531a93bf Fixed response descriptions for stream/RAM capture 2021-07-06 15:24:43 +01:00
Richard
c81c4eb64d Better API docs for autofocus extension 2021-07-06 15:24:17 +01:00
Richard
202d942c90 Add entry point to generate OpenAPI yaml/json
This is designed to be used as a console entry point so we can generate
the OpenAPI description without starting the server.
2021-07-06 15:23:42 +01:00
Richard Bowman
5b63745ad0 Merge branch 'imjoy-support' into 'master'
Added imjoy support

Closes #157

See merge request openflexure/openflexure-microscope-server!120
2021-06-29 12:08:52 +00:00
Richard
8157fa6d58 Add YAML export from APISpec 2021-06-27 21:08:48 +01:00
Richard
f5711d953d linter fixes 2021-06-22 12:09:01 +01:00
Richard
d73b0afd36 Disable ImJoy control
If the environment variable is disabling ImJoy, don't allow
the user to enable it with the tick-box.
2021-06-22 12:08:17 +01:00
Richard
33b3ffc7f7 Rely on store to enforce IMJOY_ENABLED
This removes some now-redundant code.
2021-06-22 12:07:27 +01:00
Richard
29de95fe74 Enforce ENABLE_IMJOY variable in store
The store now won't let you enable imjoy if the environment
variable is not set to "true"
2021-06-22 12:06:48 +01:00
Richard
3921f5de76 Remove commented-out code 2021-06-22 10:57:48 +01:00
Richard
03cb019864 Don't remember the "scanCapture" setting
Given that it changes the "capture" button from
single image acquisition to a long running scan,
I think it's less confusing if the "scan capture" setting
is not remembered across page refreshes.
2021-06-03 16:21:03 +01:00