diff --git a/docs/source/extensions/marshaling.rst b/docs/source/extensions/marshaling.rst index 9ee8f384..f56ae20b 100644 --- a/docs/source/extensions/marshaling.rst +++ b/docs/source/extensions/marshaling.rst @@ -37,8 +37,8 @@ For example, if you are creating an API route, in which you expect parameters `` .. code-block:: python - from labthings.server.schema import Schema - from labthings.server import fields + from labthings.schema import Schema + from labthings import fields class UserSchema(Schema): name = fields.String(required=True) diff --git a/docs/source/extensions/structure.rst b/docs/source/extensions/structure.rst index 053d4a4a..ee3ee0ce 100644 --- a/docs/source/extensions/structure.rst +++ b/docs/source/extensions/structure.rst @@ -1,10 +1,10 @@ Basic extension structure ========================= -An extension starts as a simple instance of :py:class:`labthings.server.extensions.BaseExtension`. +An extension starts as a simple instance of :py:class:`labthings.extensions.BaseExtension`. Each extension is described by a single ``BaseExtension`` instance, containing any number of methods, API views, and additional hardware components. -In order to access the currently running microscope object, use the :py:func:`labthings.server.find.find_component` function, with the argument ``"org.openflexure.microscope"``. Likewise, any new components attached by other extensions can be found using their full name, as above. +In order to access the currently running microscope object, use the :py:func:`labthings.find_component` function, with the argument ``"org.openflexure.microscope"``. Likewise, any new components attached by other extensions can be found using their full name, as above. A simple extension file, with no API views but application-available methods may look like: @@ -15,7 +15,7 @@ Once this extension is loaded, any other extensions will have access to your met .. code-block:: python - from labthings.server.find import find_extension + from labthings import find_extension def test_extension_method(): # Find your extension. Returns None if it hasn't been found. @@ -29,7 +29,7 @@ Once this extension is loaded, any other extensions will have access to your met Subclassing ``BaseExtension`` ------------------------------- -The syntax used above allows novice programmers to easily start building extensions, without having to deal with subclassing. However, for more complex extensions which require persistent state, subclassing :py:class:`labthings.server.extensions.BaseExtension` is recommended. +The syntax used above allows novice programmers to easily start building extensions, without having to deal with subclassing. However, for more complex extensions which require persistent state, subclassing :py:class:`labthings.extensions.BaseExtension` is recommended. The same simple extension as seen above can be written using subclassing: diff --git a/docs/source/extensions/tasks_locks.rst b/docs/source/extensions/tasks_locks.rst index f8ac83ae..6a5e9a18 100644 --- a/docs/source/extensions/tasks_locks.rst +++ b/docs/source/extensions/tasks_locks.rst @@ -32,7 +32,7 @@ An example of a long running task may look like: .. code-block:: python ... - from labthings.server.view import ActionView + from labthings import ActionView class SlowAPI(ActionView): def post(self): diff --git a/openflexure_microscope/api/default_extensions/zip_builder.py b/openflexure_microscope/api/default_extensions/zip_builder.py index 0445fd90..09d3bbec 100644 --- a/openflexure_microscope/api/default_extensions/zip_builder.py +++ b/openflexure_microscope/api/default_extensions/zip_builder.py @@ -47,7 +47,8 @@ class ZipObjectDescription: def close(self): logging.debug(self.fp.name) self.fp.close() - os.unlink(self.fp.name) + if os.path.exists(self.fp.name): + os.unlink(self.fp.name) assert not os.path.exists(self.fp.name) diff --git a/openflexure_microscope/api/static/src/components/genericComponents/taskProgress.vue b/openflexure_microscope/api/static/src/components/genericComponents/taskProgress.vue deleted file mode 100644 index 1f355d0f..00000000 --- a/openflexure_microscope/api/static/src/components/genericComponents/taskProgress.vue +++ /dev/null @@ -1,209 +0,0 @@ - - - - - diff --git a/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue b/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue index 488f0ed8..0d521b1b 100644 --- a/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue +++ b/openflexure_microscope/api/static/src/components/genericComponents/taskSubmitter.vue @@ -90,6 +90,7 @@ export default { data: function() { return { taskId: null, + taskUrl: null, polling: null, progress: null, taskStarted: false, @@ -150,6 +151,7 @@ export default { // Fetch the task ID console.log("Task ID: " + response.data.id); this.taskId = response.data.id; + this.taskUrl = response.data.href; // Start the store polling TaskId for success this.taskRunning = true; this.$emit("taskRunning", this.taskId); @@ -192,12 +194,12 @@ export default { var checkCondition = (resolve, reject) => { // If the condition is met, we're done! axios - .get(`${this.$store.getters.uriV2}/tasks/${taskId}`) + .get(this.taskUrl) .then(response => { console.log(response.data.status); var result = response.data.status; // If the task ends with success - if (result == "success") { + if (result == "completed") { resolve(response.data); } // If task ends with an error @@ -206,16 +208,10 @@ export default { reject(new Error(response.data.return)); } // If task ends with termination - else if (result == "terminated") { + else if (result == "cancelled") { // Pass a generic termination error back with reject - reject(new Error("Task terminated")); + reject(new Error("Task cancelled")); } - // If task ends in any other way - else if (result != "running") { - // Pass status string as error - reject(new Error(result)); - } - // Didn't match and too much time, reject! else { // Since the task is still running, we can update the progress bar this.progress = response.data.progress; @@ -232,7 +228,7 @@ export default { console.log("Starting progress polling"); axios - .get(`${this.$store.getters.uriV2}/tasks/${this.taskId}`) + .get(this.taskUrl) .then(response => { console.log("PROGRESS RESPONSE: ", response.data.progress); this.progress = response.data.progress; @@ -241,7 +237,7 @@ export default { terminateTask: function() { axios - .delete(`${this.$store.getters.uriV2}/tasks/${this.taskId}`) + .delete(this.taskUrl) .then(response => { console.log("TERMINATION RESPONSE: ", response.data); }); diff --git a/openflexure_microscope/api/static/src/components/viewComponents/galleryComponents/zipDownloader.vue b/openflexure_microscope/api/static/src/components/viewComponents/galleryComponents/zipDownloader.vue index c3eb4fbc..3c05c6df 100644 --- a/openflexure_microscope/api/static/src/components/viewComponents/galleryComponents/zipDownloader.vue +++ b/openflexure_microscope/api/static/src/components/viewComponents/galleryComponents/zipDownloader.vue @@ -166,7 +166,7 @@ export default { }, onResponse: function(response) { - this.lastSessionId = response.return.id; + this.lastSessionId = response.output.id; this.downloadUrl = `${this.zipGetterUri}/${this.lastSessionId}`; this.downloadReady = true; }, diff --git a/openflexure_microscope/camera/mock.py b/openflexure_microscope/camera/mock.py index 0b858cda..9f20b19b 100644 --- a/openflexure_microscope/camera/mock.py +++ b/openflexure_microscope/camera/mock.py @@ -204,6 +204,8 @@ class MissingCamera(BaseCamera): if isinstance(output, str): output.close() + else: + output.flush() # HANDLE STREAM FRAMES diff --git a/openflexure_microscope/captures/capture.py b/openflexure_microscope/captures/capture.py index 00777442..6364b205 100644 --- a/openflexure_microscope/captures/capture.py +++ b/openflexure_microscope/captures/capture.py @@ -129,7 +129,7 @@ class CaptureObject(object): # Store a nice ID self.id = uuid.uuid4() #: str: Unique capture ID - logging.debug("Created StreamObject {}".format(self.id)) + logging.debug("Created CaptureObject {}".format(self.id)) self.datetime = datetime.datetime.now() # Create file name. Default to UUID @@ -151,6 +151,7 @@ class CaptureObject(object): self.thumb_bytes = None def write(self, s): + logging.debug(f"Writing to {self}") self.stream.write(s) def flush(self): diff --git a/openflexure_microscope/microscope.py b/openflexure_microscope/microscope.py index 637d518c..db7b7f2a 100644 --- a/openflexure_microscope/microscope.py +++ b/openflexure_microscope/microscope.py @@ -354,7 +354,8 @@ class Microscope: ) # Capture to output object - logging.info(f"Starting microscope capture {filename}") + logging.info(f"Starting microscope capture {output.file}") + print(output) self.camera.capture( output, use_video_port=use_video_port,