Moved to a LabThings dependency for server

This commit is contained in:
jtc42 2020-01-17 15:13:32 +00:00
parent a1223d8b28
commit 36334ed743
65 changed files with 546 additions and 2364 deletions

View file

@ -10,6 +10,8 @@ if "%SPHINXBUILD%" == "" (
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXOPTS="-E"
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL

View file

@ -3,5 +3,5 @@ Classes and Modules
Extension class
---------------
.. autoclass:: openflexure_microscope.common.flask_labthings.extensions.BaseExtension
.. autoclass:: labthings.server.extensions.BaseExtension
:members:

View file

@ -2,7 +2,7 @@ from openflexure_microscope.plugins import MicroscopePlugin
from openflexure_microscope.api.views import MicroscopeViewPlugin
from openflexure_microscope.api.utilities import JsonResponse
from openflexure_microscope.common.labthings_core.tasks import taskify
from labthings.core.tasks import taskify
import os
import time

View file

@ -21,7 +21,7 @@ Tasks are introduced to manage long-running functions in a way that does not blo
the use of tasks, long-running functions would block an HTTP response until the function returns, often
resulting in a timeout.
To prevent this, any function can be offloaded to a background task. This is done through the :py:meth:`openflexure_microscope.common.tasks.taskify`
To prevent this, any function can be offloaded to a background task. This is done through the :py:meth:`labthings.tasks.taskify`
function, by calling ``taskify(<long_running_function>)(*args, **kwargs)``. Internally, the ``tasks`` submodule stores a list
of all requested tasks, which themselves contain a ``state`` dictionary. This dictionary stores the status of the task (if it
is idle, running, error, or success), information about the start and end times, a unique task ID, and the return value of
@ -38,7 +38,7 @@ An example of a long running task may look like:
.. code-block:: python
from openflexure_microscope.plugins import MicroscopeViewPlugin
from openflexure_microscope.common.tasks import taskify
from labthings.tasks import taskify
class MyPlugin(MicroscopeViewPlugin):
def post(self):
@ -63,7 +63,7 @@ the microscope hardware. For example, even if the stage is not actively moving (
within a tile scan), another user should not be able to move the microscope, interrupting the task. Thread locks act
to prevent this.
The camera and stage both contain an instance of :py:class:`openflexure_microscope.common.lock.StrictLock`, named ``lock``.
The camera and stage both contain an instance of :py:class:`labthings.lock.StrictLock`, named ``lock``.
Built-in functions such as capture and move will always acquire this lock for the duration of the function. This ensures
that, for example, simultaneous attemps to move do not occur.
@ -77,7 +77,7 @@ For example, a timelapse plugin may look like:
from openflexure_microscope.api.v1.views import MicroscopeViewPlugin
from openflexure_microscope.api.utilities import JsonResponse
from openflexure_microscope.common.tasks import taskify
from labthings.tasks import taskify
### MICROSCOPE PLUGIN ###

View file

@ -1,17 +1,17 @@
Basic extension structure
=========================
An extension starts as a simple instance of :py:class:`openflexure_microscope.common.flask_labthings.extensions.BaseExtension`.
An extension starts as a simple instance of :py:class:`labthings.server.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:`openflexure_microscope.common.flask_labthings.find` 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.server.find` 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:
.. code-block:: python
from openflexure_microscope.common.flask_labthings.extensions import BaseExtension
from openflexure_microscope.common.flask_labthings.find import find_component
from labthings.server.extensions import BaseExtension
from labthings.server.find import find_component
def identify():
@ -50,7 +50,7 @@ Once this extension is loaded, any other extensions will have access to your met
.. code-block:: python
from openflexure_microscope.common.flask_labthings.find import find_extension
from labthings.server.find import find_extension
def test_extension_method():
# Find your extension. Returns None if it hasn't been found.