Merge branch 'scan-shape-limits' into 'master'
Add minimum scan dimension See merge request openflexure/openflexure-microscope-server!123
This commit is contained in:
commit
4d405443bb
3 changed files with 26 additions and 4 deletions
|
|
@ -23,7 +23,7 @@ import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from flask import abort, send_file
|
from flask import abort, send_file, jsonify
|
||||||
from flask_cors import CORS, cross_origin
|
from flask_cors import CORS, cross_origin
|
||||||
from labthings import create_app
|
from labthings import create_app
|
||||||
from labthings.extensions import find_extensions
|
from labthings.extensions import find_extensions
|
||||||
|
|
@ -105,6 +105,20 @@ app, labthing = create_app(
|
||||||
# Enable CORS for some routes outside of LabThings
|
# Enable CORS for some routes outside of LabThings
|
||||||
cors: CORS = CORS(app)
|
cors: CORS = CORS(app)
|
||||||
|
|
||||||
|
# Enable correct handling of Marshmallow/Webargs validation errors
|
||||||
|
# Return validation errors as JSON
|
||||||
|
# (see https://webargs.readthedocs.io/en/latest/framework_support.html)
|
||||||
|
@app.errorhandler(422)
|
||||||
|
@app.errorhandler(400)
|
||||||
|
def handle_error(err):
|
||||||
|
headers = err.data.get("headers", None)
|
||||||
|
messages = err.data.get("messages", ["Invalid request."])
|
||||||
|
if headers:
|
||||||
|
return jsonify({"errors": messages}), err.code, headers
|
||||||
|
else:
|
||||||
|
return jsonify({"errors": messages}), err.code
|
||||||
|
|
||||||
|
|
||||||
# Use custom JSON encoder
|
# Use custom JSON encoder
|
||||||
labthing.json_encoder = JSONEncoder
|
labthing.json_encoder = JSONEncoder
|
||||||
app.json_encoder = JSONEncoder
|
app.json_encoder = JSONEncoder
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import datetime
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
import marshmallow
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from typing import Dict, List, Optional, Tuple
|
from typing import Dict, List, Optional, Tuple
|
||||||
|
|
||||||
|
|
@ -361,7 +362,11 @@ class ScanExtension(BaseExtension):
|
||||||
|
|
||||||
class TileScanArgs(FullCaptureArgs):
|
class TileScanArgs(FullCaptureArgs):
|
||||||
namemode = fields.String(missing="coordinates", example="coordinates")
|
namemode = fields.String(missing="coordinates", example="coordinates")
|
||||||
grid = fields.List(fields.Integer, missing=[3, 3, 3], example=[3, 3, 3])
|
grid = fields.List(
|
||||||
|
fields.Integer(validate=marshmallow.validate.Range(min=1)),
|
||||||
|
missing=[3, 3, 3],
|
||||||
|
example=[3, 3, 3],
|
||||||
|
)
|
||||||
style = fields.String(missing="raster")
|
style = fields.String(missing="raster")
|
||||||
autofocus_dz = fields.Integer(missing=50)
|
autofocus_dz = fields.Integer(missing=50)
|
||||||
fast_autofocus = fields.Boolean(missing=False)
|
fast_autofocus = fields.Boolean(missing=False)
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@
|
||||||
v-model="scanStepSize.z"
|
v-model="scanStepSize.z"
|
||||||
class="uk-input uk-form-small"
|
class="uk-input uk-form-small"
|
||||||
type="number"
|
type="number"
|
||||||
name="inputPositionZx"
|
name="inputPositionZ"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -172,6 +172,7 @@
|
||||||
class="uk-input uk-form-small"
|
class="uk-input uk-form-small"
|
||||||
type="number"
|
type="number"
|
||||||
name="inputPositionX"
|
name="inputPositionX"
|
||||||
|
min="1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -186,6 +187,7 @@
|
||||||
class="uk-input uk-form-small"
|
class="uk-input uk-form-small"
|
||||||
type="number"
|
type="number"
|
||||||
name="inputPositionY"
|
name="inputPositionY"
|
||||||
|
min="1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -199,7 +201,8 @@
|
||||||
v-model="scanSteps.z"
|
v-model="scanSteps.z"
|
||||||
class="uk-input uk-form-small"
|
class="uk-input uk-form-small"
|
||||||
type="number"
|
type="number"
|
||||||
name="inputPositionZx"
|
name="inputPositionZ"
|
||||||
|
min="1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue