├── ot2_controller ├── feature_implementations │ ├── __init__.py │ └── ot2controller_impl.py ├── generated │ ├── __init__.py │ ├── ot2controller │ │ ├── ot2controller_feature.py │ │ ├── ot2controller_types.py │ │ ├── __init__.py │ │ ├── ot2controller_errors.py │ │ ├── ot2controller_client.pyi │ │ ├── ot2controller_base.py │ │ └── Ot2Controller.sila.xml │ └── client.py ├── __init__.py ├── server.py └── __main__.py ├── MANIFEST.in ├── AUTHORS ├── doc ├── pics │ └── ExportCalibration.png └── UserGuide.md ├── setup.py ├── .gitignore ├── README.md └── LICENSE /ot2_controller/feature_implementations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include ot2-controller/generated/*/*.sila.xml -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Florian Bauer 2 | Niklas Mertsch 3 | noparis 4 | -------------------------------------------------------------------------------- /ot2_controller/generated/__init__.py: -------------------------------------------------------------------------------- 1 | from .client import Client 2 | 3 | __all__ = ["Client"] 4 | -------------------------------------------------------------------------------- /doc/pics/ExportCalibration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlorianBauer/ot2-controller/HEAD/doc/pics/ExportCalibration.png -------------------------------------------------------------------------------- /ot2_controller/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.3.0" 2 | 3 | from .generated import Client 4 | from .server import Server 5 | 6 | __all__ = [ 7 | "__version__", 8 | "Client", 9 | "Server", 10 | ] 11 | -------------------------------------------------------------------------------- /ot2_controller/generated/ot2controller/ot2controller_feature.py: -------------------------------------------------------------------------------- 1 | from os.path import dirname, join 2 | 3 | from sila2.framework import Feature 4 | 5 | Ot2ControllerFeature = Feature(open(join(dirname(__file__), "Ot2Controller.sila.xml")).read()) 6 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import find_packages, setup 2 | 3 | setup( 4 | name="ot2_controller", 5 | version="0.3.0", 6 | author="Florian Bauer", 7 | author_email="", 8 | packages=find_packages(), 9 | install_requires=[ 10 | "paramiko >=2.7.2, <2.9.0", 11 | "scp <=0.13.2, <0.15.0", 12 | "sila2 ==0.10.4", 13 | ], 14 | include_package_data=True, 15 | ) 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Temporary and core files 2 | ~* 3 | *.~* 4 | core 5 | 6 | # Python related directories and files 7 | venv/ 8 | env/ 9 | __pycache__/ 10 | *.pyc 11 | [Bb]uild/ 12 | ot2_controller.egg-info/ 13 | 14 | # PyCharm / InteliJ projects folder 15 | .idea/ 16 | 17 | # Unused generated files from the silacodegenerator 18 | /Ot2Controller_client.py 19 | /Ot2Controller/Ot2Controller_default_arguments.py 20 | 21 | # Key and cert files 22 | *.crt 23 | *.cert 24 | *.key 25 | -------------------------------------------------------------------------------- /ot2_controller/generated/ot2controller/ot2controller_types.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from datetime import datetime 4 | from typing import NamedTuple 5 | 6 | 7 | class CameraPicture_Response(NamedTuple): 8 | ImageData: bytes 9 | """The *.jpg image""" 10 | ImageTimestamp: datetime 11 | """The timestamp when the image was taken""" 12 | 13 | class CameraMovie_Response(NamedTuple): 14 | VideoData: bytes 15 | """The *.mp4 video""" 16 | VideoTimestamp: datetime 17 | """The timestamp when the video was taken""" -------------------------------------------------------------------------------- /ot2_controller/generated/ot2controller/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | 3 | from .ot2controller_base import Ot2ControllerBase 4 | from .ot2controller_errors import RemoveFileFailed, UploadFileFailed 5 | from .ot2controller_feature import Ot2ControllerFeature 6 | from .ot2controller_types import CameraPicture_Response, CameraMovie_Response 7 | 8 | __all__ = [ 9 | "Ot2ControllerBase", 10 | "Ot2ControllerFeature", 11 | "CameraPicture_Response", 12 | "CameraMovie_Response", 13 | "UploadFileFailed", 14 | "RemoveFileFailed", 15 | ] 16 | 17 | if TYPE_CHECKING: 18 | from .ot2controller_client import Ot2ControllerClient # noqa: F401 19 | 20 | __all__.append("Ot2ControllerClient") 21 | -------------------------------------------------------------------------------- /ot2_controller/generated/client.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import TYPE_CHECKING 4 | 5 | from sila2.client import SilaClient 6 | 7 | from .ot2controller import Ot2ControllerFeature, RemoveFileFailed, UploadFileFailed 8 | 9 | if TYPE_CHECKING: 10 | 11 | from .ot2controller import Ot2ControllerClient 12 | 13 | 14 | class Client(SilaClient): 15 | 16 | Ot2Controller: Ot2ControllerClient 17 | 18 | def __init__(self, *args, **kwargs): 19 | super().__init__(*args, **kwargs) 20 | 21 | self._register_defined_execution_error_class( 22 | Ot2ControllerFeature.defined_execution_errors["UploadFileFailed"], UploadFileFailed 23 | ) 24 | 25 | self._register_defined_execution_error_class( 26 | Ot2ControllerFeature.defined_execution_errors["RemoveFileFailed"], RemoveFileFailed 27 | ) 28 | -------------------------------------------------------------------------------- /ot2_controller/generated/ot2controller/ot2controller_errors.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Optional 4 | 5 | from sila2.framework.errors.defined_execution_error import DefinedExecutionError 6 | 7 | from .ot2controller_feature import Ot2ControllerFeature 8 | 9 | 10 | class UploadFileFailed(DefinedExecutionError): 11 | def __init__(self, message: Optional[str] = None): 12 | if message is None: 13 | message = "The upload of the file to the OT-2 device failed." 14 | super().__init__(Ot2ControllerFeature.defined_execution_errors["UploadFileFailed"], message=message) 15 | 16 | 17 | class RemoveFileFailed(DefinedExecutionError): 18 | def __init__(self, message: Optional[str] = None): 19 | if message is None: 20 | message = "The file on the OT-2 device does not exist or could not be removed." 21 | super().__init__(Ot2ControllerFeature.defined_execution_errors["RemoveFileFailed"], message=message) 22 | -------------------------------------------------------------------------------- /ot2_controller/server.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | from uuid import UUID 3 | 4 | from sila2.server import SilaServer 5 | 6 | from . import __version__ 7 | from .feature_implementations.ot2controller_impl import Ot2ControllerImpl 8 | from .generated.ot2controller import Ot2ControllerFeature 9 | 10 | 11 | class Server(SilaServer): 12 | def __init__(self, ot2_ip_address: str, server_uuid: Optional[UUID] = None): 13 | super().__init__( 14 | server_name="Ot2Controller", 15 | server_type="OpentronsOt2Controller", 16 | server_version=__version__, 17 | server_description=( 18 | "A SiLA 2 service enabling the execution of python protocols on a Opentrons 2 liquid handler." 19 | ), 20 | server_vendor_url="https://github.com/FlorianBauer/ot2-controller", 21 | server_uuid=server_uuid, 22 | ) 23 | 24 | self.ot2controller = Ot2ControllerImpl(device_ip=ot2_ip_address) 25 | 26 | self.set_feature_implementation(Ot2ControllerFeature, self.ot2controller) 27 | -------------------------------------------------------------------------------- /ot2_controller/generated/ot2controller/ot2controller_client.pyi: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import Any, Iterable, List, Optional 4 | 5 | from ot2controller_types import RemoveProtocol_Responses, RunProtocol_Responses, UploadProtocol_Responses, CameraMovie_Response 6 | from sila2.client import ClientMetadataInstance, ClientUnobservableProperty 7 | 8 | class Ot2ControllerClient: 9 | """ 10 | A SiLA 2 complaint controller for an OT-2 liquid handler. 11 | """ 12 | 13 | Connection: ClientUnobservableProperty[str] 14 | """ 15 | Connection details of the remote OT-2. 16 | """ 17 | 18 | AvailableProtocols: ClientUnobservableProperty[List[str]] 19 | """ 20 | List of the stored files available on the OT-2. 21 | """ 22 | 23 | CameraPicture: ClientUnobservableProperty[Any] 24 | """ 25 | A current picture from the inside of the OT-2 made with the built-in camera. 26 | """ 27 | 28 | def UploadProtocol( 29 | self, ProtocolSourcePath: str, *, metadata: Optional[Iterable[ClientMetadataInstance]] = None 30 | ) -> UploadProtocol_Responses: 31 | """ 32 | Uploads the given Protocol to the "/data/user_storage" directory on the OT-2. 33 | """ 34 | ... 35 | def RemoveProtocol( 36 | self, ProtocolFile: str, *, metadata: Optional[Iterable[ClientMetadataInstance]] = None 37 | ) -> RemoveProtocol_Responses: 38 | """ 39 | Removes the given Protocol from the "/data/user_storage" directory on the OT-2. 40 | """ 41 | ... 42 | def RunProtocol( 43 | self, ProtocolFile: str, IsSimulating: bool, *, metadata: Optional[Iterable[ClientMetadataInstance]] = None 44 | ) -> RunProtocol_Responses: 45 | """ 46 | Runs the given Protocol on the OT-2. 47 | """ 48 | ... 49 | def CameraMovie( 50 | self, LengthOfVideo: str, *, metadata: Optional[Iterable[ClientMetadataInstance]] = None 51 | ) -> CameraMovie_Response: 52 | """ 53 | A current video from the inside of the OT-2 made with the built-in camera. 54 | """ 55 | ... -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Opentrons OT-2 SiLA 2 Server 2 | A [SiLA 2](https://sila-standard.com/) compliant controller for an Opentrons [OT-2 Liquid Handler](https://opentrons.com/ot-2/). 3 | For a short function overview, and a description on how to use this software, take a look into the [User Guide](doc/UserGuide.md). 4 | 5 | ## Requirements 6 | **1. Clone this git repository:** 7 | ``` 8 | git clone https://github.com/FlorianBauer/ot2-controller 9 | cd ot2-controller 10 | ``` 11 | 12 | **2. (Optional) Set up and source a Python environment:** 13 | ``` 14 | python3 -m venv ./venv 15 | source venv/bin/activate 16 | ``` 17 | 18 | **3. Install the Python package:** 19 | ``` 20 | pip install . 21 | ``` 22 | 23 | **4. Establish an SSH connection:** 24 | Before the actual installation, an SSH connection to the OT-2 device has to be established. 25 | This requires to generate a pair of SSH keys, as well as the configuration of the OT-2 device 26 | itself. To do this, please follow the steps described in this article: 27 | [SSH for OT-2](https://support.opentrons.com/en/articles/3203681-setting-up-ssh-access-to-your-ot-2) 28 | 29 | ## Installation 30 | Use the generated key from step 4 and register it on the client. 31 | ```bash 32 | sudo ssh-copy-id -i ~/.ssh/ot2_ssh_key `whoami`@`hostname` 33 | # e.g. sudo ssh-copy-id -i ~/.ssh/ot2_ssh_key username@my_host.org 34 | ``` 35 | Ensure the packages `openssh-server` and `openssh-client` are installed. If not, install with 36 | `apt install openssh-server openssh-client`. 37 | 38 | _Some additional useful links for troubleshooting:_ 39 | * https://hackersandslackers.com/automate-ssh-scp-python-paramiko/ 40 | * https://askubuntu.com/questions/685890/ssh-connect-t-host-slave-1-port-22-connection-refused 41 | 42 | ## Start the Server 43 | 44 | Now execute `python3 -m ot2_controller --ot2-ip-address IP` with the corresponding OT-2 device IP (e.g. with 45 | `python3 -m ot2_controller --ot2-ip-address 169.254.92.42`). 46 | 47 | The SiLA server should now be available on localhost (`127.0.0.1`) on the port `50064`. 48 | 49 | Terminate the server by pressing the Enter key in the running terminal window. 50 | 51 | A more detailed description can be found in the [User Guide](doc/UserGuide.md). 52 | 53 | ## General Remarks 54 | The SiLA server is currently only able to run on a host computer which has to be connected to 55 | the OT-2 device via SSH. Since the OT-2 robot itself is also running a Linux OS on its 56 | [build-in Raspberry Pi 3+](https://support.opentrons.com/en/articles/2715311-integrating-the-ot-2-with-other-lab-equipment), 57 | it may be possible to install the SiLA server and the corresponding 58 | [sila2](https://gitlab.com/SiLA2/legacy/sila_python) libraries on to the OT-2 directly. 59 | Pull requests and instructions regarding this are gladly welcome. 60 | -------------------------------------------------------------------------------- /ot2_controller/generated/ot2controller/ot2controller_base.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from abc import ABC, abstractmethod 4 | from typing import Any, Dict, List 5 | 6 | from sila2.framework import FullyQualifiedIdentifier 7 | from sila2.server import FeatureImplementationBase 8 | 9 | from .ot2controller_types import CameraPicture_Response, CameraMovie_Response 10 | 11 | 12 | class Ot2ControllerBase(FeatureImplementationBase, ABC): 13 | 14 | """ 15 | A SiLA 2 complaint controller for an OT-2 liquid handler. 16 | """ 17 | 18 | @abstractmethod 19 | def get_Connection(self, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> str: 20 | """ 21 | Connection details of the remote OT-2. 22 | 23 | :param metadata: The SiLA Client Metadata attached to the call 24 | :return: Connection details of the remote OT-2. 25 | """ 26 | pass 27 | 28 | @abstractmethod 29 | def get_AvailableProtocols(self, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> List[str]: 30 | """ 31 | List of the stored files available on the OT-2. 32 | 33 | :param metadata: The SiLA Client Metadata attached to the call 34 | :return: List of the stored files available on the OT-2. 35 | """ 36 | pass 37 | 38 | @abstractmethod 39 | def get_CameraPicture(self, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> CameraPicture_Response: 40 | """ 41 | A current picture from the inside of the OT-2 made with the built-in camera. 42 | 43 | :param metadata: The SiLA Client Metadata attached to the call 44 | :return: A current picture from the inside of the OT-2 made with the built-in camera. 45 | """ 46 | pass 47 | 48 | @abstractmethod 49 | def UploadProtocol(self, ProtocolSourcePath: str, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> None: 50 | """ 51 | Uploads the given Protocol to the "/data/user_storage" directory on the OT-2. 52 | 53 | :param ProtocolSourcePath: The path to the Protocol to upload. 54 | :param metadata: The SiLA Client Metadata attached to the call 55 | """ 56 | pass 57 | 58 | @abstractmethod 59 | def RemoveProtocol(self, ProtocolFile: str, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> None: 60 | """ 61 | Removes the given Protocol from the "/data/user_storage" directory on the OT-2. 62 | 63 | :param ProtocolFile: The file name of the Protocol to remove. 64 | :param metadata: The SiLA Client Metadata attached to the call 65 | """ 66 | pass 67 | 68 | @abstractmethod 69 | def RunProtocol( 70 | self, ProtocolFile: str, IsSimulating: bool, *, metadata: Dict[FullyQualifiedIdentifier, Any] 71 | ) -> int: 72 | """ 73 | Runs the given Protocol on the OT-2. 74 | 75 | :param ProtocolFile: The file name of the Protocol to run. 76 | :param IsSimulating: Defines whether the protocol gets just simulated or actually executed on the device. 77 | :param metadata: The SiLA Client Metadata attached to the call 78 | :return: 79 | 80 | - ReturnValue: The returned value from the executed protocol. On a simulated execution, only the value 0 81 | is indicating a successful simulation. 82 | """ 83 | pass 84 | 85 | @abstractmethod 86 | def CameraMovie(self, LengthOfVideo: str, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> CameraMovie_Response: 87 | """ 88 | A current video from the inside of the OT-2 made with the built-in camera. 89 | 90 | :param lengthOfVideo: length of the video 91 | :param metadata: The SiLA Client Metadata attached to the call 92 | :return: A current movie from the inside of the OT-2 made with the built-in camera. 93 | """ 94 | pass 95 | -------------------------------------------------------------------------------- /ot2_controller/__main__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from argparse import ArgumentParser 3 | from typing import Optional 4 | from uuid import UUID 5 | 6 | from ot2_controller.server import Server 7 | 8 | logger = logging.getLogger(__name__) 9 | 10 | 11 | def parse_args(): 12 | parser = ArgumentParser(prog="ot2-controller", description="Start this SiLA 2 server") 13 | 14 | parser.add_argument("-o", "--ot2-ip-address", required=True, help="The IP address of the Opentrons OT-2 system") 15 | 16 | parser.add_argument("-a", "--ip-address", default="127.0.0.1", help="The IP address (default: '127.0.0.1')") 17 | parser.add_argument("-p", "--port", type=int, default=50064, help="The port (default: 50064)") 18 | parser.add_argument("--server-uuid", type=UUID, default=None, help="The server UUID (default: create random UUID)") 19 | parser.add_argument("--disable-discovery", action="store_true", help="Disable SiLA Server Discovery") 20 | 21 | parser.add_argument("--insecure", action="store_true", help="Start without encryption") 22 | parser.add_argument("-k", "--private-key-file", default=None, help="Private key file (e.g. 'server-key.pem')") 23 | parser.add_argument("-c", "--cert-file", default=None, help="Certificate file (e.g. 'server-cert.pem')") 24 | parser.add_argument( 25 | "--ca-export-file", 26 | default=None, 27 | help="When using a self-signed certificate, write the generated CA to this file", 28 | ) 29 | 30 | log_level_group = parser.add_mutually_exclusive_group() 31 | log_level_group.add_argument("-q", "--quiet", action="store_true", help="Only log errors") 32 | log_level_group.add_argument("-v", "--verbose", action="store_true", help="Enable verbose logging") 33 | log_level_group.add_argument("-d", "--debug", action="store_true", help="Enable debug logging") 34 | 35 | return parser.parse_args() 36 | 37 | 38 | def run_server(args): 39 | # prepare args 40 | ot2_ip_address: str = args.ot2_ip_address 41 | insecure: bool = args.insecure 42 | cert: Optional[bytes] = open(args.cert_file, "rb").read() if args.cert_file is not None else None 43 | private_key: Optional[bytes] = ( 44 | open(args.private_key_file, "rb").read() if args.private_key_file is not None else None 45 | ) 46 | ca_export_file: Optional[str] = args.ca_export_file 47 | address: str = args.ip_address 48 | port: int = args.port 49 | enable_discovery: bool = not args.disable_discovery 50 | server_uuid: Optional[UUID] = args.server_uuid 51 | 52 | if (insecure or ca_export_file is not None) and (cert is not None or private_key is not None): 53 | raise ValueError("Cannot use --insecure or --ca-export-file with --private-key-file or --cert-file") 54 | if sum(par is None for par in (cert, private_key)) not in (0, 2): 55 | raise ValueError("Either provide both --private-key-file and --cert-file, or none of them") 56 | if insecure and ca_export_file is not None: 57 | raise ValueError("Cannot use --export-ca-file with --insecure") 58 | 59 | # run server 60 | server = Server(ot2_ip_address=ot2_ip_address, server_uuid=server_uuid) 61 | try: 62 | if insecure: 63 | server.start_insecure(address, port, enable_discovery=enable_discovery) 64 | else: 65 | server.start(address, port, cert_chain=cert, private_key=private_key, enable_discovery=enable_discovery) 66 | if ca_export_file is not None: 67 | with open(ca_export_file, "wb") as fp: 68 | fp.write(server.generated_ca) 69 | print(f"Wrote generated CA to '{ca_export_file}'") 70 | print("Server startup complete, press Enter to stop") 71 | 72 | try: 73 | input() 74 | except KeyboardInterrupt: 75 | pass 76 | finally: 77 | server.stop() 78 | print("Stopped server") 79 | 80 | 81 | def setup_basic_logging(args): 82 | level = logging.WARNING 83 | if args.verbose: 84 | level = logging.INFO 85 | if args.debug: 86 | level = logging.DEBUG 87 | if args.quiet: 88 | level = logging.ERROR 89 | 90 | logging.basicConfig(level=level, format="%(asctime)s:%(levelname)s:%(name)s:%(message)s") 91 | 92 | 93 | if __name__ == "__main__": 94 | args = parse_args() 95 | setup_basic_logging(args) 96 | run_server(args) 97 | -------------------------------------------------------------------------------- /doc/UserGuide.md: -------------------------------------------------------------------------------- 1 | # User Guide 2 | This guide provides a short descriptions of the available functionalities of the ot2-controller and how to use them. Instructions on how to install the software can be found in the [README](../README.md). 3 | 4 | ## Feature Overview 5 | OT-2 Controller Feature 6 | 7 | Properties: 8 | - **Available Protocols**: Lists all available python protocols installed on the OT-2 device. 9 | - **Camera Picture**: Takes a current picture (*.jpeg) from the deck with the build-in camera. 10 | - **Connection**: Shows some details about the Connection (e.g. IP-Address and SSH-key fingerprint). 11 | 12 | Commands: 13 | - **Upload Protocol**: Uploads a given protocol from the host on the device. Therefore, the path to the python file on the host must be given (e.g. `/home/user/my_protocol.py`). 14 | - **Run Protocol**: Runs (or simulates the run) of the given protocol. Therefore, the name of the uploaded file must be given including the `.py` suffix (e.g. `my_protocol.py`). 15 | - **Remove Protocol**: Removes the uploaded file from the device (e.g. `my_protocl.py`). 16 | 17 | ## Server Start-Up 18 | Ensure all installation steps as described in the [README](../README.md) were completed before you continue. 19 | 20 | 1. Turn on the OT-2 (obviously). 21 | 22 | 2. Establish a network connection to the OT-2: 23 | This can be achieved via the Opentrons App. Thereby, it doesn't matter if the device is connected via [USB](https://support.opentrons.com/en/articles/2687586-get-started-connect-to-your-ot-2-over-usb) or [Wi-Fi](https://support.opentrons.com/en/articles/2687573-get-started-connect-to-your-ot-2-over-wi-fi-optional). 24 | 25 | 3. Start the SiLA-Server: 26 | To start-up the server, the IP-Address of the OT-2 must be given via the `-o/--ot2-ip-address` argument. The Address can be looked up in the Opentrons App. It is recommended to [set a static IP-Address](https://support.opentrons.com/en/articles/2934336-manually-adding-a-robot-s-ip-address), otherwise the IP-Address may change on every device restart. 27 | 28 | Now, start the server with the actual IP-Address. 29 | ``` 30 | # If working with an virtual environment, don't forget to export the environment variables first. 31 | # source path/to/venv/bin/activate 32 | python3 -m ot2_controller -o 169.254.92.42 33 | ``` 34 | 35 | The SiLA server should now be available on localhost (`127.0.0.1`) on the default port `50064`. 36 | Use `-a/--ip-address IP` and `-p/--port PORT` to explicitly set the host address. 37 | 38 | A universal SiLA 2 client to inspect and test the available service(s) can be found here: 39 | [sila-orchestrator](https://github.com/FlorianBauer/sila-orchestrator) 40 | 41 | To terminate the server, press the Enter key in the running terminal window. 42 | 43 | **Troubleshooting:** 44 | If no connection to the SiLA server could be established, check if the [SSH Keys](https://support.opentrons.com/en/articles/3203681-setting-up-ssh-access-to-your-ot-2) are properly installed on the OT-2 and the SiLA server host. 45 | 46 | ## Server Arguments 47 | See `python3 -m ot2_controller --help` for a full list: 48 | 49 | ``` 50 | usage: ot2-controller [-h] -o OT2_IP_ADDRESS [-a IP_ADDRESS] [-p PORT] 51 | [--server-uuid SERVER_UUID] [--disable-discovery] 52 | [--insecure] [-k PRIVATE_KEY_FILE] [-c CERT_FILE] 53 | [--ca-export-file CA_EXPORT_FILE] [-q | -v | -d] 54 | 55 | Start this SiLA 2 server 56 | 57 | optional arguments: 58 | -h, --help show this help message and exit 59 | -o OT2_IP_ADDRESS, --ot2-ip-address OT2_IP_ADDRESS 60 | The IP address of the Opentrons OT-2 system 61 | -a IP_ADDRESS, --ip-address IP_ADDRESS 62 | The IP address (default: '127.0.0.1') 63 | -p PORT, --port PORT The port (default: 50064) 64 | --server-uuid SERVER_UUID 65 | The server UUID (default: create random UUID) 66 | --disable-discovery Disable SiLA Server Discovery 67 | --insecure Start without encryption 68 | -k PRIVATE_KEY_FILE, --private-key-file PRIVATE_KEY_FILE 69 | Private key file (e.g. 'server-key.pem') 70 | -c CERT_FILE, --cert-file CERT_FILE 71 | Certificate file (e.g. 'server-cert.pem') 72 | --ca-export-file CA_EXPORT_FILE 73 | When using a self-signed certificate, write the 74 | generated CA to this file 75 | -q, --quiet Only log errors 76 | -v, --verbose Enable verbose logging 77 | -d, --debug Enable debug logging 78 | ``` 79 | 80 | ## Using Protocols 81 | This requires installation of the [Opentrons Python library](https://pypi.org/project/opentrons/): `pip install opentrons`. 82 | Since the Python protocols are executed directly on the robot hardware, the initial calibration steps are omitted. Incorrect positioning of the pipettes may be the consequence. To avoid this, it is possible to set the desired calibration offsets manually within the protocol. Therefore, the offset values must be gathered empirically through testing or can be extracted from the *.json file exported from the Opentrons App itself (see picture). 83 | 84 | ![Export OT-2 calibration data](pics/ExportCalibration.png) 85 | 86 | The following example shows how the offset values are used in the protocol: 87 | 88 | ```python 89 | # ... 90 | from opentrons.types import Point 91 | # ... 92 | 93 | # The used offsets are defined here. The concrete values can be gathered manually or copied from 94 | # an existing file (e.g. from the *.json file exported from the Opentrons App). 95 | OFFSET_RIGHT_MOUNT = Point(x=1.24, y=2.4, z=-0.6) # offset values in mm 96 | OFFSET_LEFT_MOUNT = Point(x=-1.67, y=-0.1, z=2.0) 97 | 98 | def run(protocol: protocol_api.ProtocolContext): 99 | # Load tiprack and set the slot location. 100 | tiprack1 = protocol.load_labware('opentrons_96_filtertiprack_200ul', 1) 101 | 102 | # Apply the offset. 103 | tiprack1.set_calibration(OFFSET_RIGHT_MOUNT) 104 | 105 | # All other labware affected by the corresponding mount shall be adjusted with `set_callibration` as well. 106 | # ... 107 | ``` 108 | -------------------------------------------------------------------------------- /ot2_controller/generated/ot2controller/Ot2Controller.sila.xml: -------------------------------------------------------------------------------- 1 | 2 | Ot2Controller 3 | OT-2 Controller 4 | A SiLA 2 complaint controller for an OT-2 liquid handler. 5 | 6 | Connection 7 | Connection 8 | Connection details of the remote OT-2. 9 | No 10 | 11 | String 12 | 13 | 14 | 15 | AvailableProtocols 16 | Available Protocols 17 | List of the stored files available on the OT-2. 18 | No 19 | 20 | 21 | 22 | String 23 | 24 | 25 | 26 | 27 | 28 | CameraPicture 29 | Camera Picture 30 | A current picture from the inside of the OT-2 made with the built-in camera. 31 | No 32 | 33 | 34 | 35 | ImageData 36 | Image Data 37 | The *.jpg image. 38 | 39 | 40 | 41 | Binary 42 | 43 | 44 | 45 | image 46 | jpeg 47 | 48 | 49 | 50 | 51 | 52 | 53 | ImageTimestamp 54 | Image Timestamp 55 | The timestamp when the image was taken. 56 | 57 | Timestamp 58 | 59 | 60 | 61 | 62 | 63 | 64 | UploadProtocol 65 | Upload Protocol 66 | Uploads the given Protocol to the "/data/user_storage" directory on the OT-2. 67 | No 68 | 69 | ProtocolSourcePath 70 | Protocol Source Path 71 | The path to the Protocol to upload. 72 | 73 | String 74 | 75 | 76 | 77 | UploadFileFailed 78 | 79 | 80 | 81 | RemoveProtocol 82 | Remove Protocol 83 | Removes the given Protocol from the "/data/user_storage" directory on the OT-2. 84 | No 85 | 86 | ProtocolFile 87 | Protocol File 88 | The file name of the Protocol to remove. 89 | 90 | String 91 | 92 | 93 | 94 | RemoveFileFailed 95 | 96 | 97 | 98 | RunProtocol 99 | Run Protocol 100 | Runs the given Protocol on the OT-2. 101 | No 102 | 103 | ProtocolFile 104 | Protocol File 105 | The file name of the Protocol to run. 106 | 107 | String 108 | 109 | 110 | 111 | IsSimulating 112 | Is Simulating 113 | Defines whether the protocol gets just simulated or actually executed on the device. 114 | 115 | Boolean 116 | 117 | 118 | 119 | ReturnValue 120 | Return Value 121 | The returned value from the executed protocol. On a simulated execution, only the value 0 122 | is indicating a successful simulation. 123 | 124 | Integer 125 | 126 | 127 | 128 | 129 | CameraMovie 130 | Camera Movie 131 | A current video from the inside of the OT-2 made with the built-in camera. 132 | No 133 | 134 | LengthOfVideo 135 | Length Of Video 136 | Duration of the video, in hours, minutes, seconds. 137 | 138 | Time 139 | 140 | 141 | 142 | VideoData 143 | Video Data 144 | The *.mp4 video. 145 | 146 | 147 | 148 | Binary 149 | 150 | 151 | 152 | video 153 | mp4 154 | 155 | 156 | 157 | 158 | 159 | 160 | VideoTimestamp 161 | Video Timestamp 162 | The timestamp when the video was taken. 163 | 164 | Timestamp 165 | 166 | 167 | 168 | 169 | UploadFileFailed 170 | Upload File Failed 171 | The upload of the file to the OT-2 device failed. 172 | 173 | 174 | RemoveFileFailed 175 | Remove File Failed 176 | The file on the OT-2 device does not exist or could not be removed. 177 | 178 | 179 | -------------------------------------------------------------------------------- /ot2_controller/feature_implementations/ot2controller_impl.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import logging 4 | from datetime import datetime, timezone 5 | from pathlib import Path 6 | from typing import Any, Dict, List, Optional 7 | 8 | import paramiko 9 | from paramiko.client import SSHClient 10 | from paramiko.pkey import PKey 11 | from scp import SCPClient, SCPException 12 | from sila2.framework import FullyQualifiedIdentifier 13 | 14 | from ..generated.ot2controller import CameraPicture_Response, Ot2ControllerBase, CameraMovie_Response 15 | 16 | DEFAULT_SSH_PRIVATE_KEY: str = "~/.ssh/ot2_ssh_key" 17 | DEVICE_USERNAME: str = "root" 18 | USER_STORAGE_DIR: str = "/data/user_storage/" 19 | 20 | 21 | class Ot2ControllerImpl(Ot2ControllerBase): 22 | device_ip: str 23 | """Path to the SSH private key file""" 24 | pkey: PKey 25 | """The actual private key used by Paramiko""" 26 | ssh: SSHClient 27 | """The SSH client used by Paramiko""" 28 | 29 | def __init__(self, device_ip: str, pkey_path: Optional[str] = None): 30 | self.device_ip = device_ip 31 | # The the location of the generated private key. 32 | # https://support.opentrons.com/en/articles/3203681-setting-up-ssh-access-to-your-ot-2 33 | # https://hackersandslackers.com/automate-ssh-scp-python-paramiko/ 34 | if pkey_path is None: 35 | self.pkey = paramiko.RSAKey.from_private_key_file(str(Path(DEFAULT_SSH_PRIVATE_KEY).expanduser().resolve())) 36 | else: 37 | self.pkey = paramiko.RSAKey.from_private_key_file(str(Path(pkey_path).expanduser().resolve())) 38 | 39 | self.ssh = paramiko.SSHClient() 40 | # Load SSH host keys. 41 | self.ssh.load_system_host_keys() 42 | # Add SSH host key automatically if needed. 43 | self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 44 | # Connect to device using key file authentication. 45 | self.ssh.connect(hostname=device_ip, username=DEVICE_USERNAME, pkey=self.pkey, look_for_keys=False) 46 | 47 | self.__logger = logging.getLogger(self.__class__.__name__) 48 | 49 | def get_Connection(self, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> str: 50 | return f"Device IP: {self.device_ip}, SSH key fingerprint: {self.pkey.get_fingerprint().hex()}" 51 | 52 | def get_AvailableProtocols(self, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> List[str]: 53 | ssh_stdin, ssh_stdout, ssh_stderr = self.ssh.exec_command(f"ls {USER_STORAGE_DIR}") 54 | return [line.strip() for line in ssh_stdout.readlines() if line.endswith(".py")] 55 | 56 | def get_CameraPicture(self, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> CameraPicture_Response: 57 | out_image_file: str = "/tmp/tmp_image.jpeg" 58 | cmd: str = f"ffmpeg -y -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:1 -frames 1 {out_image_file}" 59 | 60 | self.__logger.debug(f"run '{cmd}'") 61 | ssh_stdin, ssh_stdout, ssh_stderr = self.ssh.exec_command(cmd) 62 | run_ret: int = ssh_stdout.channel.recv_exit_status() 63 | self.__logger.debug(f"run returned '{str(run_ret)}'") 64 | 65 | scp = SCPClient(self.ssh.get_transport()) 66 | try: 67 | scp.get(out_image_file, "/tmp/tmp_image.jpeg", recursive=False) 68 | self.__logger.debug(f"Downloaded {out_image_file} to /tmp/tmp_image.jpeg") 69 | except SCPException as error: 70 | self.__logger.error(error) 71 | raise 72 | finally: 73 | scp.close() 74 | 75 | return CameraPicture_Response( 76 | ImageData=open("/tmp/tmp_image.jpeg", "rb").read(), ImageTimestamp=datetime.now(timezone.utc) 77 | ) 78 | 79 | def UploadProtocol(self, ProtocolSourcePath: str, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> None: 80 | scp = SCPClient(self.ssh.get_transport()) 81 | file: str = str(Path(ProtocolSourcePath).expanduser().resolve()) 82 | 83 | try: 84 | scp.put(file, recursive=True, remote_path=USER_STORAGE_DIR) 85 | except SCPException as error: 86 | self.__logger.error(error) 87 | raise 88 | finally: 89 | scp.close() 90 | 91 | self.__logger.debug(f"Uploaded {file} to {USER_STORAGE_DIR}") 92 | 93 | def RemoveProtocol(self, ProtocolFile: str, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> None: 94 | protocol: str = ProtocolFile.strip() 95 | if not protocol.endswith(".py"): 96 | raise ValueError("The file is not a python protocol.") 97 | 98 | file: str = str(Path(USER_STORAGE_DIR + protocol)) 99 | self.__logger.debug(f"remove: {file}") 100 | 101 | ssh_stdin, ssh_stdout, ssh_stderr = self.ssh.exec_command(f"rm {file}") 102 | # TODO: remove debug logs on release 103 | self.__logger.debug(ssh_stdout.readlines()) 104 | self.__logger.debug(ssh_stderr.readlines()) 105 | remove_ret: int = ssh_stdout.channel.recv_exit_status() 106 | self.__logger.debug(f"remove returned '{str(remove_ret)}'") 107 | if remove_ret != 0: 108 | raise ValueError(f"The removal of the file '{file}' was not successful.") 109 | 110 | def RunProtocol( 111 | self, ProtocolFile: str, IsSimulating: bool, *, metadata: Dict[FullyQualifiedIdentifier, Any] 112 | ) -> int: 113 | if IsSimulating: 114 | cmd: str = f"python3 -m opentrons.simulate {USER_STORAGE_DIR}{ProtocolFile}" 115 | else: 116 | cmd: str = f"python3 -m opentrons.execute {USER_STORAGE_DIR}{ProtocolFile}" 117 | 118 | self.__logger.debug(f"run '{cmd}'") 119 | ssh_stdin, ssh_stdout, ssh_stderr = self.ssh.exec_command(cmd) 120 | 121 | for line in ssh_stderr.readlines(): 122 | print(line, end="") 123 | 124 | for line in ssh_stdout.readlines(): 125 | print(line, end="") 126 | 127 | run_ret: int = ssh_stdout.channel.recv_exit_status() 128 | self.__logger.debug("run returned '" + str(run_ret) + "'") 129 | 130 | if IsSimulating and run_ret != 0: 131 | raise ValueError("The simulation of the protocol was not successful.") 132 | 133 | return run_ret 134 | 135 | def CameraMovie(self, LengthOfVideo, *, metadata: Dict[FullyQualifiedIdentifier, Any]) -> CameraMovie_Response: 136 | time_video = str(LengthOfVideo)[:8] 137 | out_video_file: str = "/tmp/tmp_video.mp4" 138 | cmd: str = f"ffmpeg -y -video_size 320x240 -i /dev/video0 -t {time_video} {out_video_file}" 139 | 140 | self.__logger.debug(f"run '{cmd}'") 141 | ssh_stdin, ssh_stdout, ssh_stderr = self.ssh.exec_command(cmd) 142 | run_ret: int = ssh_stdout.channel.recv_exit_status() 143 | self.__logger.debug(f"run returned '{str(run_ret)}'") 144 | 145 | scp = SCPClient(self.ssh.get_transport()) 146 | try: 147 | scp.get(out_video_file, "/tmp/tmp_video.mp4", recursive=False) 148 | self.__logger.debug(f"Downloaded {out_video_file} to /tmp/tmp_video.mp4") 149 | except SCPException as error: 150 | self.__logger.error(error) 151 | raise 152 | finally: 153 | scp.close() 154 | 155 | return CameraMovie_Response( 156 | VideoData=open("/tmp/tmp_video.mp4", "rb").read(), VideoTimestamp=datetime.now(timezone.utc) 157 | ) 158 | 159 | def __del__(self): 160 | # Close connection 161 | self.ssh.close() 162 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------