Updated to new Action tasks
This commit is contained in:
parent
28e555ad9b
commit
eaf4cf09f5
9 changed files with 27 additions and 65 deletions
|
|
@ -1,9 +1,9 @@
|
|||
from labthings.server.find import find_component
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.view import View
|
||||
from labthings.server.decorators import ThingAction, ThingProperty, marshal_task
|
||||
from labthings.server.decorators import ThingAction, ThingProperty
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request, taskify, abort
|
||||
from openflexure_microscope.devel import JsonResponse, request, abort
|
||||
from openflexure_microscope.utilities import set_properties
|
||||
|
||||
import time
|
||||
|
|
@ -337,8 +337,6 @@ class AutofocusAPI(View):
|
|||
"""
|
||||
Run a standard autofocus
|
||||
"""
|
||||
|
||||
@marshal_task
|
||||
def post(self):
|
||||
payload = JsonResponse(request)
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
|
@ -351,10 +349,9 @@ class AutofocusAPI(View):
|
|||
|
||||
if microscope.has_real_stage():
|
||||
logging.debug("Running autofocus...")
|
||||
task = taskify(autofocus)(microscope, dz)
|
||||
|
||||
# return a handle on the autofocus task
|
||||
return task
|
||||
return autofocus(microscope, dz)
|
||||
|
||||
else:
|
||||
abort(503, "No stage connected. Unable to autofocus.")
|
||||
|
|
@ -365,8 +362,6 @@ class FastAutofocusAPI(View):
|
|||
"""
|
||||
Run a fast autofocus
|
||||
"""
|
||||
|
||||
@marshal_task
|
||||
def post(self):
|
||||
payload = JsonResponse(request)
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
|
@ -382,12 +377,11 @@ class FastAutofocusAPI(View):
|
|||
|
||||
if microscope.has_real_stage():
|
||||
logging.debug("Running autofocus...")
|
||||
task = taskify(fast_up_down_up_autofocus)(
|
||||
microscope, dz=dz, mini_backlash=backlash
|
||||
)
|
||||
|
||||
# return a handle on the autofocus task
|
||||
return task
|
||||
return fast_up_down_up_autofocus(
|
||||
microscope, dz=dz, mini_backlash=backlash
|
||||
)
|
||||
|
||||
else:
|
||||
abort(503, "No stage connected. Unable to autofocus.")
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@ from labthings.server.view import View
|
|||
from labthings.server.find import find_component
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.decorators import (
|
||||
marshal_task,
|
||||
ThingAction,
|
||||
use_args,
|
||||
ThingProperty,
|
||||
)
|
||||
from labthings.server import fields
|
||||
|
||||
from labthings.core.tasks import taskify
|
||||
from labthings.core.utilities import get_by_path, set_by_path, create_from_path
|
||||
|
||||
|
||||
|
|
@ -146,15 +144,12 @@ class Calibrate1DView(View):
|
|||
@use_args(
|
||||
{"direction": fields.List(fields.Float(), required=True, example=[1, 0, 0])}
|
||||
)
|
||||
@marshal_task
|
||||
def post(self, args):
|
||||
"""Calibrate one axis of the microscope stage against the camera."""
|
||||
|
||||
direction = np.array(args.get("direction"))
|
||||
|
||||
task = taskify(csm_extension.calibrate_1d)(direction)
|
||||
|
||||
return task
|
||||
return csm_extension.calibrate_1d(direction)
|
||||
|
||||
|
||||
csm_extension.add_view(Calibrate1DView, "/calibrate_1d", endpoint="calibrate_1d")
|
||||
|
|
@ -162,12 +157,9 @@ csm_extension.add_view(Calibrate1DView, "/calibrate_1d", endpoint="calibrate_1d"
|
|||
|
||||
@ThingAction
|
||||
class CalibrateXYView(View):
|
||||
@marshal_task
|
||||
def post(self):
|
||||
"""Calibrate both axes of the microscope stage against the camera."""
|
||||
task = taskify(csm_extension.calibrate_xy)()
|
||||
|
||||
return task
|
||||
return csm_extension.calibrate_xy()
|
||||
|
||||
|
||||
csm_extension.add_view(CalibrateXYView, "/calibrate_xy", endpoint="calibrate_xy")
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from labthings.server.view import View
|
||||
from labthings.server.find import find_component
|
||||
from labthings.server.extensions import BaseExtension
|
||||
from labthings.server.decorators import marshal_task, ThingAction
|
||||
|
||||
from labthings.core.tasks import taskify
|
||||
from labthings.server.decorators import ThingAction
|
||||
|
||||
from flask import abort
|
||||
|
||||
|
|
@ -62,7 +60,6 @@ def recalibrate(microscope):
|
|||
|
||||
@ThingAction
|
||||
class RecalibrateView(View):
|
||||
@marshal_task
|
||||
def post(self):
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
@ -71,7 +68,7 @@ class RecalibrateView(View):
|
|||
|
||||
logging.info("Starting microscope recalibration...")
|
||||
|
||||
return taskify(recalibrate)(microscope)
|
||||
return recalibrate(microscope)
|
||||
|
||||
|
||||
@ThingAction
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ 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 marshal_task, use_args, ThingAction
|
||||
from labthings.server.decorators import use_args, ThingAction
|
||||
from labthings.server import fields
|
||||
|
||||
from openflexure_microscope.devel import taskify, abort, update_task_progress
|
||||
from openflexure_microscope.devel import abort, update_task_progress
|
||||
|
||||
from labthings.server.view import View
|
||||
import time
|
||||
|
|
@ -309,7 +309,6 @@ class TileScanAPI(View):
|
|||
"resize": fields.Dict(missing=None), # TODO: Validate keys
|
||||
}
|
||||
)
|
||||
@marshal_task
|
||||
def post(self, args):
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
|
|
@ -327,7 +326,9 @@ class TileScanAPI(View):
|
|||
abort(404)
|
||||
|
||||
logging.info("Running tile scan...")
|
||||
task = taskify(tile)(
|
||||
|
||||
# return a handle on the scan task
|
||||
return tile(
|
||||
microscope,
|
||||
basename=args.get("filename"),
|
||||
temporary=args.get("temporary"),
|
||||
|
|
@ -343,9 +344,6 @@ class TileScanAPI(View):
|
|||
tags=args.get("tags"),
|
||||
)
|
||||
|
||||
# return a handle on the scan task
|
||||
return task
|
||||
|
||||
|
||||
scan_extension_v2 = BaseExtension("org.openflexure.scan", version="2.0.0")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from openflexure_microscope.devel import (
|
||||
JsonResponse,
|
||||
request,
|
||||
taskify,
|
||||
update_task_progress,
|
||||
)
|
||||
|
||||
|
|
@ -22,7 +21,6 @@ from labthings.server.utilities import description_from_view
|
|||
from labthings.server.decorators import (
|
||||
ThingAction,
|
||||
ThingProperty,
|
||||
marshal_task,
|
||||
marshal_with,
|
||||
pre_dump,
|
||||
)
|
||||
|
|
@ -142,19 +140,16 @@ default_zip_manager = ZipManager()
|
|||
|
||||
@ThingAction
|
||||
class ZipBuilderAPIView(View):
|
||||
@marshal_task
|
||||
def post(self):
|
||||
|
||||
ids = list(JsonResponse(request).json)
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
task = taskify(default_zip_manager.marshaled_build_zip_from_capture_ids)(
|
||||
# Return a handle on the autofocus task
|
||||
return default_zip_manager.marshaled_build_zip_from_capture_ids(
|
||||
microscope, ids
|
||||
)
|
||||
|
||||
# Return a handle on the autofocus task
|
||||
return task
|
||||
|
||||
|
||||
@ThingProperty
|
||||
class ZipListAPIView(View):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue