TCode Integrator API

The TCode integrator is the other side of tcode_api.commands.SEND_WEBHOOK. Here is an example integration with ATC Thermocycler. The ATCThermoCycler class came from pylabrobot.

from tcode_api.servicer.integrator import TCodeIntegratorBase, WebHookBody

class ATCIntegrator(TCodeIntegratorBase):
    async def perform_action(self, data: WebHookBody):
        thermal_cycler = ATCThermoCycler("192.168.8.129")
        await thermal_cycler.setup()

        if data.payload == "open_lid":
            await thermal_cycler.open_lid()
        elif data.payload == "close_lid":
            await thermal_cycler.close_lid()

        await thermal_cycler.stop()

        if data.is_execution_paused:
            self.resume_tcode()


integrator = ATCIntegrator()
integrator.serve()

The TCode used to trigger this action is

script.commands.append(
    tc.SEND_WEBHOOK(pause_execution=True, url="http://localhost:8092", payload="open_lid")
)

API Reference

class tcode_api.servicer.integrator.TCodeIntegratorBase(tcode_server_host=None)

The base class for TCodeIntegrator. Upon encountering SEND_WEBHOOK command, the control for TCode is transferred to subclass of this interface.

Parameters:

tcode_server_host (str | None)

class tcode_api.servicer.integrator.WebHookBody(**data)

The webhook request that is sent out with SEND_WEBHOOK

Parameters:
  • timestamp (float) – UNIX timestamp of the request in seconds

  • fleet_name (str) – Name of the fleet controller that triggered the request :param destination_url: The destination URL of this request as specified in TCode. This parameter can be useful if your integrator is behind a reverse-proxy or is controlled by a third party.

  • is_execution_paused (bool) – Whether the execution of the script is paused

  • payload (str | None) – The custom payload as specified. Max size 32KB.

  • destination_url (str)