Loading openflexure_microscope/api/default_extensions/autofocus.py +13 −9 Original line number Diff line number Diff line from labthings.server.find import find_component from labthings.server.extensions import BaseExtension from labthings.server.view import View, ActionView, PropertyView from labthings.server.decorators import ThingAction, ThingProperty from labthings.server import fields from openflexure_microscope.devel import JsonResponse, request, abort from openflexure_microscope.utilities import set_properties Loading Loading @@ -336,7 +336,9 @@ class AutofocusAPI(ActionView): """ Run a standard autofocus """ def post(self): args = {"dz": fields.List(fields.Int())} def post(self, args): payload = JsonResponse(request) microscope = find_component("org.openflexure.microscope") Loading @@ -344,7 +346,7 @@ class AutofocusAPI(ActionView): abort(503, "No microscope connected. Unable to autofocus.") # Figure out the range of z values to use dz = payload.param("dz", default=np.linspace(-300, 300, 7), convert=np.array) dz = np.array(args.get("dz", np.linspace(-300, 300, 7))) if microscope.has_real_stage(): logging.debug("Running autofocus...") Loading @@ -360,18 +362,20 @@ class FastAutofocusAPI(ActionView): """ Run a fast autofocus """ def post(self): payload = JsonResponse(request) args = { "dz": fields.Int(default=2000), "backlash": fields.Int(default=25, minimum=0) } def post(self, args): microscope = find_component("org.openflexure.microscope") if not microscope: abort(503, "No microscope connected. Unable to autofocus.") # Figure out the parameters to use dz = payload.param("dz", default=2000, convert=int) backlash = payload.param("backlash", default=25, convert=int) if backlash < 0: backlash = 0 dz = args.get("dz") backlash = args.get("backlash") if microscope.has_real_stage(): logging.debug("Running autofocus...") Loading openflexure_microscope/api/default_extensions/autostorage.py +4 −3 Original line number Diff line number Diff line from labthings.server.extensions import BaseExtension from labthings.server.view import View, PropertyView from labthings.server.decorators import ThingProperty, PropertySchema, use_args from labthings.server import fields from labthings.server.find import find_component Loading Loading @@ -198,8 +197,9 @@ class GetLocationsView(PropertyView): return autostorage_extension_v2.get_locations() @PropertySchema(fields.String(required=True, example="Default")) class PreferredLocationView(PropertyView): schema = fields.String(required=True, example="Default") def get(self): global autostorage_extension_v2 Loading @@ -219,7 +219,8 @@ class PreferredLocationView(PropertyView): class PreferredLocationGUIView(View): @use_args({"new_path_title": fields.String(required=True)}) args = {"new_path_title": fields.String(required=True)} def post(self, args): global autostorage_extension_v2 Loading openflexure_microscope/api/default_extensions/scan.py +18 −20 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ from functools import reduce from openflexure_microscope.captures.capture_manager import generate_basename from labthings.server.find import find_component, find_extension from labthings.server.extensions import BaseExtension from labthings.server.decorators import use_args from labthings.server import fields from openflexure_microscope.devel import abort, update_task_progress Loading Loading @@ -91,7 +90,7 @@ class ScanExtension(BaseExtension): def __init__(self): self._images_to_be_captured: int = 1 self._images_captured_so_far: int = 0 return BaseExtension.__init__(self, "org.openflexure.scan", version="2.0.0") BaseExtension.__init__(self, "org.openflexure.scan", version="2.0.0") def progress(self): progress = (self._images_captured_so_far / self._images_to_be_captured) * 100 Loading Loading @@ -289,8 +288,7 @@ class ScanExtension(BaseExtension): scan_extension_v2 = ScanExtension() class TileScanAPI(ActionView): @use_args( { args = { "filename": fields.String(missing=None, example=None), "temporary": fields.Boolean(missing=False), "stride_size": fields.List( Loading @@ -306,7 +304,7 @@ class TileScanAPI(ActionView): "tags": fields.List(fields.String, missing=[]), "resize": fields.Dict(missing=None), # TODO: Validate keys } ) def post(self, args): microscope = find_component("org.openflexure.microscope") Loading openflexure_microscope/api/default_extensions/zip_builder.py +3 −9 Original line number Diff line number Diff line Loading @@ -14,16 +14,10 @@ import logging from labthings.server.find import find_component from labthings.server.view import View, ActionView, PropertyView from labthings.server.schema import Schema from labthings.server.schema import Schema, pre_dump from labthings.server import fields from labthings.server.extensions import BaseExtension from labthings.server.utilities import description_from_view from labthings.server.decorators import ( ThingAction, ThingProperty, marshal_with, pre_dump, ) class ZipObjectSchema(Schema): Loading Loading @@ -140,7 +134,6 @@ default_zip_manager = ZipManager() class ZipBuilderAPIView(ActionView): def post(self): ids = list(JsonResponse(request).json) microscope = find_component("org.openflexure.microscope") Loading @@ -151,7 +144,8 @@ class ZipBuilderAPIView(ActionView): class ZipListAPIView(PropertyView): @marshal_with(ZipObjectSchema(many=True)) schema = ZipObjectSchema(many=True) def get(self): return default_zip_manager.session_zips.values() Loading openflexure_microscope/api/v2/views/actions/__init__.py +0 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ def enabled_root_actions(): return {k: v for k, v in _actions.items() if v["conditions"]} # @Tag("actions") class ActionsView(View): def get(self): """ Loading Loading
openflexure_microscope/api/default_extensions/autofocus.py +13 −9 Original line number Diff line number Diff line from labthings.server.find import find_component from labthings.server.extensions import BaseExtension from labthings.server.view import View, ActionView, PropertyView from labthings.server.decorators import ThingAction, ThingProperty from labthings.server import fields from openflexure_microscope.devel import JsonResponse, request, abort from openflexure_microscope.utilities import set_properties Loading Loading @@ -336,7 +336,9 @@ class AutofocusAPI(ActionView): """ Run a standard autofocus """ def post(self): args = {"dz": fields.List(fields.Int())} def post(self, args): payload = JsonResponse(request) microscope = find_component("org.openflexure.microscope") Loading @@ -344,7 +346,7 @@ class AutofocusAPI(ActionView): abort(503, "No microscope connected. Unable to autofocus.") # Figure out the range of z values to use dz = payload.param("dz", default=np.linspace(-300, 300, 7), convert=np.array) dz = np.array(args.get("dz", np.linspace(-300, 300, 7))) if microscope.has_real_stage(): logging.debug("Running autofocus...") Loading @@ -360,18 +362,20 @@ class FastAutofocusAPI(ActionView): """ Run a fast autofocus """ def post(self): payload = JsonResponse(request) args = { "dz": fields.Int(default=2000), "backlash": fields.Int(default=25, minimum=0) } def post(self, args): microscope = find_component("org.openflexure.microscope") if not microscope: abort(503, "No microscope connected. Unable to autofocus.") # Figure out the parameters to use dz = payload.param("dz", default=2000, convert=int) backlash = payload.param("backlash", default=25, convert=int) if backlash < 0: backlash = 0 dz = args.get("dz") backlash = args.get("backlash") if microscope.has_real_stage(): logging.debug("Running autofocus...") Loading
openflexure_microscope/api/default_extensions/autostorage.py +4 −3 Original line number Diff line number Diff line from labthings.server.extensions import BaseExtension from labthings.server.view import View, PropertyView from labthings.server.decorators import ThingProperty, PropertySchema, use_args from labthings.server import fields from labthings.server.find import find_component Loading Loading @@ -198,8 +197,9 @@ class GetLocationsView(PropertyView): return autostorage_extension_v2.get_locations() @PropertySchema(fields.String(required=True, example="Default")) class PreferredLocationView(PropertyView): schema = fields.String(required=True, example="Default") def get(self): global autostorage_extension_v2 Loading @@ -219,7 +219,8 @@ class PreferredLocationView(PropertyView): class PreferredLocationGUIView(View): @use_args({"new_path_title": fields.String(required=True)}) args = {"new_path_title": fields.String(required=True)} def post(self, args): global autostorage_extension_v2 Loading
openflexure_microscope/api/default_extensions/scan.py +18 −20 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ from functools import reduce from openflexure_microscope.captures.capture_manager import generate_basename from labthings.server.find import find_component, find_extension from labthings.server.extensions import BaseExtension from labthings.server.decorators import use_args from labthings.server import fields from openflexure_microscope.devel import abort, update_task_progress Loading Loading @@ -91,7 +90,7 @@ class ScanExtension(BaseExtension): def __init__(self): self._images_to_be_captured: int = 1 self._images_captured_so_far: int = 0 return BaseExtension.__init__(self, "org.openflexure.scan", version="2.0.0") BaseExtension.__init__(self, "org.openflexure.scan", version="2.0.0") def progress(self): progress = (self._images_captured_so_far / self._images_to_be_captured) * 100 Loading Loading @@ -289,8 +288,7 @@ class ScanExtension(BaseExtension): scan_extension_v2 = ScanExtension() class TileScanAPI(ActionView): @use_args( { args = { "filename": fields.String(missing=None, example=None), "temporary": fields.Boolean(missing=False), "stride_size": fields.List( Loading @@ -306,7 +304,7 @@ class TileScanAPI(ActionView): "tags": fields.List(fields.String, missing=[]), "resize": fields.Dict(missing=None), # TODO: Validate keys } ) def post(self, args): microscope = find_component("org.openflexure.microscope") Loading
openflexure_microscope/api/default_extensions/zip_builder.py +3 −9 Original line number Diff line number Diff line Loading @@ -14,16 +14,10 @@ import logging from labthings.server.find import find_component from labthings.server.view import View, ActionView, PropertyView from labthings.server.schema import Schema from labthings.server.schema import Schema, pre_dump from labthings.server import fields from labthings.server.extensions import BaseExtension from labthings.server.utilities import description_from_view from labthings.server.decorators import ( ThingAction, ThingProperty, marshal_with, pre_dump, ) class ZipObjectSchema(Schema): Loading Loading @@ -140,7 +134,6 @@ default_zip_manager = ZipManager() class ZipBuilderAPIView(ActionView): def post(self): ids = list(JsonResponse(request).json) microscope = find_component("org.openflexure.microscope") Loading @@ -151,7 +144,8 @@ class ZipBuilderAPIView(ActionView): class ZipListAPIView(PropertyView): @marshal_with(ZipObjectSchema(many=True)) schema = ZipObjectSchema(many=True) def get(self): return default_zip_manager.session_zips.values() Loading
openflexure_microscope/api/v2/views/actions/__init__.py +0 −1 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ def enabled_root_actions(): return {k: v for k, v in _actions.items() if v["conditions"]} # @Tag("actions") class ActionsView(View): def get(self): """ Loading